• AWS EC2 NodeJS, Forever, HAProxy Setup

    Sign up for EC2

    Create an instance, I used one from here, Alestic, paste in the ami-xxxxxx value to find the one you want.

    Create an security group with at least SSH and HTTP.

    Save your private key and connect like:

    ssh -i your_key.pem ubuntu@ec2-instance-location.amazonaws.com

    Update and install the needed packages:

    sudo apt-get update
    sudo apt-get install git-core g++ make curl libssl-dev

    Install node, get latest url at NodeJS.org

    curl -O http://nodejs.org/dist/node-v0.2.6.tar.gz
    tar -xvzf node-v0.2.6.tar.gz
    cd node-v0.2.6
    sudo make install

    Node Package Manager

    Install Node Package Manager.

    sudo chown -R $USER /usr/local/{share/man,bin,lib/node}
    curl http://npmjs.org/install.sh | sh


    This will be used to keep your node process running, forever. Restarting as needed.

    keep NodeJS running with Forever

    npm install forever

    HA Proxy

    HA Proxy

    HA Proxy Logging

    Quickly setup a load balanced high availability cluster

    ACL Proxy Config for HAProxy

        log   local0
        log   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        log global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout  5000
        clitimeout  50000
        srvtimeout  50000
    frontend http-in
        bind *:80
        acl is_domain_com hdr_end(host) -i domain.red27.net
        use_backend domain_com if is_domain_com
        default_backend hello
    backend domain_com
        option httpchk HEAD /check.txt HTTP/1.0
        option httpclose
        option forwardfor
    backend hello
        option httpchk HEAD /check.txt HTTP/1.0
        option httpclose
        option forwardfor

    change /etc/default/haproxy

    # Set ENABLED to 1 if you want the init script to start haproxy.
    # Add extra flags here.
    #EXTRAOPTS="-de -m 16"


    sudo /etc/init.d/haproxy start
    sudo forever start path-to-app.js


    NOTE: don’t forget to create and EBS AMI Image so your stuff is saved.


    NodeJs for server newbs


    EC2 Getting Started

    Alestic AMI’s

    NodeJS on your own AMI

    Node as a service

    HA Proxy Setup

  • NodeJS Web Applicaiton Links

    Node API Docs and Resources

    More links from my recent NodeJS hacking.

    Node JS API 0.2.6

    Express JS

    Expresso JS

    Node JS Modules

    Node Twilio

    Node Twilio Docs

    JS Reference from Mozilla

    Jade, Hmal like view engine

    Nodester Hosting

  • Node JS Notes

    Getting Node Setup

    Node JS

    How To Node

    Download the latest package from Node JS

    tar -vxzf node-v0.2.6.tar.gz
    cd node-v0.2.6
    make install

    Package Manager

    How To Node NPM




    npm install express
    npm install connect
    npm install jade

    Get the express samples to see how things work

    git clone https://github.com/visionmedia/express.git

    If you follow the hello world example, you might see the following error

        throw e;
    Error: session requires the "secret" option string for security
        at Object.sessionSetup (/usr/local/lib/node/.npm/connect/0.5.5/package/lib/connect/middleware/session.js:45:13)
        at Server.<anonymous> (/Users/dustycandland/projects/smsbet/app/app.js:18:19)
        at Server.configure (/usr/local/lib/node/.npm/express/1.0.3/package/lib/express/server.js:332:8)
        at Object.<anonymous> (/Users/dustycandland/projects/smsbet/app/app.js:12:5)
        at Module._compile (node.js:462:23)
        at Module._loadScriptSync (node.js:469:10)
        at Module.loadSync (node.js:338:12)
        at Object.runMain (node.js:522:24)
        at Array.<anonymous> (node.js:756:12)
        at EventEmitter._tickCallback (node.js:55:22)

    FIX: add the { secret: 'some random text' } to the app.js configure section

    app.use(express.session({ secret: 'some random text' }));

    Hearding Code Podcast

    How To Node NPM

    Mongo DB OSX Install

    Mongo DB with Express

    Express JS

  • Building Web Applications

    I’ve been working on a series of posts on my consulting site, Red27.net, about building web applications. These posts are really focused toward less technical folks. However, I wanted to post about it here to get any additional feedback people might have. Also, feel free to forward on to people that might find the info useful. Here’s a summery of the first few posts.

    Internet Basics: Websites

    This targets the basics of websites, like domain names, hosting, DNS, the basic connectivity of the web.

    I know we’re starting at a really basic level, but I want to build a solid foundation for the coming information. The internet is comprised of servers, large computers, and users, you.

    Internet Basics: Email

    This one is short and just talks about the importance of having an email with your domain and the power of Google App for your Domain.

    What makes web applications work?

    This post gets more into the programming aspects of web applications, HTML, CSS, JavaScript on the client and PHP, Python, Ruby, C#, Java on the server.


    Web applications are a client/server based model. The client is your web browser and the server is the web application server. There are a lot of technologies that make web applications work, but there are a few primary ones that we’ll talk about here.

    There will be more coming in the next few weeks and I’ll do another post here in a month or so. Please do forward on and post any feedback.

  • Setting Up My Fujitsu ScanSnap S300 in Ubuntu 10.10

    Mostly a post to help my future self and others trying setup a ScanSnap S300 in Ubuntu

    Things should mostly be setup by default, but there is one tricky bit. You need a file from the windows drivers. I had an old hard drive w/ my previous install to copy from. You might need to set it up in a virtual machine or another windows machine to get the file.

    Make a directory for the file at /usr/share/sane/epjitsu/

    Copy from C:\Windows\SSDriver\S300\300_0c00.nal to /usr/share/sane/epjitsu

    chmod 755 /usr/share/sane/epjitsu/300_0c00.nal

    Make sure you scanner is found using


    If it is you can do scanimage -L or sudo scanimage -L to see if things are working.

    HTH someone


  • Tips from the MountainRB ruby on rails workshop

    Yesterday I was at the MountainRB ruby workshop, which was basically an intro to rails class. It was a really good workshop and here are some tips I picked up.


    Change the config/cucumber.yml file to display pretty output, making it easier to see the failed step.

    default: -format pretty

    use Background: in cucumber features for tasks that need to happen for every scenario. Use just like Scenario

    Background: Make sure that we have a topic
      Given I go to the topics page
      And I follow "New Topic"
      And I fill in "Title" with "Rails Fixtures" 
      And I fill in "Description" with "Introduce how to add test data with fixtures."
      And I press "Create"

    Rails templates

    When you create a new rails application you can specify a template that runs after the initial generation. It can handle a lot of the initial setup. Here’s the one used used in the workshop http://gist.github.com/609269.txt

    rails new APP_NAME -m TEMPLATE_URL

    View a models attributes

    From inside the rails console you can view a models attributes by calling class on an instance of the Model.

    ruby-1.9.2-p0 &gt; (User.new).class


    rake routes will show the routes defined for the application.

            login        /login(.:format)          {:action=>"new", :controller=>"user_sessions"}
             logout        /logout(.:format)         {:action=>"destroy", :controller=>"user_sessions"}
    user_sessions GET    /user_sessions(.:format)  {:action=>"index", :controller=>"user_sessions"
    user_sessions POST   /user_sessions(.:format)  {:action=>"create", :controller=>"user_sessions"}


    Rails will cascade saves in a transaction by default

    The resource generation option will create the model and migration, while adding a blank controller and empty views directory.

    rails generate resource

    heroku open shows the current heroku app in the browser.


    http://bit.ly/ruby-resources – Resources from DevChix

    http://railsapi.com – Rails documentation

    http://boulderruby.org – Boulder user group

    http://groups.google.com/group/derailed – Denver user group

    http://RailsBridge.org - an inclusive and friendly Ruby on Rails community

  • Resize/Clone a VirtualBox hard disk with the current snapshot

    After wasting a ton of time, I’m noting this here to hopefully help myself or someone else in the future.

    Making the new virtual hard disk

    In VirtualBox open the virtual media manager and create a new disk with the larger size. Note it’s location.

    Open a command prompt to c:\program files\oracle\virtualbox and run

    VBoxManage showvminfo <Machine Name>

    Find the primary master line, and note the UUID.

    Clone that using your UUID and the path to the new disk

    VBoxManage clonehd 73880a2b-ba46-459e-b71b-816ceadecb5a c:\users\dusty.virtualbox\harddisks\CloneDisk.vdi –existing


    There may be better instructions elsewhere, but this worked for me.

    1. Attach a Linux live cd to the cdrom of the machine.

    2. Change the hard disk image to your new image file.

    3. Boot

    4. Start GParted

    5. Right click the swap and select swapoff, note the size and delete.

    6. Delete the extended partition.

    7. Resize the primary partition.

    8. Add an extended partition back.

    9. Add a swap partition back.

    10. Apply the changes.

    11. Shutdown, remove the live image from the machine, restart.