I’m a JavaScript girl who really likes C

I have a confession. I’m a JavaScript girl who really likes the C programming language. I took a boot camp and learned all about JS, because I thought that C was scary, I also thought that C was a not so useful programming language any more. Well, I’m going with the line from Home Alone, “I’m not afraid anymore”.

Home alone Not afraid anymore

I’m picking up C and it’s going swimmingly.

I am dabbling with the course CS50 on edX and it’s quite exciting.

I really how we write #include <stio.h> and how I have to point my pointers somewhere and deal with memory, it’s like all the things I don’t have to think about, I’m becoming more aware of. There’s more going on under the hood and I’m really digging it.

The C Programming Language book cover

If you want to come join me, the course is called CS50’s Introduction to Computer Science and is available for free on edX.

They have other languages as well further in the course, Python and JavaScript. I’m half tempted to go jump to those and knock them out of the way since I already know those languages and they’re low hanging fruit for me, but I’m being good and staying on track.

cs50 Problem Sets

I already have plans for the final project and will be working on that as I make my way through the course. It’s called Service Dog Log, it’s a logging application for dog training, specifically aimed to be of assistance to the service dog community, but will be able to be used by anyone training their dog. It will track a dogs progress over time, encourage the user to keep training their dog(s) and give helpful suggestions for training your dog.

Connecting Eat Da Burger to JawsDB on Heroku

Steps to setting up the Node/Express/MySQL app EatDaBurger on Heroku with a working database.

My code for this app is located at Github
I’ve deployed this app using these steps to Heroku

Screenshot of Eat the burger MySQL application

Step 1.

Add a .env file, which you will use to get the process.env variable from for your MySQL database. Also add the .env file to your .gitignore. You don’t want to add your database credentials to GitHub or anywhere else on the internet where it can be grabbed.
echo .env >> .gitignore
There’s more information on getting JawsDB set up at https://devcenter.heroku.com/articles/jawsdb

Inside your .env file set the JAWSDB_URL equal to your MySQL string you get from JawsDB, you can get this information from https://dashboard.jawsdb.com/mysql/dashboard or from the running the command heroku config:get JAWSDB_URL

JAWSDB_URL='mysql://username:password@hostvalue.amazonaws.com:3306/nameOfYour_db'

Step 2.

Inside your connection file add this to connect with JawsDB if it’s online or localhost if you’re on your machine

var mysql = require('mysql');

var connection;
if (process.env.JAWSDB_URL) {
    // Database is JawsDB on Heroku
    connection = mysql.createConnection(process.env.JAWSDB_URL);
} else {
    // Database is local
    connection = mysql.createConnection({
        port: 3306,
        host: 'localhost',
        user: 'root',
        password: '',
        database: 'nameOfYour_db'
    })
};

var mysql = require('mysql');

Step 3.

Set up db connection to your JawsDB in MySQL workbench.
Use your JawsDB credentials to sign into MySQL workbench, then open up a SQL editior.
Inside the SQL editor, make sure you’re using your JawsDB database, by running the USE command.

USE jawsDBname;

Once you’re inside your database, using your JawsDB databse, then run your SQL commands in MySQL workbench.
Now your app should be working within a couple of minutes.

Extra Step. If error.

If you’re getting error H13.
Whenever your app experiences an error, Heroku will return a standard error page with the HTTP status code 503. To help you debug the underlying error, however, the platform will also add custom error information to your logs. Each type of error gets its own error code, with all HTTP errors starting with the letter H and all runtime errors starting with R. Logging errors start with L.

I looked up the heroku error code, which you can read yourself, which wasn’t that helpful in solving the problem.
https://devcenter.heroku.com/articles/error-codes#h13-connection-closed-without-response

These two articles were helpful.
https://github.com/request/request#requestoptions-callback
https://devcenter.heroku.com/articles/request-timeout

Here’s what you need to do. Inside your server.js file, add a timeout. I grabbed a timed out function, then it has to be called after your app.use statements.

// Timeout
app.use(timeout(15000));
app.use(haltOnTimedout);

function haltOnTimedout(req, res, next) {
    if (!req.timedout) next();
}

I hope this has been helpful, if you have questions, leave me a comment.