Helpful if you have an iOS device.
http://www.overthought.org/blog/2014/the-ultimate-guide-to-solving-ios-battery-drain
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
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/
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 COLUMNcolumn1
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 = '';
An interesting read. 'Don’t use security questions' is one I think all developers should LEGALLY be required to adhere to.
http://kennethjorgensen.com/blog/2014/dont-reset-my-password/
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.
A huge list of patterns that you can use as background images for your website.
Via Reddit
Working with CSV files sucks. You have to handle different line endings and entries can be wrapped in double quotess which could have a comma inside of it preventing you from just using explode()
. Thankfully, PHP provides two functions for working with CSV files that are super helpful.
The first is fgetcsv
which reads from a file handle and brings in single line broken into an array. If you've every worked with processing csv files before you know how awesome this is. As an example,
The other is fputcsv
which writes to a file with the correct formatting for a CSV file:
Occasionally, we want to create a CSV file for a user to download. We could save the file to disk and then redirect to the output but I would rather just output the results:
Using fgetcsv
we can convert a CSV file into an associative array. I like this approach because then it doesn't mater what order the columns are in the CSV.
A couple weeks ago I was working on an older development VM that was setup with a smaller hard drive and I started getting unexpected end of file error messages. I couldn't find the problem in my file so I was going to run git diff
on the file to see what I've changed. I started do this and ran into a problem:
user@VM:/var/www/$ ls -l <tab>bash: cannot create temp file for here-document: No space left on device
bash: cannot create temp file for here-document: No space left on device
Shit!
Well, that explains why I couldn't find the problem...
Read More
subscribe via RSS