agileaholic :)

Java, groovy, grails, hacking and more…

Avoiding Firefox 3.0 frequent prompts when behind the proxy

Posted by Prabhu Beeman on February 21, 2009

You are reading this blog because you are using Firefox 3.0 and you are behind the proxy which needs authentication and you are annoyed by the frequent prompts for the username password.

How to stop this?

1) Just type about:config in your address bar

2) Enter network.auth.use-sspi in the filter field

3) Change the value to false if set to true

You will never be prompted anymore (may be you have to enter for the first time after making this change)

Posted in Uncategorized | Leave a Comment »

Connect 2 PCs using USB Cable

Posted by Prabhu Beeman on February 21, 2009

Do you know that you can establish a network connection between two PCs using a USB-USB cable. For that though you need a special USB-USB bridged cable. It costs somewhere between Rs.700 to Rs.1000. Click here to know more on how to connect your PCs using USB Cable

Posted in Uncategorized | Leave a Comment »

How to compute distance between two places

Posted by Prabhu Beeman on January 17, 2009

After successful implementation of my previous project I started working on my new project which is confidential :-)

I was trying to figure out if i could compute distance between 2 places which is one of the requirements for my project. After searching for about 4-5 hrs, I got what i want although not very precise.

Basically, you need the latitude and longitude of the places for which you need the distance. Thanks to the Yahoo Maps – GeoCoding API. You just need to provide the necessary details (like the location/city/country) and you get the latitude and longitude of the location.
In order to compute the distance you can use Haversine formula. Here is the java implementation.
It provides the result in nautical miles….

1 nautical mile = 1.85200 kms

I tried calculating distance between some of the places in chennai, India and it worked great.

Posted in haversine geocoding distance | Leave a Comment »

XpressMark – Bookmarking Videos made easy

Posted by Prabhu Beeman on October 19, 2008

My new site Xpressmark is up and running. It helps you to bookmark your favorite video from your favorite video sites such as youtube, metacafe, vimeo etc.

Technologies used: Groovy, Grails

Posted in video bookmark xpressmark groovy grails | Leave a Comment »

Regex in Groovy

Posted by Prabhu Beeman on July 19, 2008

Target Audience: Regex newbies

I would like to talk more about regex this time. This might be helpful for someone who thought regex to be very complex.

Let us use regex to validate an email (like firstname.lastname@email.com or firstname@email.com)

In regex, what matters is the pattern. Let us examine our pattern one by one.

how should we validate firstname( it should start with a alphabet and can have any number)

def FIRSTNAME = /[a-z]+\d*/

eg: james

we define the pattern always between the backslashes ‘/’

[a-z]   – means a to z

[a-z]* – means a to z can occur one or more times

\d       – means any digit/number

\d*     – means any digit/number zero or more times

def DOT = /[.]?/

[.]  – means a dot should be present

[.]? – means a dot should be present zero or one time

please be aware that  . without the square brackets means ‘can have any character’

def SECONDNAME = /\w*/

eg: gosling

\w -   means any word (includes number as well)

\w* – means any word can occur zero or more times

def AT = /[@]/

[@] – means must have @ symbol

def DOMAIN = /[a-z]+\w*/

// eg: sun

[a-z]+ – means a to z can occur one or more times

\w* – means any word including numbers can occur zero or more time

def TLD = /[a-z]{2,4}/

//eg: com, us, info

[a-z]{2,4} – means a to z can occur 2 to 4 times (ie can be “us” or “com” or “info”)

Now putting it all together

def emailRegex = /[a-z]+\d*[.]?\w*[@][a-z]+\w*[a-z]{2,4}/

or even better

def emailRegex = /$FIRSTNAME$DOT$SECONDNAME$AT$DOMAIN$DOT$TLD/

If you want to validate an email in groovy, following is the code

   1: email="james.gosling@sun.com"
   2:
   3: FIRSTNAME = /[a-z]+\d*/
   4: DOT = /[.]?/
   5: SECONDNAME = /\w*/
   6: AT = /[@]/
   7: DOMAIN= /[a-z]+\w*/
   8: TLD=/[a-z]{2,4}/
   9:
  10: print (email ==~ /$FIRSTNAME$DOT$SECONDNAME$AT$DOMAIN$DOT$TLD/ )

==~ – means look for the matching pattern

Try validating with other email values and try optimizing your program by bringing in more constraints.

Disclaimer: This program by no means is complete and cannot be used for a full fledged email validation, please google ‘regex’ for better regex patterns.

Posted in groovy, regex | Leave a Comment »

Groovy – operator overriding

Posted by Prabhu Beeman on July 18, 2008

What do you think will the world without Google will be?

Let us try to represent this using a groovy code and in the process know more about the groovy language.

   1: class World {

   2:     String result = "World";

   3:

   4:     World(){}

   5:

   6:     World minus(Company company) {

   7:         if(company.getName() == "Google") {

   8:             result = "No Search!!!No AdSense!!!"

   9:         }

  10:         else {

  11:             result = "Don't Know"

  12:         }

  13:         return this;

  14:     }

  15:

  16:     World minus(String company) {

  17:         minus(new Company(company))

  18:     }

  19:     // This method is called when we try to print the object

  20:     String toString() {

  21:         return result;

  22:     }

  23: }

  24:

  25: class Company {

  26:     String name

  27:     Company(String name) {

  28:         this.name = name

  29:     }

  30: }

  31:

Let me explain the code here

We do not have any more semicolons (optional)

Line 6: We have overridden the ‘-’ (minus) operator here, I will explain this later

Line 7: Now where was getName() defined, well getName() and setName(…) method is created for you the moment you create the property (Line 26)

Line 16: That is operator overloading

Alright so here is the final piece of code, let us go ahead and look at it…

   1: def ourWorld = new World()

   2: def google = new Company("Google")

   3: ourWorld - google

Line 1: This is dynamic typing, the compiler takes care of the object type it should be converting to.

We create a world instance and a Company instance.

So when we remove google from ourWorld(Line 4)

ourWorld – google

What do we get??

Result: No Search!!!No Adsense!!!

Even better with the following code

   1: def ourWorld = new World()

   2: ourWorld – “Google”

Isn’t this amazing. You just subtract Google from ourWorld and you see the result, couldn’t depict better than this.

Posted in agile, groovy | Tagged: , | Leave a Comment »

NONOH – NO Security

Posted by Prabhu Beeman on July 8, 2008

I stay away from India and had to use some cheap voip service to call back home.

I used nonoh, pretty cheap so you have to compromise on the quality.

Well, i realized very recently that i need to compromise even on the security aspect of it.

When I login to the application they are passing the username and password as part of the url (a GET request). Well, the username and password is encrypted. But it didn’t take me more than 10 secs to know that they use ROT13. Probably might help you protect from lame users but not from the ever watching nerds.

Posted in agile | Leave a Comment »

Modal Box Plugin for Grails

Posted by Prabhu Beeman on July 6, 2008

[Update: This issue is now fixed in the latest version of the plugin. Thanks for the fix Alex.]
Plugin url: http://www.grails.org/ModalBox+Plugin

I tried to implement the Modal Box Plugin in my application and had difficulties in getting it done.The instruction given in the above site looked straight forward. But then after following the instruction all I get is a blank page..

looked into the generated html (right click and view source)

following was the header snippet (<modalbox:modalIncludes/> generates the following code)

<script type=’text/javascript’ src=’/myapp/plugins/modalbox-0.1/js/modalbox/prototype.js’ />
<script type=’text/javascript’ src=’/myapp/plugins/modalbox-0.1/js/modalbox/scriptaculous.js?load=effects’ />
<script type=’text/javascript’ src=’/myapp/plugins/modalbox-0.1/js/modalbox/modalbox.js’ />
<link rel=’stylesheet’ href=’/myapp/plugins/modalbox-0.1/css/modalbox.css’ />

Effectively removing the <modalbox:modalIncludes/> from the jsp gsp renders the page correctly
So time to scrutinize the above 4 lines..
The problem was actually with the empty close tag.

So ideally
<script type=’text/javascript’ src=’/myapp/plugins/modalbox-0.1/js/modalbox/prototype.js’ />

should be

<script type=’text/javascript’ src=’/myapp/plugins/modalbox-0.1/js/modalbox/prototype.js’ ></script>
and so is the rest.
bingo.. everything works great now.

So how do i make this change in the plugin?

Go to your plugins directory -> modalbox-0.1->grails-app->taglib->ModalboxTaglib

then make your changes inside def modalIncludes

Its done…I’m a happy soul now :-)

Posted in grails, plugin | 1 Comment »

Goowy – Webtop

Posted by Prabhu Beeman on October 24, 2006

Goowy is a Web(Desk)top with lot of features. Though its built on flash it was fairly fast on a 64 kbps connection. The look and feel was good too.It has the following features e-mail, contacts, calendar, news, rss, file storage (1 GB from Box.net), games and many more.
You can create an account in a flash (pun unintended).

I have attached some screenshots for those who wants to have a view before they try out.

Snapshot of the Desktop

Snapshot of file upload

Posted in agile | Leave a Comment »

Qumana way

Posted by Prabhu Beeman on October 19, 2006

Qumana impressed me a lot in terms of usability.

What is Qumana ? Its a blog editor with some real good feature.

Worth a try!!!

Powered by Qumana

Posted in agile | Leave a Comment »