Installing a Specific Version of a Gem

Last week, I needed to setup a new VM with a copy of the STAGES website so I could do some testing. We use SASS to preprocess our CSS files but I started running into weird errors when tried to compile them. In order to fix this I had to install the same version we were using on our webserver into the VM. In order to do this you need to pass the -v flag:

gem install sass -v 3.2.12

Link Post: Your Greatest Code Quality Threats and How to Solve Them

I find that heterogeneity can really hurt productivity. I’ll sometime brood over how someone didn’t use braces for an if statement or didn’t tab the correct number of times (really, how hard is this!) and I’ll get lost in the fact that I’m there looking to fix a bug. The other items on this list are good too.

http://blog.codacy.com/2014/06/19/your-greatest-code-quality-threats-and-how-to-solve-them/

A Fix For MySQLs 1292 Error

I was trying to add a new column to an old table and I ran into a problem:

Error running query: ALTER TABLE table ADD COLUMN column1 VARCHAR(255) NOT NULL
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: ’0000-00-00′ for column ‘column’ at row 2

It turns on something similar to this problem has existed for a long time (http://bugs.mysql.com/bug.php?id=33240) and the fix is to run the command below before running the alter:

set SQL_MODE = '';

Looping Your Unit Tests

When I write my code I like to have my unit tests run automatically but sometimes I need to focus on a single test but I don’t want to tab to the window where you’re running your unit tests to run them (I know, how lazy can you be). When this happen I like to do two things.

The first is that I can run phpunit in a continuous loop with a one second delay so I can read the screen:

while(true); do vendor/bin/phpunit -c tests --filter <filter>; sleep 1; done

This works well but you end up having the tests run constantly which can drain your battery (if like me you aren’t plugged in every so often). In this case I use the following:

while(true); do vendor/bin/phpunit -c tests --filter <filter>; read -p "Press Enter..."; done

Which will wait for an enter key before running the tests a second time.