Installing node js on Ubuntu 14.04

See their own docs:


1 –

2 –

That’s pretty much it 🙂

Install composer on ubuntu 14.04 globally

I always seem to forget this one, or when searching never find the right blog/tutorial. So.. as usual.. here is my own reference. Run as root.

1 – If you don’t already, install the deps

2 – Download and install composer globally with one line

That’s it. Composer is now available.

Backing up and restoring a mongo database to a new server

  1. Create a dump of your database:
    1. Make a dump folder, eg “mkdir /data/dump_01/”
    2. Run the dumper: “mongodump –out /data/dump_01/”
  2. Now zip it up
    1. Ensure zip is installed: “apt-get install zip”
    2. Then zip up your folder: “zip -r /data/dump_01/”
    3. Now get your zipped folder over to the other server, i would recommend Rsync.
  3. At the other end it is basically a reverse of the above
    1. unzip
    2. This will create a folder of the zip relative to where you are.
    3.  Now just run “mongorestore dump01/”

Providing you had a running instance of mongo on the 2nd server you should now have imported your mongo db.

Removing bad images to reveal placeholder with html and css. No javascript

Load a placeholder image for say a profile picture without having to check if the actualy profile picture exists already.



That’s it.

The onerror attr on the image tag will hide the image when the href is bad meaning that bad broken image icon is no longer present, and as the image is not in the DOM the background image of the containing div is shown. Shhimplles 🙂

Get the the top 2 records of each group in a single mysql query

Eg the following result is the 2 players from each team with the highest score:

AngJs injecting new ng-inlcudes into the DOM via an array