2 min Mean stack (MongoDB, Express, Angular, Node.JS) implementation on vagrant

January 31, 2014 1 comment
# setup vagrant
vagrant init precise32 http://files.vagrantup.com/precise32.box
vagrant up
vagrant ssh

#install node
sudo apt-get update
sudo apt-get install python-software-properties  
sudo add-apt-repository ppa:chris-lea/node.js  
sudo apt-get update  
sudo apt-get install nodejs

#install yeoman
sudo npm install -g yo grunt-cli bower 

#install generator
sudo npm install generator-generator -g
sudo npm install generator-mean -g

#create project
mkdir myProject
cd testProject

yo mean

#launch server
grunt server

Update to Rails, MySQL, Ubuntu stack on AWS post

September 7, 2012 1 comment

This is an update to my first post on how to setup a working environment on Amazon EC2 with Ruby on Rails, Passenger, MySQL, and Ubuntu.

Quiet a lot has changed in last three years, so I thought I’d do a quick post to improve the installation, seeing as how the old post still receives a bit of traffic.

I’m using the official Ubuntu Server 12.04 LTS ami. Here is the rundown:

# Setup Ruby on Rails, MySql, Apache + Passenger
# on Amazon Ubuntu instance (12.04 LTS)
# 9/7/2012

echo Updating operating system and components...

sudo apt-get update -y
sudo apt-get dist-upgrade -y
sudo apt-get install build-essential -y
sudo apt-get install libxslt-dev libxml2-dev -y
sudo apt-get install curl libcurl4-openssl-dev -y
sudo apt-get install zlib1g-dev libssl-dev libexpat1-dev -y

echo Installing apache server, mysql utils, ruby, and git

sudo apt-get install apache2 apache2-threaded-dev -y
sudo apt-get install mysql-server mysql-client-core-5.5 -y
sudo apt-get install git-core gitweb -y
sudo apt-get install ruby1.9.2 -y
sudo apt-get install imagemagick -y
sudo apt-get install libmagickwand-dev -y

sudo curl -L https://get.rvm.io | bash -s stable
source /home/ubuntu/.rvm/scripts/rvm

sudo apt-get install automake -y
sudo apt-get install bison -y
rvm install 1.9.2-head

gem install passenger
sudo passenger-install-apache2-module

A couple of big items. First, you’ll notice the addition of RVM. I found it makes my life a lot easier when managing ruby installations. Second, no gems. This is because now you’ll be managing all your gems through the bundler, which will make your life a lot easier too.

If you are using git, don’t forget to set

git config --global user.name "USERNAME"
git config --global user.email "EMAIL@WEBSITE.COM"


Access YQL finance data using Jquery

March 1, 2011 6 comments

Let’s take a look at how you can access stock information(realtime and historical) without the use of server-side code.  In case you haven’t noticed, it is hard these days to find a good source of market data that will satisfy most developers’ needs (free, fast and easy).

YQL and Open Data tables

YQL (Yahoo! Query Language) is a SQL-like language that lets you query, filter, and join data across the web. Open Data tables are YQL plugins (XML) that can mapped onto any web service or source on the internet. Together, they provide developers a simple way to access data via a RESTful web api in XML or JSON format. For our example we use jQuery to retrieve our information as a JSON object.


jQueryUI’s datepicker is a life saver. HTML5’s input placeholder is a nice little enhancement as well. I commented out the resources the you will need to include in your tag.

<!-- Header References
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.js -->

<div id="inputSymbol"> 
        <p>Enter Stock</p> 
            <input id="txtSymbol" class="required" Placeholder="Symbol" />   
            <input id="startDate" class="datePick required" type="text"  Placeholder="From" />   
            <input id="endDate" class="datePick" type="text" Placeholder="To"  /> 
        <button ID="submit">Submit</button> 
<div class="realtime"> 
    <div><p>Name</p><span id="symbol"></span></div> 
    <div><p>RealtimeBid</p><span id="bidRealtime"></span></div> 
<div class="historical"> 
    <div><p>Date</p><span id="date"></span></div>
    <div><p>Price</p><span id="closeValue"></span></div> 


Used some CSS3 on the textbox for the required field indicator

*{margin:0; padding:0}  body{padding:1em; color:#555; font-family:verdana; text-align:center}

p{padding:0.5em 0; font-weight:bold} input:focus { outline:none; }

input, button{padding:0.4em 0.3em;  margin:0.5em 0em}
input{border:1px solid #999; border-left:1.05em solid #aaa;-moz-border-radius: 15px; border-radius: 15px;}

.required{ border-left:1.05em solid #E8725C;} 

#inputSymbol, .realtime, .historical{ 
    padding:0.5em 0.5em; margin:0% 20%;  
    border-bottom:1px solid #aaa
.realtime div, .historical div, .realtime div span, .historical div span{ display:inline-block }
.realtime div, .historical div{width:45%}

#date span, #closeValue span { display:block; color:#666; font-size:90%}
.ui-datepicker { font-size:11px !important} /* skrink datepicker */


After we pull our JSON object, we output our columns of interest to their appropriate HTML elements.

var yqlURL="http://query.yahooapis.com/v1/public/yql?q=";
var dataFormat="&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";

$(function() { //Load jQueryUI DatePicker by class name
    $( ".datePick" ).datepicker({dateFormat: 'yy-mm-dd'} );
$("#submit").click(function() {
    var symbol = $("#txtSymbol").val();
    var startDate=$("#startDate").val();
    var endDate=$("#endDate").val();

    var realtimeQ = yqlURL+"select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22" + symbol + "%22)%0A%09%09&"+ dataFormat;
    var historicalQ = yqlURL+"select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22"+ symbol +"%22%20and%20startDate%20%3D%20%22"+ startDate +"%22%20and%20endDate%20%3D%20%22"+ endDate +"%22"+ dataFormat;

    $(function() {
        $.getJSON(realtimeQ, function(json) {//YQL Request
            $('#symbol').text(json.query.results.quote.Name);//Assign quote.Param to span tag
    $(function() {
        $.getJSON(historicalQ, function(json) {            
            $.each(json.query.results.quote, function(i, quote) {//loop results.quote object 
                $("#date").append('<span>' + quote.Date + '</span');//create span for each record
            $.each(json.query.results.quote, function(i, quote) { //new each statement is needed
                $("#closeValue").append('<span>' + quote.Close + '</span');

Editable Demo

If anyone is familiar with any free stock market APIs out there, I would be interested in checking it out and taking it out for a test drive.

Good Luck,


Upgrading Rails, Gems, and MySQL to Snow Leopard

November 29, 2010 Leave a comment

Have been meaning to post this for a while. I have an older MBP that came with OS X version 10.4, and after upgrading to 10.6 my entire coding stack collapsed. After a couple of hours here is the solution I came up with.


First, find what processor you are running on, ie 32 or 64 bit. If you don’t know use this guide http://support.apple.com/kb/ht3696


Second, download and install the appropriate MySQL version  from http://dev.mysql.com/downloads/mysql. In my case it was 64-bit MySQL 5.1.37.


After that you’ll need to install ruby gems from scratch. You can find more details in my other post How to setup RoR+Passenger+MySql+Ubuntu Server on EC2,but here is an excerpt bash script with all you need:

echo Installing ruby gems...
cd /usr/local/src
sudo wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
sudo tar -zvxf rubygems-1.3.5.tgz
cd rubygems-1.3.5/
sudo ruby setup.rb

echo Symlinking...
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

Note: If you find that the gem command still won’t run try this

sudo ln -s /usr/bin/gem /usr/local/bin/gem


Finally, execute the following:

sudo gem update --system
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Note: make sure you set  ARCHFLAGS flag to the appropriate architecture.


Good luck and enjoy your new OS.

Installing swftools and pdf2swf on Ubuntu Linux

February 23, 2010 49 comments


I’ve been using swftools, mainly pdf2swf functionality, for a while now and installation always sucked. Google usually provides good results for common problems, but lack of a step-by-step installation guide is lacking.

Main site, http://swftools.org, has pretty good wiki for documentation and a tidy installation walkthrough. Unfortunately for me I had a ton of problems getting pdf2swf to work properly on Amazon’s AWS Ubuntu server (ami-5059be39 – ubuntu-intrepid), but fortunately for you I finally got it working and also put together this guide, which will hopefully save you some time.

Note: swftools version that comes default with aptitude would not work for me hence the need to compile from source.
Note2: this guide assumes the distro is up to date and all system libraries have been installed from Installing RoR on Ubuntu post

Get necessary libraries and extract

wget http://swftools.org/swftools-0.9.0.tar.gz
tar -zvxf swftools-0.9.0.tar.gz
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar -zvxf jpegsrc.v7.tar.gz
wget http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-2.3.12.tar.gz
tar -zvxf freetype-2.3.12.tar.gz

Note: v8 produced errors in swftools install so I grabbed v7, which worked wonderfully.

Now order of install. First we install jpeg:

cd jpegsrc.v7
sudo ./configure
sudo make
sudo make install

Freetype is a little trickier. For install you have to reset cache, set flags, run ranlib (not sure why but it wouldn’t work without for me, if you know I’d love an explanation)

cd freetype-2.3.12
rm -f config.cache
sudo ranlib /usr/local/lib/libjpeg.a
sudo ldconfig /usr/local/lib
sudo LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure
sudo make
sudo make install

If you want to be able to convert pdf files into text you have to install xpdf. Fortunately aptitude does provide us with the right libraries this time.

sudo apt-get install xpdf-reader

And now for the final step:

cd swftools-0.9.0
sudo LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure
sudo make
sudo make install

Big thanks to swftools for making this possible.


Edit (3/3/2011): Updated code formatting.

Tags: ,

Incorret user name or password when setting up GMail on iPhone/touch

November 14, 2009 8 comments

I bought an iPod Touch and was trying to hook it up to my gmail account, but kept getting “The user name or password for “imap.gmail.com” is incorrect”. I tried going through the official GMail setup but to no avail.

Triple checked to make sure IMAP support was enabled, still nothing.

Then I stumbled along a post suggesting to try unlocking captcha on my account (https://www.google.com/accounts/UnlockCaptcha). I went ahead and everything worked fine afterward. Awesome!

Cost of hosting development on Amazon EC2

November 10, 2009 2 comments

I’ve noticed there were some searches coming through with people asking how much it costs to host servers on Amazon’s EC2. Without going into detail, last month I ran 3 Linux instances (m1.small) with no EBS and minor S3 usage, which cost me about $200 a month.

Compared to my previous hosting company – hostmonster.com – Amazon is way more expensive. However, I now find that taking care of my server administration needs is much easier and (gasp!) fun.

Tags: ,