Friday, September 27, 2013

Enchanting cloud with juju !

Automating infrastructure is not a new thing, but doing so with the ease of setting up paas is still in its infancy. As an interesting solution to this, Cannonical has recently come out with a PAAS tool Juju that can easily setup, configure, provision, include and change master/slaves, provide continuous integration environment among other things. This tool has not come out from wild, but is currently in use: Juju and MaaS are the default deployers for Openstack. So all large Openstack deployments that are currently happening on Ubuntu use Juju and MaaS. Additionally Ubuntu One and other Ubuntu cloud services are all running on top of Juju.
Juju might sound similar to Puppet or Chef, but rather than just providing a server, this provides various services. Internal to each juju are different charms that call various programs and provide the infrastructure to the juju. The charms App Store contains charms on various services which can be used in the juju to solve  a particular task. There are currently hundreds of different charms available - from databases to php/ruby/python servers to nosql and hadoop instances and a growing community of developers who customize and release their own customized charms.
One feature that is worth mentioning is the ability to create a traditional Paas such as CloudFoundary as a charm to run over juju.
For instance, here's the procedure to boot off a rails sever:
juju deploy rails myapp --config sample-app.yml
(This yml file contains the url to the github repository containing the charm)
juju deploy haproxy
juju add-relation haproxy myapp
Now the database can be created:
juju deploy postgresql
juju add-relation postgresql:db myapp
then migrate the database
juju ssh myapp/0 run rake db:migrate
Finally expose the proxy
juju expose haproxy
and view the status, which should provide you with the public url
juju status haproxy
The coolest feature now is to add/remove servers horizontally through gui or through command as:
juju add-unit myapp 
juju remove-unit myapp
Currently, there is also a charm-championship taking place  that encourages developers to take part in developing customized charms for various themes.
So what are you waiting for?
Jump right in at to see it in action.

Monday, September 9, 2013

On book writing

For the past month and a half, I've been involved in writing a short technical book that introduces automated acceptance test driven development through an open-source tool, Robot Framework. Now that the drafts have been sent to the publisher, I can introspect on how things happened. Book writing has been challenging and rewarding at the same time. It often happened that I completed my draft revisions way past 1 am and arrived red-eyed in the office the next day. Like a blog post, I built up the contents of the book line by line, then like a blog post, different topics that went into the construction of different chapters.
As it was my first book, I managed to finish the drafts in time due to a constant urging in back of my head to finish the chapter X by the end of this week. I kept doing that when I had my holidays, or after arriving from work in the evening. Even when I visited relatives or did my gardening on the weekends, I managed to have this constant reminder which allowed me to keep up my pace with the delivery schedule. I'd also like to thank many other accomplished authors out there who encouraged amateurs like me to go about with the writing business and will definitely encourage and help anyone who stumbles here with his/her writing plans as it is as satisfying as drinking a fresh coconut water when extremely thirsty on a hot summer day.

Tuesday, September 3, 2013

Introduction to LiveScript and its comparison with Coffesript

LiveScript is an indirect descendant of CoffeeScript with features to assist functional programming like pattern matching and function composition. In a manner similar to coffeescript, it too compiles to javascript and can be used to write expressive code with as little boilerplate code as possible.
Like coffeescript, it runs on node.js and can be installed using sudo npm install -g LiveScript command.
Here are some of the amazing features 

  • jQuery parenthesis are no longer required: $ \.content .find \.date-author .text!split ' ' .0
  • Partially apply operators to entire list:eg; this multiplies all list variables by 2.  map (* 2), [1 to 5] 
  • Usage of pipes to make the nested functions seem a lot less messy: [1 2 3] |> map (* 2) |> filter (> 3) |> fold1 (+)
  • Easily find the minimum/maximum from a list minimum [12 13 3 -16 101 56 0 23]
  • Partition a list into two lists neatly; [passed, failed] = partition (> 33), [30, 45, 35, 12, 50, 32, 66] will yield: passed = [45, 35, 50, 66] and failed = [30, 12, 32]

The site also offers a small Coffeescript to Livescript guide:

  • All => to ~>
  • All block comments ### to java styled comments /*  */
  • All undefined to void
  • Any range syntax [a..b] to this expressive syntax; [a to b]. similarly for [f...g], do [f til g]
  • In a similar manner, range syntax is changed from 'for x in [4..12]' to 'for x from 4 to 12'
  • The regular expression literals are also changed from /// to //
  • Functions having empty arguments can remove their parentheses
  • Constructor functions are also changed as the explicit constructor keyword becomes optional and is defined as a top level keyword.
  • Any calls to parent classes is done via super ... as super is a direct reference to the parent function itself.
  • For multi-line strings, the indentation after a line is treated only as a single space.
  • Special casing function literals here use a 'let' instead of a 'do' eg; do($ = jQuery) -> $
  • Javascript code literals only need a single 'quote' around them.
  • For property access, do not leave space around both sides of the dot. eg; z.x (here it is use to compose functions
Hope that these pointers might motivate someone to jump start into livescript.