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.

Thursday, November 3, 2011

String trimming in Javascript

Here is a simple trim function to remove leading and trailing whitespaces.

function trim(s) {
return s.replace(/^\s*|\s*$/g, '');
}

and in CoffeeScript
trim = (s) ->
s.replace /^\s*|\s*$/g, ''


You can check Steven Levithan's collection of trim functions.

Saturday, October 29, 2011

'Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.' error in MacVim (Janus)

After launching MacVim you may get this annoying error message:
'Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.'

To remove this you have to install ctags which you can download from http://ctags.sf.net.
After you unziped it, you have to set the Tlist_Ctags_Cmd variable in the .vimrc file to point to the ctags folder.

let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'

After that you have to restart vim and the message should not pop up again.

Tuesday, October 25, 2011

Launching MacVim from Command line

Put this into your .profile or .zshrc file
function mvim { /Applications/MacVim.app/Contents/MacOS/Vim -g $*; } 

Then you can use 'mvim' in the command line.

The full explanation is in the MacVim Google Groups