Friday, December 07, 2012

Vagrant , chef and Node

This is a note to myself, mostly to make sure I will not forget what I learned during set-up of the dev environment for NodeJs development. If you find it useful feel free to drop a comment on the post.

Steps followed:

1. installed vagrant and virtualbox using the osx package manager
2. Execute 'vagrant init' using terminal
3. This will create a sample 'Vagrantfile' config file
(as i didnt have the base VM downloaded yet, i had to download it )
4.vagrant box add ubuntu_lucid64 http://files.vagrantup.com/lucid64.box
5. Add the following line to Vagrantfile
config.vm.box = "ubuntu_lucid64"
6. Enable port forwarding to access the VM through the local IP address. (where 1337 is the port in the VM and 5001 is the port of the host machine)
config.vm.forward_port 1337, 5001
7. Create a folder named 'cookbooks' within the project folder
8. Download the nodejs recipe from chef community and put it to cookbooks folder
9. Add the following lines to the vagrantfile
config.vm.provision :chef_solo do |chef|
 chef.cookbooks_path = "cookbooks"
 chef.add_recipe("nodejs")
end
10. Execute 'vagrant up'
11. Execute 'vagrant ssh'
12. When you try to install node modules using npm within the VM you will always get error msgs saying "symlinks failure" (this is because virtualbox VMs cannot create symlinks with its default settings). so include the following line on the vagrantfile in order to change the default settings.
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
13. Execute 'vagrant reload'
14. Write an node server which listens to 0.0.0.0:1337
var http = require('http');
var url = require('url');
http.createServer(function(req,res){
}).listen(1337,'0.0.0.0');

15. Test the connection by visiting localhost:5001 from your host machine browser.
16. Done!!

Points to remember when writing the node scripts:

1. If you are writing a server listening to a port using NodeJs make sure its listening to the IP address '0.0.0.0:1337' (otherwise you will not be able to access the site using hostmachineip:5001)

Todo:

1. Write a custom receipe for installing required packages using npm within the VM
2. find out how to install node using a binary saved in the local machine than rebuilding from the source - already completed. http://rarepraveen.blogspot.com/2012/12/vagrant-chef-and-node-part-2.html
3. write a separate blog post on how I used 'node dbox' (node library for dropbox APIs) to write a sample application

Okay that's it for the moment. If you know any tips that could help another dev's life easier feel free to share them as comments.

Sunday, February 06, 2011

importing PHP projects to a fresh aptana 2.0

after long usage of notepad++ and vim for all my development needs, i wanted to try out a proper opensource IDE to see whether it could really improve my efficiency in development.

as i have worked with eclipse and netbeans before in various projects i thought i will give a try on aptana studio this time. after all it was build on eclipse eco system where you can choose to install 1000s of eclipse plugins available out there.

so i downloaded a fresh copy of aptana and installed it. the installation process was really fast. and once installed when i was trying to create a default web project i realized they don't support php by default. thats a little bit weird provided that php is one of the most widely used languages on the web development. so for their aptana studio 3 i wish they will be able to support few more different types of projects by default rather than getting the user to install them manually.

installing PDT on aptana was really a joke (seriously). both PDT 1 and 2 failed miserably on aptana studio 2. well i a little bit of googling linked me to this great article where barmus explained how to install the aptana 1.5 PHP module into aptana studio 2.

[Thanks for the great article bram, it really was a life saver]

once installed it wasnt much hard to import my previous projects into aptana, all i had to do was to follow the steps mentioned below to get it up and running like a charm.
1. goto file -> import
2. choose other -> existing folder as a new project
3. once created right click on the project and click "properties"
4. on the dialog goto "project natures" and select "PHP nature" and press ok.
5. let aptana re-open the project automatically to apply the settings

and now you have your project opened in aptana as a PHP project.

I'm going to continue to play with aptana and see what it has in it for me when it comes to my lame development habbits.

feel free to let me know if there any more sweet plugins that i should look into, or if there were any other way you guys managed to get aptana to run PHP projects.

Tuesday, May 11, 2010

easy product management with quickPad


"sometimes learning abt new technologies and frameworks seems to be a quiet frustrating task, but at the end it always give good results."

that is what i exactly feel abt learning "ExtJs" (the javascript framework). it was not an easy task but finishing a Demo project for online product management totally using extJs but it was a good experience for me.

it hardly took a one and half weeks to complete this demo project which has category management, editable product grid, product search and dynamic PDF generation.

i'll attach some sample screens so then anyone can have a rough idea about the project.

2. text box in the editable grid

3. drop down in the editable grid

4. preview window for image references

5. the product preview window

6. add category window

7. the multi selection preview mode with quick tooltips

8. dynamically generated PDF

this project is currently online http://www.quikpad.net.
 

Friday, April 23, 2010

some good change in directions of my career

Well i guess its high time for me to use my knowledge on client-end programming on real life projects.

It was just as sweet as wine to take a little break from backend development to break some rules in front-end. ;)

lets get ajaxified more and more. I will try to post as much i can during the months to come.

till then adios.

Wednesday, February 17, 2010

word cloud on my cv

just tryed wordle on my cv. it looks good.


Wordle: my cv

Tuesday, December 15, 2009

Rating system for ZendFramework with Jquery

This ain't going to be mind blowing article, because its one of the very first blog post of mine which will explain how i got some task done. as this is the very beginning i wanted to select a small task to cover up in a blog post.

well i had to write a nice rating module for a small CMS which was written in Zend Framework.

so first i had to find a nice JavaScript rating code and then to write the PHP back-end to make it functioning.

so the only thing which got my eye was a jquery plugin which looked nice and it had lot of customization options as well.

and then it was the time for me to change this into a Zend Framework view helper. so here are the steps i took.

1. The view helper class

The view helper class will be needed so you will be able to call the rate module to render the rating control from any place of your site. this file should reside in folder Library/View/Helper.

2. The template(phtml) file

This file will be one which will hold all the HTML/CSS/SCRIPT needed to render the rating controller. having it one centralized template file makes it very easy for us to make any changes in the way it renders without having to edit multiple place. this file should reside in the folder application/views/scripts.

3. The Model (to interact with the database table)

this file will have all the functions to ADD/REMOVE/GET ratings entered by users. this file can be used to introduce new rules, or different storage mediums later on. the initial view helper file we discussed about will always be talking directly to this model to grab necessary information which it needs to render the rating tool.

4. The controller file (main access point for data submissions)

This file will be used to capture the event of user ratings. so once the user clicks on the rating control the AJAX request will be directed to this controller's add action. and from there it will communicate it with the model to get it saved in the database. this file shud be placed on /application/controllers/ folder.

i will have to find some other way to post code samples into the blog post straight away, but for the time being i cant figure out a way to add the PHP/XHTML code into this blog post. i will re edit this post once i figure out a solution for that.

happy coding!!!

[update Jul2014]
all the source code for this article can be downloaded from here.
Looks like the website that hosted the sample source code is not in use anymore. I will try to find the original source code and post it here.

Friday, October 30, 2009

all tamils arent tigers

i happned to come across this article from the christian sience moniter about human rights in sri lanka. it made me realize how powerful media is to make one race go so angry against another race of people who shares the same mother land.

i'm not defending anyone here, coz we all have to agree that nothing is perfect in this world. but all my fellow journalists and writers please do not use the word tamil rebels to represent LTTE. terrorists are terrorists regardless of their race and culture. insult LTTE for the innocent lives they have taken, but not the tamil race as a whole.