Friday, December 23, 2011

Bash script can tell its location

You can get the path of the directory in which a bash script is located FROM that bash script.

Read more about this problem on stackoverflow.

Tuesday, December 20, 2011

Print out more than 20 items in mongodb shell

When you're listing a large dataset in the shell you'll only see 20 items by default and a 'has more' text indicating that there are more.
If you want to change this limit you can use

DBQuery.shellBatchSize = 300

in the shell.

Saturday, December 17, 2011

Loading CDN hosted jQuery with local fallback

I found this piece of art in html5boilerplate.
It tries to load jQuery from a CDN and if it fails for whatever reason it tries a local one.

Friday, December 9, 2011

Creating a custom google maps marker with canvas

Generating a custom marker with canvas is handy when you want to change the marker size/color dynamically.

The following code snippet contains a 'createMarker' function that creates a canvas, draws the marker graphics and returns back the Data URL encoded version of that canvas which can be used as an input at the marker creation.

See the example below.