code

GIT Commands Cheat Sheet

Monday, January 25, 2016
By Colin

A cheat sheet of git commands that I use the most, and also of the ones I use the least (which is really much more important to have on a cheat sheet). »

Amazon Silk Browser does not send a user agent when downloading assets specified in a cache manifest

Saturday, May 31, 2014
By Colin

Here is some header info for a file downloaded by the part of the silk browser that is reading the cache manifest: Date: May 31 21:41:56 HTTP Code: 200 HTTP Version: HTTP/1.1 Referer: - Size (in bytes): 16057 User Agent: This means that if you are trying using the user agent on the server... »

aboutmydevice.com : a new site that helps explore a mobile browser’s Javascript properties

Wednesday, September 7, 2011
By Colin
aboutmydevice.com : a new site that helps explore a mobile browser’s Javascript properties

Here’s the latest website I’m releasing onto the world: aboutmydevice.com. I wrote  it so that I could explore what Javascript properties, objects, and values exist on the browsers of various mobile devices. I walk into a store, go to a phone, load up aboutmydevice.com, and see what kind of properties this browser has. It’s... »

Perl script make MySQL query, binds variables, outputs JSON

Friday, July 16, 2010
By Colin

An example of a Perl script that is called by an ajax request. The script takes in just one parameter, opens a MySQL DB connection, binds the parameter to the query, and sends the query. The result is then formatted into JSON and returned to the browser. This can be seen in action on... »

Perl script makes MySQL query; outputs to JSON

Sunday, June 20, 2010
By Colin

An example of a perl script that is called by an ajax request. The script takes in a few parameters, opens a mySQL DB connection, and then makes a rather tortuous query. The result is then formatted in to JSON and returned to the browser. »

UNIX/AWK Tricks: How to copy a long list of files into a directory

Sunday, April 25, 2010
By Colin

Make your list of files, with complete paths, call it “imgList.txt”. Put every file on a new line. Write a small awk script with the following 1 line: { printf(“cp %s images/\n”,$0);} Save the script as “copyList.awk” Do the following command: awk -f copyList.awk imgList.txt | sh Brief explanation of the awk script: %s... »

HTML Character Entities in Javascript

Sunday, April 25, 2010
By Colin

Sometimes you need to write html character entities in javascript, but html character entities can’t be used, because they don’t get interpreted by javascript. In javascript, you need to use the equivalent unicode character codes instead. HTML character entity, wrong: formElement.value = "Dirección"; You get: Dirección Unicode character code, correct: formElement.value = "Direcci\u00F3n"; You... »

Handy MySQL Commands

Sunday, April 25, 2010
By Colin

To reset an auto_increment field to 1: ALTER TABLE tbl_name AUTO_INCREMENT = 1; To load a local csv file into an empty existing table: LOAD DATA LOCAL INFILE ‘/completePathToLocalData.csv’ INTO TABLE tableName FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’ IGNORE 1 LINES; This assumes you’ve already created your empty table... »

jQuery parsererror: clean up your JSON objects

Sunday, March 7, 2010
By Colin

Has your JSON using jQuery web app suddenly stopped working?  Getting a parsererror on your JSON objects, where you got none before?  This is what happened to me when my site upgraded to jQuery 1.4. I use the Google API’s jQuery, and it automatically upgraded my whole site to jQuery 1.4.   In jQuery... »