grantnicholas.io
A blog about my adventures in programming
Nodemailer is a super awesome way to send emails through node
Just try it. It is super easy to setup. http://www.nodemailer.com
Shrink PDF files from the terminal
Really quick terminal command to shrink large PDF files for sites with stubborn upload limits: convert -density 200x200 -quality 60 -compress jpeg input.pdf output.pdf Just change the quality to a lower number to reduce the filesize even more.
Mongodb set dbpath and debugging
From the node project directory use the following command to launch mongodb with the path to the data directory: mongod --dbpath /path/to/data ie) mongod --dbpath ~/Desktop/nodeCIHL/data If there is an error about the address being in use check that mongod is not already active with sudo service mongodb stop mongod...
Adding click handlers in a loop with javascript closures
I wanted to make an array of elements on a page all have an event happen on click. I first tried: for(var i=0; i<array.length; i++){ jQuery(array[i]).click(function(){ coolEventGoesHere(); }); } I quickly ran into a common javascript error of trying to add click handlers in a loop. This stackoverflow post about...
Override default behavior of a link in a div
The problem: I was developing a page in drupal to display a slideshow of views (with linkable content within the views). However, the default views slideshow behavior was to advance forward a slide on click, making the links within the views useless. The solution: I first disabled the click to...