Two absolutely necessary Node packages, within a week of Nodding

As my learning continues with NodeJS, it is now becoming obvious to me that probably I could never live without Node in future from now on, even if I do not continue developing on NodeJS. In just about a week there are the below two packages which became absolutely necessary for me in day to day work, while doing front-end web work or just playing around with javascript in general.
serve
nodemon
These two enable any folder to act as a web server. Once installed from “npm” one can directly fire up these commands and see the folder as a website through a browser.
If you want to run the webserver at port “1234″, just navigate to the folder you want to serve as a website and fire up the command below.

serve -p 1234

If you do not care about the port, just

serve

will do the job, where the site will be served at a default port “3000″.
Now to access the website go to “http://localhost:3000/” in your favorite browser.
If you change a file, you have to manually restart the server.
Now “nodemon” helps us in automatically restarting the server on any file change. If one is working on any web application and does continuous changes to the files, one just have to refresh the webpage (No need to restart the server over and again for updates). That gives continuous focus on development.
Happy Nodding :)

On my search for a JS variant, triggered by NodeJS study

Well while going ahead with my NodeJS study and after looking at the functionality that NodeJS provides, I got a little curious to search for something which might help me develop in JS a little more easily. To my surprise, I found a lot of languages which does that, but I picked 3 as it seemed these are got some history to themselves and backed by big corporate or have a huge community to support.
1. CoffeeScript
2. TypeScript
3. Dart
All these three compile to javascript. While CoffeeScript and TypeScript are nodeJS dependent and installed by “npm”, Dart comes with its own installation and IDE. Personally I liked the first two, at first glance as they are installed with “npm”. But then Dart comes with its own IDE, which is an advantage.
Now a little bit about the face value of the three.
CoffeeScript : A huge community and has proven history of a good player.
TypeScript : Its a microsoft initiative.
Dart : Its a Google initiative.

Looking at all these, I still feel HAXE is the best for JS dev too, may be thats my biased opinion.

Modules in NodeJS

There is this concept of Modules in NodeJS, which is kind of but not exactly the same as Class concept of programming languages like Java and ActionScript. To add a module the syntax is

 
require() // its like import in Java and Actionscript

A detailed implementation of “require()” statement is as below

 
var myModule = require('./myModule.js');

So that’s all to include a module, if the module JS file and your application JS file are in the same folder, for the time being lets do the understanding this way. :)
Now lets see what kind of features or flexibility “modules” gives us as a nodeJS developer.
If we think of modules as the Classes then it will be easier for us to understand.
First of all, everything inside a module is private. Ohh yes, private things in javascript. Thats interesting, is not it!
Lets write a simple class kind of thing in a module, which has a private property and getter-setter method of the same.

stupidVar='Global Scope. Avoid this.';// Never put anything in Global Scope
var nameOfModule='I am private';
exports.getName=function(){
	return nameOfModule;
}
exports.setName=function(newName){
	nameOfModule=newName;
}

Couple of things to note here. First of all every variable that is not declared with “var” is on the Global scope. I think thats true in general for javascript. Apart from this anything else in a module is private, that means the variable “nameOfModule” in our example is only accessible from inside that module itself. If we try to access it from out side the module NodeJS will throw an error. Now to expose methods and properties to outside world, we have to add the methods and properties to an object named “exports”.
Now to consume the module, lets write a “main” class which we can assume as the application entry.

console.log("Hello Modules.");
var modOne=require ('./modOne.js');
console.log(modOne.getName());
modOne.setName("I am set by the setter. Setter is Public.");
console.log(modOne.getName());
//console.log(nameOfModule);// this will throw an ERROR as we are trying to access private var
console.log(stupidVar);

Save both the files in the same directory. Open the commandline and navigate to the directory. To run our application we have to write

node main

Just a note that we do not have to specify “.js” after the “main”, while feeding the file to NodeJS.

The source files for this are here to download.
[reference : net.tutsplus.com ]
Now there are publicly available packages, libraries and modules in our case. To install a module in a nodeJS application, one has to navigate to the folder containing the application through commandline and install the required module. An implementation detail is as below.

npm install module_name

I hope you remember “npm” from previous tutorial. For a quick reminder, “npm” and “node” both the tools are installed by default when we have installed nodeJS. The “npm” is the package manager for nodeJS.

Happy Nodding :)

How I started with NodeJS

To be clear with the following contents, let me tell you that the whole experiment or learning was done in a Windows environment, but then I found that MAC is easier to start with NodeJS.
Installation is straightforward. Just download the binary and get going.
Once installation is done, node and npm command should be available from command-line, if not try restarting and then test the commands. Testing the commands means typing “node” or “npm” in the command line and pressing ENTER. If installed, the result should be something other than “missing command or error message”.

The next commands I went through are

 npm root
npm bin 

why ? To see the details of below explained stuff

npm root // to see where modules go
npm bin // to see where executables go

[ ref : https://npmjs.org/doc/faq.html ]

Next I tried with “-g” switch as below.

 npm root -g
npm bin -g

Why ? Thats because node installs differently for global and local specifications.
[ ref : https://npmjs.org/doc/faq.html
If you install something with the -g flag, then its executables go in npm bin -g and its modules go in npm root -g ]

Next is my favorite first timer stuff, to list all the installed packages,

npm ls

Next to know a little bit about Node itself

 npm view npm author
npm view npm contributors

So thats the start.
Next is the node official doc. [ ref : http://nodeguide.com/beginner.html ]

Hello 2013

Happy new year and its already started. As you can see the post is a little late, for the year is started for me, in a busy mode, which is always a positive sign.

Time for a retrospect of the last year. The year 2012 was a very happening year for me after my college days.
1. I got into a startup in Jan 2012 ( pixykids and now renamed to Kazaana )
2. Met a friend and her family from Swizerland ( Stephanie Booth http://climbtothestars.org/ )
3. Attended first Tweet-meetup for Pune in Pune
4. Took interviews for senior flex developer from all around India for the start-up I joined
5. A lot of learning and research and development happened for multi-user application development. Finally demoed and implemented Union Platform for the product I was working on the start-up.
6. Got Married.
7. Looking the product I was working on being released in staging server, alpha version and public beta.
8. And finally towards the end of the year, I lost my mom, may her soul rest in peace.

So the eventful year of highs and lows came to an end and given a chance to look at things in new perspective.

RayTrace V4.1.0 is now released

Well, its a long time since anything happening here. The good news is finally the long awaited feature of the smallest logger ie; RayTrace is available as of today. This is the vertical scrollbar for the logs.
I must say its more than just a requirement for this logger. Though we could scroll through the logs with mouse wheel or by selecting text from the logger, but then we do needed the scroller. The scroller is still is still way far from perfect, but at least the feature is active and is there for scrolling through all the data from initial to final.
The source code is up in github as well and the workable or binary files are here for you to download and use.
Thank you so much the patience and have a nice time logging.
Happy coding.

Java for iOS and Android

It seems that its a long wait for the Java developers. But the good news is the wait is over. finally we have an SDK which expects us to write in Java and deploy our application into iOS and Android.
Codename One is an opensource SDK, library, deployment system, all in all a platform to develop for mobile platforms.
The short story is I tried to put a simple helloworld application to put in my android phone and it took only 30 minutes to make my development environment ready to deploy to the phone.
Well, the whole of the SDK is just a plugin to Eclipse or Netbeans, depends upon your preferred IDE of choice. Thats all to it. What a developer gets, is a GUI builder, a simulator, the SDK and the complete framework. Now go straight into the IDE and start building the application you want to do with the Java skills. Finally decide where you want to put it, iOS or Android, select the option and push it to the cloud, so that Codename One cloud will make the build for you to deploy into the device. Thats a no brainer deployment and code migration.
What all that means is, one is very well ready to develop iOS applications in windows machine. A very nice and well thought of SDK and framework.

Happy Coding.

RayTrace v4.0.0 is released

Well, this release is mostly an UI update. There is a major functionality update of this new release is the “Advanced” settings. If you are using the default mode, it will work as it was working previously.
With advanced mode, one need to change two things. One is the “raytrace.as” which comes budled with this application. Inside this file one has to put the connection name. This name could be any string, it could be your project name, version name or your name, but then remember this name so as to put the same name in advanced setting text input (thats the second setting). After that its as usual process.
The release version can be found here for direct download and use. The source code is up in github.

Happy Haxe -ing

An IDE for HAXE and NME for every OS

The long wait is over! The search for a perfect IDE for Haxe and NME is finally over. Thanks to the hard work of Joshua Granick. He is still in development of this feature, but for me I found it perfectly alright to use it in my Mac OSX.
So the IDE is Mono Develop and making it a Haxe and NME IDE is just enabling the addin for it. Presently its a manual process but thats ok I think. The Addin is on the github.
Everything is just straight forward. Just a little thing on command line is to create a .hxml file in OSX. I am not sure if thats the case in other OSs. Navigate to your newly created project folder from Terminal and fire up the command below (where {projectName} should be replaced with your own project name)

haxelib run nme display {projectName}.nmml mac>{projectName}.hxml

Thats all to it. Just open up MonoDevelop and enjoy code hilight, code hinting and compilation from inside the IDE.

Happy haXe -ing

RayTrace v3.0.0

A new release of RayTrace, the simplest flash logger. Its made with haXe and compiled with NME for SWF output.

The feature list is as below
1. Stop and start button (To start the logger and stop the logger)
2. A sightly improved GUI (some colors at last)

With that here is the link to the compiled code (SWF and the lib for directly use in your project) and here is the github source code.

Happy haXe -ing