Blogroll, General

Busy Busy Busy

It has been two months since I touched my blog, I apologize for that its been really busy. First there was the trip to India which was really nice, it seems like every time I go to India the traffic on the streets have increased. With the exponential increase in the number of banks that want to give loans the number of cars have increased but the streets have not kept pace with it.

During my vacation I discovered Vince Flynn, he is a real good writer can’t put down the books once you start reading. He also has a website that you can go to. So far he has written nine books of which I have read six and plan to read the rest. His books are all about the CIA and CIA super agent “Mitch Rapp”, they are real page turners.

Also upgraded my Ubuntu install to the latest version (7.10) it felt sluggish at first but after turning off beagle it seems to be doing much better. Really impressed with tracker search and with the new Broadcom drivers my wireless card seems have better signal strength. I had to turn off all the desktop effects cause it still gives me problems with some applications like SqlDeveloper (the window does not seem to refresh), but overall. the upgrade went very smooth which was a pleasant and welcome surprise.

Also started reading “Programming Erlang“, a very interesting programming language. I strongly believe in “using the right tool for the job” which in my world translates to “using the right programming language for the project”. It does not matter if it is a small or a big project using the right tool makes all the difference, which is why I try to keep learning new languages.

So as you can see I have been real busy but now that things are settling down I hope to be more regular in updating my blog.

General

Dynamically updating JBoss Rules with Spring

JBoss Rules or formally know as Drools is a popular open source Rules Engine, it is “augmented implementation of Charles Forgy’s Rete algorithm tailored for the Java language.” I have used it for the past 2 years in various projects and have come to like it below is a list of things I like about Drools

  1. It is open source, which will help you overcome a major obstacle when trying to introduce into a project.
  2. It is light, by that I mean you do not need a dedicated server to just host a rules engine or learn a new tool, it just another Jar file you add to your existing project.
  3. Plays well with Spring, now this is a winning combination for me cause I love the Spring Framework (Spring just makes life easy).

I am not going to go in dept about using Drools with Spring you can read my other post about it, what I want to talk about today is how you would dynamically update Rules, here is my setup.

A Rules POJO

 

RulesService
{
	/** returns an instance of the Rules Base */
	getRulesBase(); 

	/** initializes an instance of a Rules Base object by reading files from a specific directory */
	init(); 

}

Make sure the RulesService is a singleton which it should be by default when you are using Spring, your spring config should look something like this.

 

	<bean id="rulesService" class="edu.apollogrp.qtask.RulesService" init-method="init">
		<!-- where to the files are stored -->
		<property name="drlResourcePath" value="RulesDirectory"/>
	</bean>

This will make sure that as soon as your context starts, the RulesService POJO will start up and initialize a Rules Base Object by reading files (usually DRL or Decision Tables) from some specified directory (we will call this RulesDirectory) on the hard disk. RulesBase is a thread safe object so no worries there.

Calling Services

All services that need to execute rules should be injected with the RulesService POJO and use the RulesService to get the instance of the RulesBase and then create a working memory using it

 

INeedRules{
	RulesService rulesService;

	someMethod()
	{
		final WorkingMemory workingMemory = rulesService.getRulesBase().newWorkingMemory();
		workingMemory.assertObject(someObject);
	}

	setRulesService(RulesService rulesService)
	{
		this.rulesService = rulesService
	}
}

Refresh

Create an Action class and inject it with the RulesService, this Action class when executed should call the RulesService.init() method, make sure this action is only allowed to some super user.

That it! now anytime you can deploy new rule files into the RulesDirectory and call the refresh action and it will immediately take effect.

General

Minor Update

It’s been slightly more than 2 weeks since I installed Ubuntu and I am happy to report that everything is well, Eclipse and all other programs feel more snappy, multiple desktops make life so much easier and a general overall increase in productivity. I also got Oracle instant client installed and working with Rails. Here are some links that will help you if you want to do the same.

  1. http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html
  2. http://wiki.rubyonrails.com/rails/pages/HowtoConnectToOracle

Unfortunately you have no other choice but to set up the LD_LIBRARY_PATH for oracle to work, but on the bright side you can reduce the number of entries you put into it by making symlinks to the oracle dynamic libraries in /usr/lib directory. Also found out that the case matters when you set up the TNS_ADMIN variable (lower case will not work, weird!)

That said, the only reason why I ever go to my windows partition is to use iTunes, I wonder why Apple has not released iTunes for Linux ? I also wish Google talk was available for Linux, Gaim is pretty good but I miss how talk would remember the conversation history.

General

Installing Ubuntu and VPN

I finally got Ubuntu working on my laptop, YAY. Took me about a day and a little help from my friend Tim. The first problem I had was the install kept blowing away my MBR, using Partition Recovery I was able to recover it, for some reason the install had problems with setting up GRUB, so Tim had the idea to manually install GRUB and then try installing Ubuntu and it went through fine.

The next problem was getting wireless to work, Broadcom wireless network card has problems with Ubuntu after some goggling on “ubuntu dell wireless” found the solution, apparently there are no Linux drivers for broadcom so you have to use ndiswrapper there are many excellent pages that describe how to do this.

So now after setting up Ubuntu and getting the wireless to work the next hurdle was connecting to VPN, Juniper was designed to work with Red Hat but there is a workaround to get this done read here.

And finally the top 10 apps to install on Ubuntu from lifehacker.com.

VPN using Ubuntu

General

Cargo Cult

The first time I heard about Cargo Cult was at the Rails Conf, if you have never heard of it, please read this article on wiki.

Cargo Cult in a nutshell, during World War II the US established a military installation on some remote island and the tribals that lived on that island noticed cargo planes land and drop tons of cargo that had food and other articles. Now after the war the base was closed and the planes stopped. The tribals assumed that planes were from God and in order to receive gifts (cargo) that had to please God the same way the soldiers did. So they tried to imitate the soldiers they made control towers and headphones out of wood and even a runway.

When I first heard it I was amused, but now that I think about it, what if we are all doing the same thing ? Our practices and religions maybe our ancestors, like the tribals in the cargo cult started imitating these practices and we have been just following it.

Are we like the cargo cult tribals just been imitating all this while ?

General

Random Thoughts

  • How will the iPod look in 10 years ?
  • I want a laptop that looks and feels like a regular book, just open it and start reading/writing.
  • What separates Wii from Playstation3 and Xbox 360 “innovation”.
  • Humanity is hungry for innovation, give it to them and you will be rewarded.
  • I feel one of my co-workers is going to go postal one day, checked around with others, they feel the same way too, I should probably get life insurance.
General

Four Stages in a Programmer’s Job

In any job one goes through four stages, The Anxious Stage, Excitement, SSDD (Same Shit Different Day) and finally The Bail Out.

Job Stages

Stage One ‘The Anxious Stage’, you have just started off in a new job and not too sure if you did the right thing. You are surrounded by new and strange people, a ton of new abbreviations that make no sense and of course there is no documentation. You miss the familiarity of the old job and your old colleagues. This usually last about 2-3 weeks.

Stage Two ‘The Excitement’, by now you have well settled into your new place and have all the logins and access to all the systems. You have already started facing challenges and providing great solutions, you wake up everyday looking forward to go to work, you think off great ideas in your shower to impress colleagues and bosses, everything makes sense, you are completely connected into the matrix. You are spitting out code in your sleep and fixing bugs faster than you can say Katmandu. 24 hours are barely enough in a day. Simply put, Life could not get any better.

Stage Three ‘Same Shit Different Day’ also know as SSDD or S2D2, well you have proved yourself yet again and now you are getting more work than you can handle, manager is in lala land, some members of your team are pulling there weight, estimates are a joke that you quietly accept cause there is no point arguing and deadlines come and go, you know there are a ton of places in the code that needs to be fixed but you have no time to fix it. You are just trying to keep your head above water. Every Sunday night you are depressed and think ‘I have to go back to school tomorrow, wait! did I just say school ? ‘. This is a dangerous stage, cause it leads to the next stage, this is the stage where the idea of ‘greener pastures‘ comes into the mind and as many books have suggested once that idea comes in, everything else just affirms it, a smart boss will immediately recognize this stage and try and ratify it before it is too late.

Stage Four ‘The Bail Out’, months have passed by in stage three and now you know there is no hope, it is time to brush the dust off that old resume and get in touch with your old contacts. One can easily recognize people in this stage, they will never go anywhere without there Cell phones and jump every time it rings. They run out off the room with the cell phone or you hear phases like can I call you back in a few minutes. And thus the cycle begins.

So this brings us to this Question : Which stage are you in ?

General

devender.com

I really wish I could get the domain devender.com, but alas it has already been taken. Try going to the site, it is clearly a parked domain I have tried buying the domain using godaddy’s domain buying service and sending emails to the contact listed on the page but nothing has worked. I have to wonder about the reasoning behind buying a domain and just not doing anything with it.

General

Rails Conferance 2007 Day 3 (Final Day)

Rails Conf 2007 Today started with “The Rails Way” keynote given by Jamis Buck, Michael Koziarski of the TheRailsWay site, on this site you can submit your code for review and they may do a write up about it, by the way both the speakers are part of the “Rails Core Team”. One of the important suggestions they gave was to keep your code simple and try not to complicate things.

The next talk I attended was on “JRuby on Rails” by Charles Nutter & Thomas Enebo , they showed how JRuby has come a long way and can now run (almost) any rails app, you can install any gem or plugin and as long as it is not doing anything natively in C and everything is written in Ruby it will work just fine on JRuby. They also showed how JRuby will consistently provide better performance over native Ruby and this is due to the fact that JRuby is running inside the JVM which is highly optimized. They showed some numbers where except for the startup time JRuby outperformed native Ruby and as of jdk-1.6 there has been a lot of work done on the JVM’s startup time and this problem should improve. They also mentioned how the Java vm makes full use of os threads and thus eliminating problems with native Ruby’s green threading model and another interesting note which I did not understand completely, is that you can now, using a plugin create a war of your rails app and deploy it into any servlet container and since rails is not thread safe it will create different rails threads and each thread will process one request and thus provide a work around for Rails threading limitation (not completely sure about this need to investigate). You can also use JDBC drivers with JRuby on rails and even use JNDI datasources which I thought was pretty cool. Link to JRuby wiki.

How to Contribute to the Ruby on Rails Open Source” by Josh Susser , although this talk was geared towards contributing to Rails code most of the suggestions can be used with almost any open source project. This talk was about how you can contribute and if you do decide to do it, how to go about doing it. One of the best places to start is by looking at the Rails Trac (bug tracking system) and see if there are any open bugs. If you do decide to fix some bug, first write a test case that shows that there is one and submit that and then you can submit your fix. If you want to add a new feature and if it is something major first try to discuss this and when you get enough traction then open a ticket for it. Your patch should be attached to the ticket.An area which is in constant need for attention is Test Coverage and you could start off with writing some tests that would be great. There are 900 patchs that have been submitted to Rails Code and non off them have been processed so far,the speaker suggest that the Rails Team is actively working to fix this issue and to those who want to Fork, he suggested to Fork…..

Solr on Rails” by Erik Hatcher, Solr is actually Java code that is written on top of Lucene (a high-performance, full-featured text search engine library written entirely in Java). Once your bring up Solr, it provides many ways you can communicate with it, including REST style API, you can directly connect to it using http or use the SolRuby lib which not only can communicate with a Solr api but also provide back Ruby objects for direct consumption, and there is also the acts_as_solr rails plugin that adds full text search capabilities using Solr to any Rails model.

Finally Keynote by Dave Thomas, his talk was very interesting he talked about how we are constantly going in a circle, rich client-web-rich client and we need to break out off it, he talked about how the most advanced and complex programs today are video games that people play with just two thumbs so why is it that we are still using forms to fill out data on the internet ? On an another note he suggested that the Rails community needs to welcome woman programmers and play nice with newbies. And last but not the least just have fun, try other programming languages and think out of the box.

By the way according to the last numbers Rails Conference raised 26,000 $ towards charity, YEAH!!

If you are looking for slides and other info for the Rails Conf 2007 here is the wiki link, and here is a link to in depth review/notes of DHH keynote, I hope like last year they will put a video of the keynotes.

Interesting Quotes

“If you’re fortunate enough to use a real editor…” – from the Rails Way talk referring to TextMate

General

Rails Conferance 2007 Day 2

Rails Conf 2007 So today started off with keynotes from the sponsors, first one was from ThoughtWorks Studios and the second from Sun (Sun sponsoring a RailsConf who would have thought), anyway ThoughtWorks Studios now has a bunch of Ruby related products, like now they have a CruiseControl.rb (don’t you think it should be cruise_control.rb instead? 🙂 ) and RubyWorks.

The keynote from ThoughtWorks was delivered by Cyndi Mitchell she talked about how “enterprise software” used to mean something innovative but now has come to mean bloatware. She said we as Ruby and Rails developers should “Reclaim the Enterprise” before it is taken over by bloatware and ThoughtWorks can help with its production stack of application and environment tools, Developer tools, Frameworks, libraries and of course consulting. She mentioned that they are now working with Vonage to improve there software.

The keynote from Sun was delivered by Tim Bray , he explained why Sun is interested in Ruby on Rails, Sun is in the business of selling hardware and every production Rails app will need to run on some hardware that is where Sun comes in. He also talked about how Ruby has to catch up in a lot of places, like speed he said “There is no reason why ruby can’t be faster than Java”, in reference to a slide shown on the previous night by Avi Bryant where Java is at least 10 time faster than Ruby. He also talked about tools and IDE support and that is where NetBeans comes in, NetBeans now has support for Ruby including context sensitive help. He talked a lot about how to remove friction to adoption of Ruby by big companies by providing free tools, including Virtualization and companies can freely test there apps before going to production, he also said how Ruby and Rails libraries need more documentation (huh ?), anyway on the whole he was a good speaker.

There was something interesting he asked for a show of hands to see where people are coming from

  1. Coming from Java background (had the largest number of people)
  2. PHP, slightly less than Java
  3. Microsoft Eco System (even less than PHP)

First session I went to was “Exploring Virtual Clusters for Rails Development and Deployment” given by Bradley Taylor, this talk was hilarious (not for its content) first the speaker was running on windows, next it kept popping up since it installed something wanted to reboot he had to keep clicking later every five minutes, then it popped up to say that there are unused icons on the desktop, and then it popped up about the power in the battery being low (though it was connected), anyhow it was hard to stay serious with all this going on and people shouting “get a mac” in the middle of the session. Now on to the meat, I was really hoping to learn about his plugin to do virtualization but instead it was a talk to describe what Virtual Servers mean and how people could use it to optimize the use of there resources, what VMware is and so on.

Memcaching Rails” given by Chris Wanstrat, now this was a fast paced talk with a lot of tips about Memcaching. The speaker talked a about a plugin called “memcache-foo” which extends Rails and will make memcaching easier. A tip he mentioned, if you are using memcached try to use the direct ip address of the servers, just in case the DNS goes down and even if it does not take time, the memcache ruby client will take time to decode the dns. Another tip put your memcache logic where ever the code for the actual retrieval of data is it makes it easy to follow the code. The plugin also has the ability to version, so if you release a new version of your class it can automatically expire all the keys for that class only without having to reboot the entire cache.

Xen and the Art of Rails Deployment” given by Ezra Zygmuntowicz, an excellent talk, you can see the slides on his blog . According to him the best stack right now is “Linux+Nginx+Mongrel(mongrel_cluster)+Monit”, he also talked about “Swiftiply” which is a hot patch to Mongrel, which makes Mongrel single threaded and event driven and will make if FAST. He mentioned Rmagick and :include (in models) as some of the worst culprits when it comes to using up memory. ActiveRecord sometimes makes it very easy for developers to write in-efficient code and the best way is to look at the logs to see what sql’s are getting generated. Another tip is to not use Rails script runner, since it brings up the entire stack of rails and instead try and use plain ruby.

A little rant, I had to stand in the next session and so did many others, there were so many people in this session, I really wish next time around the rails conference people could please have some sort of a sign up process so that they can set up the appropriate size rooms. Another wish please, please put the level of proficiency needed to attend some of these talks I ended up going to talks that were just about the basics or put some sort of a description which will let us know that some session is for beginners so that we wont waste time. If you are paying the 7-800 $ for a ticket I don’t want to learn about what VMserver is !!

Practical Design for Developers” given by David Verba, you can get the slides of this session here , he talked about how design is not just about pretty colors, take a look at the IPOD or the Mac and you can see how much design went into it, how the people behind it tried to think about everything. He talks about knowing your users, talking to your users to understand how they will use your application and in conjunction to the other apps they will be using. How to structure your applications to make is easy for your users.

Open Mic Demo Session“, attendees were invited to showcase some of the applications they have written, here are the ones

Interesting Quotes

  • “Fear based enterprise sales” – Cyndi (I think)
  • “There is a distressing absence of women in this community…” – Tim Bray
  • “We used to be, the answer is Java – Ok whats the question” – Tim Bray
  • “The decisions that drive growth don’t get made by CTOs and CIOs.” – Tim Bray
  • “My .emacs file would make strong men weep.” – Tim Bray
  • “How do ordinary people write code efficiently” – Tim Bray
  • YGNI, you think you are going to need it” – Chris Wanstrath
  • Rails eats database resources for breakfast” – Ezra Zygmuntonwicz
  • “NFS, not a fail safe system” -not sure