Installing the MEAN Stack on Cloud9

Create a new Node.js workspace, then enter the following in the shell:

rm -rf *
nvm install stable
echo "export NODE_PATH=$NODE_PATH:/home/ubuntu/.nvm/versions/node/v0.12.7/lib/node_modules" >> ~/.bashrc
source ~/.bashrc
npm install -g npm
npm install -g yo
npm install -g grunt
npm install -g grunt-cli
npm install -g bower
npm install -g generator-angular-fullstack

Make sure that you use the updated Node.js version when you update NODE_PATH.

You can then deploy the Angular.js scaffold:

yo angular-fullstack

Answer the questions thusly:

Javascript, Yes (ES6), HTML, CSS, ngRoute, Yes (Bootstrap), Yes (UI Bootstrap), Yes (Mongoose), Yes (authentication), Twitter, No (

Yeoman will then attempt to run bower and npm to install dependencies. If it fails, run these two commands:

bower install
npm install

Next, we'll set up MongoDB:

mkdir data
echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"' > mongod
chmod a+x mongod

Open a new terminal window (since the once you were just working in is now busy with MongoDB), and start the server:

grunt serve

Due to the small amount of memory available on a micro instance, I had to delete the node_modules directory and run 'npm cache clean', then 'npm install' again to resolve an error I was getting when trying to start the server.

Remote Editing Using Atom

Atom has quickly become my favorite code editor. Since I've successfully deployed the MEAN stack to my Digital Ocean droplet, I now want to be able to edit files on the server from the comfort of my own Windows box. This one got a little dicey, but I was able to figure it out. Here goes:

A few prerequisites that are not included in this guide:

  1. You'll need a remote server with SSH working
  2. You'll need to install Atom on your Windows box
  3. You'll need to install PuTTY on your Windows box

Now to the good stuff:

Open up Atom and install the 'remote-adam' package

On your remote server, install 'rmate'

curl -o /usr/local/bin/rmate
sudo chmod +x /usr/local/bin/rmate

I renamed 'rmate' to 'ratom'.

sudo mv /usr/local/bin/rmate /usr/local/bin/ratom

Set up PuTTY

  1. Set up your SSH session the way you normally would
  2. Navigate to Connection -> SSH -> Tunnels
  3. Under 'Add new forwarded port', enter 52698 for the source port, localhost:52698 for the destination, and choose the 'Remote' radio button
  4. Go back to the main screen and save what you've done so you don't have to do it again

Connect to your remote server using PuTTY and the settings you just created.

In Atom, click 'Packages' and then 'Remote Atom' -> 'Start Server'.

Finally, on your remote server, type

ratom path_to_file/filename

and you will magically be editing that file on your local machine!

Every time  you save, remote-atom will upload the document back to the remote server.

To finish, close the last file in Atom, then click 'Packages' and 'Remote Atom' -> 'Stop Server'. You can then close your SSH connection.

RegEx for Validating North American Phone Numbers

This is a regular expression for validating a 7 or 10 digit phone number, with extensions allowed, and using space, dashes, or periods as delimiters:


Better to use a specialized library, though:

Convert to Roman Numerals

Method for converting Arabic to Roman Numerals in Javascript.

var roman = {
    map: [
        1000, 'M', 900, 'CM', 500, 'D', 400, 'CD', 100, 'C', 90, 'XC',
        50, 'L', 40, 'XL', 10, 'X', 9, 'IX', 5, 'V', 4, 'IV', 1, 'I',
    int_to_roman: function(n) {
        var value = '';
        for (var idx = 0; n > 0 && idx <; idx += 2) {
            while (n >=[idx]) {
                value +=[idx + 1];
                n -=[idx];
        return value;
roman.int_to_roman(1999); // "MCMXCIX"

Run Python from within Notepad++

To run a Python script from within Notepad++

  1. Install the NppExec plugin
  2. After you restart Notepad++, press F6
  3. Enter the f0llowing into the "Execute..." dialog:
    python "$(FULL_CURRENT_PATH)"
  4. Save the script as whatever makes sense to you
  5. Press "Cancel"
  6. Press Shift-F6 to enter the Console Filters dialog
  7. Enter the following Highlight Mask:
    *File "%ABSFILE%", line %LINE%, in*
  8. Make sure the line is checked, and enter FF under red, 00 under green, 00 under blue, and check the U box (underline)
  9. Click OK

Now, when you have a script open in Notepad++, just hit F6 to run it. Any errors will be highlighted and clickable!