Django, Open Source, Personal, Python, Random

Ada Lovelace Day – Leah Culver

Though internet spreads the word at lightening speed, but i came to know about Ada Lovelace Day 3 days late.  Pardon my ignorance.

To quote from website http://findingada.com/

Ada Lovelace Day is an international day of blogging to draw attention to women excelling in technology

Who was Ada ?

Ada Lovelace wrote the world’s first computer programmes for the Analytical Engine, a general-purpose machine that Charles Babbage had invented.

Influences :

The computer language Ada, created by the U.S. Defense Department, was named after Lovelace

The name that promptly came to my mind of  woman in technology i admire is :

Leah Culver

She was founder and lead developer of  Pownce (a twitter clone), She has contributed to OAuth and many more open source projects and another important thing she writes code in  python :).

Nowdays she works with SixApart.

Its not too late to celebrate i think, spread the word and tell the world about women you admire in technology.


Standard
India, Linux, Open Source, Python

Attention Guys , Kwippy here !

May be this shirt quote is witty enough, Some one will finally love me

The origin of above quote is xkcd . Its human instinct to seek attention. Its deep rooted in our genes. The T-shirt quotes are one example. Same goes for the IM status.  The IM is yet another communication tool that has become part of our lives. Now we do set our IM statuses according to our mood or just for fun. So that friends around us might read our status message.

What about having an aggregation of all the status messages you ever set. Kwippy is here for that.

kwippy

kwippy

Just add Kwippy as buddy in your gtalk or yahoo messenger and get going with the storing the status messages from your IM messenger to your Kwippy account at web.

There are lot of features that Kwippy provides:

  • comment on the status messages.
  • share posts,links as instant messages.
  • have threaded discussions on a post
  • make more friends on the webosphere.

To dig more deep into Kwippy, its different that twitter, pownce and other microblog services in away,I quote the official kwippy blog for this:

In kwippy, the whole focus is on the Instant Messenger. The friends list on the instant messenger is the most intimate friends list you can find, of all social networks. It gives the people in the list immediate access to your attention. People share their joys (i got a raise), sorrows (i flunked my english papers), their favorite links, and thousand other things through their status messages. And all these people also have a list of their closest friends on their list. And like in the real world when a real friend introduces you to another person, the chances that you hit it off are greater. There’s this trust thing which is automatic.

Moreover Kwippy is built on coolest technologies like python, django, jQuery, Nginx and memcached. They have loosely coupled the system into services, Their blog post about its architecture speaks a lot about its quality of service and proclaims its bound to scale well.

I was following the twitter downtime discussions, some one was talking about Why twitter was built as a CMS why not as is messaging service ?.

I feel the same for Kwippy , Can they integrate concepts of messaging system to the kwippy architecture?

I have affinity for Kwippy because its Made in India , I have personally met the Kwippy CEO/co-founder. The startup culture is not as happening and vibrant in India, Its on the brink of becoming a great startup environment, So Kwippy is yet another Indian startup that might become an cult/role model figure for startuppers.

Come on Kwippy dikha do !

Follow me at kwippy

Standard
Open Source

I am a World Record Holder :)

Firefox achieved the world record for most number of downloads in a day. I was a downloader too. So i got this certificate From Mozilla. I am part of a world record for a browser that changed the world of browsing,challenged the market hegemenoy of Internet Explorer and created an ecosystem of applications around firefox with its addons and open source code.

firefox-certificate

firefox-certificate

If you are still using Internet Explorer, Don’t click the blue e now. Download cool new Firefox 3 and be a part of a revolution, you will feel the difference.

Standard
Java, Open Source, Python, Script

Joys of Python and APIs

At my present job , Most of the time, I have to do changes in the legacy Java code to improve performance.

But this time i was asked to tell the extent of performance improvement due to my changes . I tried to use some Java Profiler , I tried Eclipse TPTP and HPROF but due to complacency of the legacy application. I was not able to profile my changes.

So i decided to keep it simple . Log the timestamps and analyze the result. But the log generated by this was unable to show any subsequent improvement in performance as I had to log time in Milliseconds ( System.nanoTime () could not be used for Java 1.4) .

For better time precesion i googled and found this timer library by Vladimir Roubstov.I tweaked it for my code and got the comprehesive log output.

Now to analyze the log, I wrote a python script that reads two log files and generates the time improvements in aggregation and for each run. This was the most exciting part.

for i in imap(lambda x,y:(x, y, x-y), [float(b) for b in new_list],[float(a) for a in old_list]):
              print '%f - %f = %f' % i

I wrote it in no time , Python Rocks . Then I decided to go one step further. What about plotting it on a graph. Straight away Google Chart API came to my mind and there is python wrapper to this.
So I wrote this small function to produce graph for these logs.

def draw_chart():
    from pygooglechart import Axis,SimpleLineChart
    chart = SimpleLineChart(600,200,
                        x_range=(0.000, 0.999), y_range=(0.000, 0.999))
    chart.set_colours(['ff0000', '0000ff'])
    chart.set_legend(['New','Old'])
    chart.add_data([float(a) for a in old_list])
    chart.add_data([float(b) for b in new_list])
    chart.set_axis_range(Axis.LEFT, 0.000, 0.999)
    chart.set_axis_range(Axis.BOTTOM, 1, 100)
    chart.download('D:\\my_data.png')

This is the graph generated for my data :

The Generated Graph

The graph does not show much improvement though , but the post was about joys of python and APIs :)

P.S. : There are Java backports for using 1.5 > features like System.nanoTime().

Standard
India, Open Source

Delhi Barcamp 4 Take Aways

barcamp4

delhibarcamp4

After being postponed 2 times , The Delhi Barcamp 4 started at Amity audi quite well as scheduled. All credit to Piyush and volunteers the people behind it.

I reached the venue much early and met this guy Nilesh and IITK and IIML product , He has just started a startup and runs a music school and he was to perform in the evening beer party .

Then the event started in a formal way , But by an amazing personality Mr. Talwant Singh , A Judge by profession who has used IT in the district courts to evolutionarily automating the processes of District Courts, A first by some one in Government Sector. No wonder he blogs for cyber security.

He presented a good talk and said build something that works and is simple to use even for an illiterate person.

Then it was talk on entrepreneurship incubation my Amity ppl, Then we moved to the presentation halls. First interesting talk was by chahiye guys (one of the main sponsors) . The presntation was a bit over crowded by the American names but the emphasis was on building something that adds value.

Nirat Bhatnagar said there are two ways to make a difference :

  • start a business and make profit only
  • start an NGO with no profit no loss.

But there is middle path also , to put ethics in you business , to do something that adds value to society.

Then a nice talk by two young guys on building facebook apps. They had built a cool Gift sharing app iGift in their summer training.

Another session was by Alabot guys , there product is really cool , it uses NLP and sits as middleware to give results for any query from different sources. The talk was more market oriented more then telling how it was built . There was demo for getting air ticket from chennai to banglore. from IM and it provided awesome results.

In the mean time i met my twitter frnd Mayank Dhingra , He is working some really cool stuff at a startup that works in Mobile and Python . Then the guys frm quite famous slideshare , Arun and Gaurav.

Then it was lunch . After lunch Guneet from chaahiye told about developing web apps with salesforce.

and Demo by RouteGuru folks .

The the last talk was by two firangs Nick and Charlie from UK and Germany . They out sourced themselves to India for yet another startup for yet another Rails app Entrip . This talk was pick of the barcamp in terms of demo and the work they had done . Entrip is mashup of Google Maps , flickr facebook and many other api’s to show travel trips by frequent travllers on a map .

The two presentation i really liked were by prashant on weird topic East Internet company , he elaborated how the History of expeditions lead to colonies and Wat will happen with the internet .

Get the East Internet Company presentation here.

The other presentation was by Akshatt on Folksonomy the term given to social collaboration over Internet . The power of contribution/sharing can do wonders. Get the Folksonomy presentation here .

There was quiz to go and a beer party later , but i had to leave as i had been offred lift to gurgaon by another startupper from Masplantaz. He is working on some product on Rails . Wish i hear another startup success story.:)

And Yes i got the free T-Shirt  which says ” I want to change the world but they don’t provide the source code “

This was my first barcamp. I wanted to hear about python/django stuff . But it was Rails and Entrepreneurship all the way .

My Takeways from the Barcamp were:

One should build some thing that is simple and that adds value.

Check out the Barcamp Pics at Flickr.

Standard
display tags, Java, Open Source

Exploring Display Tags

Being a J2EE developer you have an edge over others , as you can explore thousands of prebuilt open source components over internet . Display Tag is one cool component which i explored recently .

It provides pagination to the JSP page , one just have to set the arraylist of bean object int the request scope of the page and display tags iterate that arraylist and provides a cool tabular view of the data. One just have to mention property names of beans in the dispaly column tag. It uses commons beanutils for iterating the beans.

Now my point in exploring is that i had to provide much more functionalty for my project .

1. Sorting by table headers
2. Exporting to CSV , Excel file .

Both had a simple solution i just had to mention “export=true” in the table header for exporting the table data.

I had to write “sortable=true” in the table column.

Sorting worked out fine with String values but , there was error for date column as it took date as string also. So i had explore more .

What i did, I changed the type of my date field in bean to java.util.Date . The sorting problem was resolved , But the date format caused problem as i had to show it in GMT . For that I downloaded the source code of display tag from sourceforge. There is org.displaytag.sample package in the source . I placed the source of this package in my code and added decorator to the column :

Now it displayed the proper output.

Now with export set to true in table header . It display links to export in CSV,EXCEl,PDF,RTF formats etc. for exporting to be prper ihad to add ‘displaytag.properties’ to the classpath of my application .

export.types=csv excel xml pdf rtf
export.excel=true
export.csv=true
export.xml=true
export.pdf=true
export.rtf=true
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView
export.pdf.class=org.displaytag.export.DefaultPdfExportView
export.rtf.class=org.displaytag.export.DefaultRtfExportView
export.excel.filename=data.xls
export.pdf.filename=data.pdf
export.xml.filename=data.xml
export.csv.filename=data.csv
export.rtf.filename=data.rtf

But it still didn’t work it displayed all the records on the next page.

So what i had to do to sort out the problem was to add a filter fior exporting in the web.xml.

Configure the Filter in your web.xml:

ResponseOverrideFilter
org.displaytag.filter.ResponseOverrideFilter

And add mappings for urls the filter will intercept, for example:

ResponseOverrideFilter
*.do

ResponseOverrideFilter
*.jsp

Thats it . I made my report table specfic to the client needs.
Thanks Display Tags.

Long Live The open Source Revolution.

Standard
Java, Open Source

Have Fun With Display Tags

Most of the time we get large chunk of data on a view page say there are more then 20 records to be shown , which makes it untidy and scrolling..
So there are many solutions to this problem, that is we have to implement pagination in our code .
first solution is to develop your own programming logic for pagination, its good bid if you are a proud geek .. and you make your own way…
But i opted for second option that is to look for an already available solution on the web and i found it easily … Display Tags is my bet fo pagination…

they are very easy to use with JSP/Servlets application , provided you send arraylist of the Java Beans you populate to view records… Look at this tut . Its makes your jsp code neat and gives you a paged output…

You may find an issue if you are using struts ,as the case with me… that is you are unable to next output page.. for that there is support provided by them.

Just download the display tag jar and use in you web app .. have fun with pagination…

Standard
Java, Jboss, Logging, Open Source

Logging is in, System.out.println() is passe..

I read somewhere in a technical book , “Writing Code without logging is like Driving in the fog without switching the lights “

As a beginner we use System.out.println() to print messages in Server log, that is pretty efficient for debugging purposes .But the problem with System.out.println()is that it is not descriptive .If we want to know which file is generating the message we have to identify our self, and moreover we are not able to generate separate log files

log4j mechanism is the answer to all these limitations. We can configure it to work as Console appender (like System.out.println()) and as a separate log file.
Working with it is quite simple ,What we have to do is to just download log4j jar , set this in your application. write a sample log4j.properties file add it to WEB-INF/classes .

log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB

log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

hmm.. thats it now use it in place of System.out.println() ,just you have to instantiate a logger object .. as shown below :


import org.apache.log4j.Logger;
public class Test {
static Logger logger = Logger.getLogger(Test.class);
public void doIt() {
logger.info("Info Logger!");
logger.debug("Debug Logger!");
logger.error("Error logger!");
}
}

Thats it.. we can specify multiple logging level i.e. INFO,DEBUG,WARN,ERROR,FATAL etc… that is the further you dig the more you get… if you want dig , check this cool link.

The there is rolling file appender that is we can generate log file ,hourly , daily , weekly or monthly, that too very easily..

Hmmm … Then i tried it for my appliaction wich is deployed on JBoss server ..

But it gave errors saying that “OnlyOnceFileAppender Error” blah blah…
that was due to the fact that jboss uses log4j internaly for logging… and i can’t overload jboss logger with another..

So what i did i configured the jboss logging for my use .. and it was as smooth sailing afterwards ….
what i did , went to JBOSS_HOME/server/default/conf and there was the file log4j.xml … to configure it for my application what i had to do was to add one appender and one category element in log4j.xml ..
look at this jboss wiki .. it tells the story what i did actually , i added following appender for my application in log4j.xml

One more thing i added was the category for appender… Read This to Configure log4j.xml ..

Thats all ,get going with this logging and kick System.out.println() out of your code…

Standard
Jboss, Open Source, Oracle

Pain-Less Database Connectivity with Jboss datasource and Oracle 10 g express

It will be pain less for you guys as i beared the pain configuring my application to connect to database with jboss datasource . so here are the steps for that :
I used JBoss version 4.0.5 and Oracle 10g express edition . both are downloadable freely from internet
Then i found the suitable driver for me as i was using java version 1.5 so i downloaded thin driver ojdbc.jar .
Then i googled and followed some suitable links :

1. Copied the thin oracle driver (ojdbc14.jar) in server\default\lib directory of
JBOSS_HOME.

2. Copied the oracle-ds.xml file from docs\examples\jca directory of JBOSS_HOME to server\default\deploy of JBOSS_HOME.
Configured it for my use “oracleDS” is the name for my datasource , its type matching OracleXE was also defined by (explained later)
which reads as:
<datasources>
<local-tx-datasource>
<jndi-name>oracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>hr</user-name>
<password>hr</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>OracleXE</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

3.Changed to server\default\conf of JBOSS_HOME and edited standardjaws.xml for my use. added the following entry on the top under jaws element .
<datasource>java:/oracleDS</datasource>
<type-mapping>OracleXE</type-mapping>

the type defination of OracleXE is not provided by default , i simply copied the type defination of Oracle8 and renamed it a OracleXE. (may be its not professional approach but there was no other alternative )
It works fine.

4.Edited standardjbosscmp-jdbc.xml and added
<datasource>java:/oracleDS</datasource>
again defined the type matching here as in third step.

5.Edited login-config.xml ,added OracleDb realm as following :

<application-policy name="OracleDbRealm" >
<authentication>
<login-module flag="required" code="org.jboss.resource.security.ConfiguredIdentityLoginModule" >
<module-option name="principal" >sa</module-option>
<module-option name="userName" >sa</module-option>
<module-option name="password" />
<module-option name="managedConnectionFactoryName" >jboss.jca:service=LocalTxCM,name=oracleDS</module-option>
</login-module>
</authentication>
</application-policy>

Thats it JBoss is ready ,

Now add the code like this in your jsp file

InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:oracleDS");
Connection con = ds.getConnection();

and you can do it.

There is another way for connecting to data source which is :

I faced many problem in connecting and had to take help from JBoss forums Link , it realy helped.

Thats it restart JBoss server and have fun.

Standard
Linux, Open Source, Ubuntu

My Ubuntu CD arrives.

Ubuntu is one cool linux distro’s available these days , and they are shipping it free to your doors for promotional purposes.

I requested it a month ago and it arrived yesterday to my place. i installed it on my machine as it came.

ubuntu is an African word meaning ‘Humanity to others’, or ‘I am what I am because of who we all are’.

To be frank ubuntu rocks and beats windows in every aspect as user friendliness is its key USP.

The latest ubuntu release is feisty fawn 7.04 .

ubuntu logo

ubuntu primarily comes withe gnome desktop environment  .

There are other flavours  kubuntu which has kde as desktop environment .

another ubuntu based flavour is edubuntu which is for educational purposes . it hase many open source softwares helpful for educating children.

I have requested these two distro’s too.

Standard