Installing the MEAN stack on Digital Ocean

After trying multiple times to get the MEAN stack (MongoDB, Express, AngularJS, Node.js) up and running, I have finally hit upon the correct set of steps. For all the world's benefit, here is how to install MEAN.JS from scratch!

As a prerequisite to the following steps, I created an Ubuntu 14.04 droplet on Digital Ocean and went through their published steps to get everything set up.

Install Node.js

curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install --yes nodejs

Install MongoDB

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org

Make sure MongoDB is listening on the right port (should be 27017)

tail /var/log/mongodb/mongod.log

Install Bower

npm install -g bower

Install Grunt

npm install -g grunt-cli

Download and install MEAN.JS

git clone https://github.com/meanjs/mean.git meanjs
cd meanjs
git checkout 0.4.0
npm install

Run it!

grunt

At this point, you should be able to point your browser to <your_ip>:3000 to view the fruits of your labor. Unless, of course, you have a firewall problem. 🙂

One last note: don't use sudo to handle global npm installations. Use npm-g_nopsudo instead. After following those instructions, I had to do the following to make everything work right:

npm config set prefix ~/npm
echo export PATH="$HOME/npm/bin:$PATH" >> ~/.bashrc
echo "export NODE_PATH=$NODE_PATH:/home/$USER/npm/lib/node_modules" >> ~/.bashrc && source ~/.bashrc

I also had to do this for bower to work with git:

git config --global url."https://".insteadOf git://

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:

/^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/g

Better to use a specialized library, though: https://github.com/googlei18n/libphonenumber

SSH to a Local Bitnami VM

I'm using a Bitnami Virtual Appliance (MEAN stack) for development purposes, and I was having a trouble connecting to it via SSH. Finally found the key. Here's what you need to do to enable

$ sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf
$ sudo start ssh

and disable

$ sudo stop ssh
$ sudo mv /etc/init/ssh.conf /etc/init/ssh.conf.back

the SSH server.

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 < this.map.length; idx += 2) {
            while (n >= this.map[idx]) {
                value += this.map[idx + 1];
                n -= this.map[idx];
            }
        }
        return value;
    }
}
 
roman.int_to_roman(1999); // "MCMXCIX"

Low Carb Vanilla Cheesecake

Low Carb Vanilla Cheesecake
Write a review
Print
Ingredients
  1. 1 1/2 C almond flour
  2. 3 tbsp Splenda (sucralose)
  3. 1/2 C melted butter
  4. 24 oz cream cheese (3 packages)
  5. 1 C Splenda (sucralose)
  6. 1 tbsp vanilla extract
  7. 3 eggs
  8. 1 C sour cream
Instructions
  1. Combine almond flour and 3 tbsp Splenda. Add melted butter. Mix thoroughly and press into 9" springform pan. Bake 5-10 minutes at 350 degrees until set.
  2. In a mixer, combine cream cheese, Splenda, and vanilla extract. Mix until incorporated. Add eggs one at a time and mix slowly until smooth. Stir in sour cream by hand until well combined.
  3. Spoon cream cheese mixture evenly onto prepared crust. Bake at 350 degrees for 45 minutes. The center should NOT be done. Turn off the oven and leave the cheesecake in the hot oven for an additional half hour. Remove and cool completely. Chill at least four hours, preferably overnight.
Excogitation https://www.excogitation.org/

Classic Deviled Eggs

Classic Deviled Eggs
Serves 6
Write a review
Print
Ingredients
  1. 6 hard cooked eggs
  2. 1/4 C mayonnaise
  3. 1 tsp vinegar
  4. 1 tsp yellow mustard
  5. 1/8 tsp salt
  6. black pepper to taste
Instructions
  1. Cut the eggs in half length-wise (after shelling, of course) and remove the yolk. Set aside the whites. Combine the yolks and the rest of the ingredients. Mix until relatively smooth, then spoon into the reserved white halves. Serve cold.
Excogitation https://www.excogitation.org/

Rip a CD using VLC

VLC lets you rip CD audio, but you have to do it one track at a time. Here's a handy batch file that rips the whole CD at once. Just put this in the folder that you want the tracks ripped to and set it loose!

@ECHO OFF

setlocal ENABLEDELAYEDEXPANSION

SET /a x=0

FOR /R D:\ %%G IN (*.cda) DO (CALL :SUB_VLC "%%G")
GOTO :eof

:SUB_VLC
call SET /a x=x+1

ECHO Transcoding %1
REM Here's where the actual transcoding/conversion happens. The next line
REM fires off a command to VLC.exe with the relevant arguments:
CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I http cdda:///D:/ --cdda-track=!x! :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access="file",mux=raw,dst="Track!x!.mp3"} vlc://quit

:eof
Rip CD with VLC.cmd

Crashplan Central “Sea” List

I'll update this as I encounter more. I couldn't find a list online, so I'm starting one. I'm adding these to the "skip" list of my web filter to keep backup running smoothly. I didn't think they changed, but I've had a couple change on me in the last couple of months, so I just keep monitoring it.

aub-sea.crashplan.com [162.222.41.101]
cea-sea.crashplan.com [162.222.40.18]
cia-sea.crashplan.com [162.222.40.38]
cjb-sea.crashplan.com [162.222.41.48]
crc-sea.crashplan.com [162.222.40.215]
cya-sea.crashplan.com [162.222.40.118]
ddb-sea.crashplan.com [162.222.41.19]
dkd-sea.crashplan.com [162.222.41.181]
dmf-sea.crashplan.com [162.222.42.177]
dnc-sea.crashplan.com [162.222.40.196]
dua-sea.crashplan.com [162.222.40.99]
epb-sea.crashplan.com [162.222.41.80]
eqa-sea.crashplan.com [162.222.40.80]
erf-sea.crashplan.com [162.222.42.203]

Easy eBook Creation with Pandoc and Sigil

Recently, I had a rather lengthy Word document that I wanted to convert into an eBook. I love the EPUB format. Whenever I can, that's the format I prefer to buy my books in. When I can't, as long as there's no draconian DRM involved, I'm happy to use Calibre to convert them.

Unfortunately, authoring an EPUB by hand is a royal pain. It's much easier to put together your document in a nice WYSIWYG editor like Word. The problem is that Word produces absolutely atrocious HTML on export. I spent some time over the last couple of days looking for a solution to get easily from Word to EPUB without a lot of fuss.

Enter Pandoc. Written in Haskell (which is impressive by itself), Pandoc bills itself as "a universal document converter". Hit the link to see everything that it can do.

After downloading and installing Pandoc, I fired up a CMD window (sorry, no GUI for you!). This one line turned my DOCX file into a beautiful EPUB:

pandoc -f docx -t epub3 -o output.epub input.docx

When it was done processing, I opened it up in Sigil and was amazed at what I saw! The only edit I made was to add a cover. The table of contents worked perfectly and Pandoc had divided my document into chapters at each Heading 1 section.