Wednesday 1 February 2012

Installing WebStorm on Ubuntu

Get Webstorm (its worth it)

then ... 

Install Java JDK 1.6+ first (see full http://superuser.com/questions/353983/how-do-i-install-the-sun-java-sdk-in-ubuntu-11-10-oneric )

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin
You may want to also add the following
sudo update-alternatives --config java
You should get the following
  Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 2
Select (2) and press enter
Now running:
java -version
Returns:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

How-to setup M-Project and Espresso with Node.js on Ubuntu

git clone https://github.com/mwaylabs/Espresso.git
cd
git submodule update --init 



alias espresso='~/Espresso/bin/espresso.js'

(check version is => 1.0.0.0)
espresso version   


(init it with some example files)


cd devroot

espresso init --project=Nodey2 --example 


(spin up the m-project via the espresso server)
cd ~/devroot/Nodey2
espresso server

..calling the cloud9 ide
~/cloud9/support/node-builds-v4/node-linux32 ~/cloud9/n/cloud9.js -w ~/devroot/Nodey2 -l 192.168.1.12 -p 3101 -a x-www-browser 

interesting sample.. useful to get the first couple of pages going

get a theme going with ThemeRoller


Friday 27 January 2012

Setting up my Node.js solution in Cloud9 IDE

Now where do we go after we have a brand new toy.. I just installed Cloud9 IDE.. see how-to install cloud9 here.

I want to setup a quick web app (really, really quick). I will time it.

00:00 - Get all my favourite (sounding) node modules from npm (presume you have npm) then use...
npm install  


See all the goodies I got.. note espresso took some time. Also look them up at http://search.npmjs.org/#/ 

00:09 - I had to install mongodb separately using (can also go here ..)

sudo apt-get install mongodb
00:18 - Created a folder at ~/devroot/MongoDb/data/db for my MongoDb instances. Now to run the db server..
mongod --port 9080 --objcheck --dbpath "devroot/MongoDb/data/db" --directoryperdb --rest
Note: --rest == RestApi, --directoryperdb == create a new dir for each new db's files
Success == MongoDb web console at http://127.0.0.1:10080/ (not so sure about the port, but trust that the mongod startup script should tell you your magic port number)



00:22 - Try out the mongodb server quickly...


mongo 
db.foo.save( some json object here );
db.foo.find()
 00:24 - setup that web app... hmm
Ok. Make sure you have done a global install of express using
sudo npm install -g express 
00:26 -  Use express to setup your solution structure inside your project root
sudo express  
cd   
npm install 
Note: this  installs default packages only so I had to get other ones here by
npm install
It uses  the cache (304) so it does not waste your time. I have now installed,
ejs, mongoose, colors.. (see list above)

Lets setup some routing .. see a good guide on expressjs here .. i am not re-inventing this.

Should be easy enough from here... good luck!


Node.js and Installing Cloud9 IDE

I am a bit infatuated with node.js at the moment and the whole real-time web thing. So trying to get it going on my machine. Why??? A.) I love javascript. B.) I love javascript. Always have. Never in secret. Been glared at for writing jQuery apps, etc. I have done all the other languages too (C#, java... respect.. they've paid my wages).

So... I have been at this for a whole day... phew! Tried on windows (gave up!) and now on Ubuntu. Need to go back to the mac (yes, I admit, the war is now over). I am lazy, I like simple kits, but I like a working IDE, debugger, etc. So I hunted around and found a few...

  • WebStorm (from JetBrains and they still make that super ReSharper VS-addin)
  • Cloud9 IDE - a nodejs based web IDE - how cool.. and open-source so you can run it on your box
WebStorm was simple enough install, could find all the modules but I could not get the debugger going. Anyone good with this, please ping me at kenn9j.at.gmail.com :) 

Cloud9 IDE was not simple to get installed. Too many rig-ma-roles... but it kicked in.. and here is how...
  • Go to http://gratdevel.blogspot.com/2011/03/setting-up-cloud9-on-ubuntu-1010-32-bit.html it says most of it.. (forget windows for now)
  • If you are running a 32-bit Ubuntu on 64-bit windows vmware like me.. all will not go well. So at some point you will get... "error while loading shared libraries: libssl.so.0.9.8: cannot open shared object file: No such file or directory" 
  • Fix it with - sudo apt-get install libssl0.9.8 
  • Start cloud9.. point to your project folder and it starts up in the ide.. in your default browser... :) smile... 
path-to-node-v4-build path-to-cloud9.js -w path-to-your-project -a x-www-browser 
~/cloud9/support/node-builds-v4/node-linux32 ~/cloud9/bin/cloud9.js -w ~/devroot/Nodey -a x-www-browser 

  • Add a little app.js file with a server in there like see above. Hit run (will have to configure first time so point to your app.js) 
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3001, "0.0.0.0");
  • Enjoy! It's a bit slow on my vm but it can debug. (can always two-time with geany)