Skip to main content

Posts

Showing posts from 2009

Axis bank programming error or deliberate prank

Look at the number 4 in front of each menu item and the ) in front of logout. Even the signon page has a -) in the title. Not sure if it was some easter egg as both the pages seems to be functional in all respects.

Holy Cow Google is crawling my site real time

I submitted a post and it was searcheable on Google index within minutes. I wonder this is because the blogger I am using is owned by google.

Premature optimization

I have been assigned the task to increase the the performance of the application in my last 2 companies and from my past experience I believe in 80-20 code execution rule, i.e. in production most of the time its the 20% of the code that is being executed and the rest 80% is used rarely. Therefore before you embark on increasing the performance of the website You should know your customers You should know their usage patterns You should first collect statistics about what are the features that customers are using heavily Don't try to guess which features are used, do a quantitative analysis and focus on only those features that are used heavily. Apache/Tomcat access logs can be your buddies in reaching the goal, take daily logs from last 2-3 months put them in mysql or any DB using some simple python/perl script and create some excel graphs and do a trend analysis. For example in the below graph of webdav usage, I would rather focus on optimizing the PROPFINDs first then othe

Brother MFC490CW printer offline issue

Bought a new Brother printer on Thanksgiving day sale, though the reviews for a 1 year old version were better I bought this one thinking that it would be more better, but this is worse. The printer has no issues connecting for the first time and I was able to scan,print, copy through it but after 2-3 weeks I had to print a document and the printer would show offline in systray.One design flaw I see straight away in printer was no Ethernet port, WTF and it had only a USB port(at 10 in the night I didn't wanted to go shop for a USB port). Googling on it I somehow found that if you reinstall the printer it would work, later I found that there is no need to reinstall as my router is DHCP and I hadn't given a static IP to the printer it was getting a different IP so I had to go to printer properties and change the port. After 1 week I had to scan a document for my wife's Math assignment and the printer in systray was showing offline, changing printer properties also wouldn

Importance of Community support when evaluating open source software

In my previous company we were evaluating ExtJS v/s SmartClient, we did lots of comparisons and SmartClient had lots of cool features and was up to the par with ExtJS but the only thing that was lacking here was traction in the community, finally we decided on ExtJS. When evaluating an open source product I give lots of importance to open source community around that product, namely I look for Does this product has a mailing list, how active is the mailing list? how many messages are posted by users per month and are there enough discussions going on? How frequent are releases for this product? How many users have written blogs and tutorials about this product? Are there any books from OReilly or Manning about this product (I rate Manning and Oreilly books better then other and I hate the SAMS 24 days books) How many bugs are closed,Open,In QA for this product How old is this product? Old product have their own baggage so if a newer kid is on the block with a vibrant community I

Making Windows 7 programmer friendly

My build suddenly started taking a long time(15 mins) one day and the reason was disk related. I started digging into it then thought of creating another smaller partition for just codebase so that I can defrag it at a higher frequency. When I created the partition and tried moving my source code it took more then an hour to copy 5G of data from one drive to other drive and I thought it was some Virus or my AntiVirus software and for some reason I right click on the drive and I accidentally found that windows by default indexing content of files. Unchecking this and then Disabling the windows search service entirely from my maching made my build time from 15 min to 6 mins. It looked like when my build was copying files around in tomcat stupid windows was indexing my files. This was happening even when my content was on c:. Anyways now I am happy. Even 6 mins of build time is killing. I share a virtual box folder to my ubuntu VM to do the build. Virtual box shared folder performance

Food Inc.

If you see this movie you won't like to eat your food. They have made a factory out of processing food. http://www.youtube.com/watch?v=QqQVll-MP3I   and http://www.imdb.com/title/tt1286537/ I am glad being a vegetarian I am less affected by it as most of the stuff in this movie is related to processing meat for Fast food joints. No wonder so many fast food joints can afford to have a dollar menu.

Being Lazy

Not sure if anyone also feel like me but I really get annoyed when I have to think about things I shouldn't have in first place. Below are few examples of things that  I get really annoyed at: Like this blog If I am pasting xml code I have to convert it to xml entities instead of copy paste. This blogger should take care of it. When you enter credit card information some sites use expiration month names instead of numbers. The credit card itself shows the expiration month as a digit then why the hack I have to convert it to a word when I enter it, instead  of entering 7/11 I have to think oh yaa 7 is Jun and I have to select June 11. Like the Grouping function in Windows task bar. if I have 4 Firefox windows open I have to click first on the taskbar on FF icon then think oh which window I have to open. I usually disable that feature. I use this tool called as HotKey Plus that will allow me to type CTRL+ALT+F to open FF. But when I go to other developer machine to debug I hate w

Implementing a Simple Http server within Java client

I have to implement BDB replication for backup purpose. We cant afford to miss any commits. we do checkpoint every 2 mins but loosing even 2 mins of data can be catastrophic, therefore we are going to use a simple Java client that will open BDB as a replica and Master will sync every change to this guy and only then it will commit. Now the challenge was to verify the replication I wanted to print something from this replica or I wanted to stop this replica gracefully. Implementing a shutdown hook wasn't working because kill -9 wasn't calling it and I have to implement some other operations on this Java client. Instead of juggling around with commandline or some RPC I used a simple Http server from Java. private void init() {         InetSocketAddress addr = new InetSocketAddress(httpServerPort);         httpServer = HttpServer.create(addr, 0);         HttpContext context = httpServer.createContext("/", new AdminOpsHandler());         httpServer.setExecutor(Exec

Nudist on late shift

Read this book about Silicon valley history. The story about Hotmail was a pretty intetersting one and it shows that a CEO really needs Guts to show a finger to Microsoft if he thinks that his company is more valued then what the acquirer thinks.

Using ThreadDump to solve production performance issues

One of the cool features with JDK 1.6 is that you can take a thread dump of a running VM. We were intermittently seeing spikes in our production servers and server would become slow for users whenever we saw a spike. we setup a cron job to take threaddump at regular interval and we nailed the issue. Most thread dumps were 300 KB but on was 25 MB and that ringed some bells. Looking at thread dump told use there were 3300 threads executing the same Runnable Task. Further investigation told us that we were using Executors.newCachedThreadPool to create a thread pool in Spring. This would create a new thread if not available for each submitted job. So it created 3300 threads, more CPU was spent on switching thread context than really doing the job. Using Executors.newFixedThreadPool with a size of 15 solved the issue :).

Aggregating DWR interface scripts

My company has a website and running Yslow on it reported that the no of HTTP requests were in the range of 120-130. Accessing the site from UK was pretty slow. Now we used CSS sprites to reduce the no of css images and we were already using JS and CSS aggregation. There were still 10-12 DWR interface scripts and as browser stops rendering while its downloading and rendering js files. I was looking for a solution for aggregate DWR generated interfaces. I searched a lot and than landed onto JAWR. As we are using build time aggregation for static JS I am using JAWR only for generated interface JS. Here are the things I did. Add jawr lib to WEB-INF/classes ==============================web.xml============================     <servlet>         <servlet-name>JawrServlet</servlet-name>         <servlet-class>net.jawr.web.servlet.JawrServlet</servlet-class>         <init-param>             <param-name>configLocation</param-name>        

Ant exec Mysql

to execute a mysql command like "mysql my_db -ufoo -pbar <server/resource/sql/mysql/foo/create_tables.sql" from mysql use the input attribute to pass standard input         <exec executable="mysql" dir="${basedir}/${build}" input="${basedir}/resource/sql/mysql/foo/seed_data.sql">             <arg value="${sql.db_name}" />             <arg value="-u${sql.db_username}" />             <arg value="-p${sql.db_password}" />         </exec> Note this is after Ant 1.6 before Ant 1.6 use the task. The only thing I dont like about it is that you have to set the classpath for the driver.

CGLibProxy example

JDK proxy can't extend classes, you would need to Create a CGLib proxy. But I would recommend using this as the last resort when all your hopes with JDK proxy have ran out. Below is a sample code to create a CGLib proxy. Don't judge on the code as I had to remove lots of code before posting copyrighted code. User trace= (User) Enhancer.create(User.class, new MethodInterceptor(){ @Override public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { long start = System.currentTimeMillis(); try{ return method.invoke(user, args); } finally { logger.debug(" TimeLog: Time taken in "+ (System.currentTimeMillis() - start)); } } });

Ant Grep alternative

if you are using ant filterset to replace properties and you want to figureout if some of the properties are set or not than below target can help you in doing that. <target name="checkTokenReplacement" description="verifies that all tokens are replaced properly and there is not a token with _@ or ENV. in it."> <pathconvert property="errorsFiles"> <path> <fileset dir="${dirToScan}"> <include name="${filePattern}"> <contains text="_@"> </contains> <fileset dir="${dirToScan}"> <include name="${filePattern}"> <contains text="ENV."> </contains> </include> </fileset> <condition property="errorsOccured"> <length string="${errorsFi

Spring Bean locator

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ A python file to read applicationcontext.xml and generate Spring bean locator class. this will remove the need to lookup bean using string constant. This class assumes that you have a SpringUtil class that will provide you the application context. A sample class that will be generated looks like package xxx.util; import xxx.util.SpringUtils; public class SpringBeanLocator { public static xxx.cache.JCache getJcache() { return (xxx.cache.JCache) SpringUtils.getApplicationContext().getBean("jcache"); } public static xxx.ldap.LDAPHelper getLdapHelper() { return (xxx.ldap.LDAPHelper) SpringUtils.getApplicationContext().getBean("ldapHelper"); } ...................... } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import sys try: from xml.etree import ElementTree as ET except ImportError: from elementtree import ElementTree as ET CLASS_TEMPLATE =&

TimeStamp your ant build

Download your ant contrib from http://ant-contrib.sourceforge.net and add it to your ANT_HOME\lib directory and run ant -listener net.sf.antcontrib.perf.AntPerformanceListener deploy This will print a summary report at the end like precompile-jsps: BUILD SUCCESSFUL Total time: 6 minutes 23 seconds Statistics: -------------- Target Results --------------------- ui._applet_jar_deploy: 0.000 sec server.replaceLdapTokens: 0.001 sec ui.replace_applet_version_tags: 0.008 sec server.baseDeploy.common: 0.018 sec server.baseDeploy.common: 0.019 sec server.baseDeploy.common: 0.023 sec server.baseDeploy.common: 0.052 sec ui.baseDeploy.common: 0.062 sec server.baseDeploy: 0.102 sec server.baseDeploy: 0.105 sec server.baseDeploy: 0.108 sec server.baseDeploy: 0.149 sec ui.svnversion: 0.160 sec

RabbitMQ java clients for beginners

Here is a sample of a consumer and producer example for RabbitMQ. The steps are Download Erlang Download Rabbit MQ Server Download Rabbit MQ Java client jars Compile and run the below two class and you are done. This sample create a Durable Exchange, Queue and a Message. You will have to start the consumer first before you start the for the first time. For more information on AMQP, Exchanges, Queues, read this excellent tutorial http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/ +++++++++++++++++RabbitMQProducer.java+++++++++++++++++++++++++++ import com.rabbitmq.client.Connection; import com.rabbitmq.client.Channel; import com.rabbitmq.client.*; public class RabbitMQProducer { public static void main(String []args) throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setUsername("guest"); factory.setPassword("guest"); factory.setVirtualHost("/"); factory.setHost("127.0.0.1"); factory.se

Why do you become so valuable when you are leaving the company?

I work for a good software company and for the last 2 years they didn't do any appraisals. This year we worked like hell on a big project within the company and were expecting to get a decent raise but due to bad economy the appraisal were not done. The company still pays the market rate and due to bad economy none of the employees were thinking of switching jobs. Suddenly I got this job offer from another cool startup and I told my CTO on phone (because he was on vacation) that I am leaving. We had a long conversation on phone and I asked for a day to decide on it. He calls up again after 10 minutes and told me that if its a monetary decision to leave the company than I can tell him and the company do something about it and the company willing to offer me employee stock options to retain me. Not that I am leaving the company because of monetary reasons but how come suddenly I became so valuable that I am being offered stock options and some more money whereas no one talked about

Sql Optimization Tricks in oracle

When optimizing queries, the first thing I do with a slow query is figure out what it's trying to do. You can't fully optimize a query unless you know how to consider alternative ways to write it, and you can't do that unless you know what the query "means." I frequently run into a situation where I'm forced to stop and ask what they were trying to do with the query. This is database-agnostic, not related to Oracle. Dont optimize if you dont need to Use Oracle Grid Control to find the top queries and only work on them. Check Oracle Grid Alerts to see if you are doing more I/O or more CPU or insufficient SGA is allocated, if queries are doing more sorts or using sort joins than a bigger sort area can help, similarly a bigger hash area can help for hash joins. Avoid Union and use Union All if possible: - Union will require elimination of duplicates and if you know that the sets to union does not have duplicates than use Union all. Avoid correlated subqueries: -

Oracle TM contention

Assume there exists a table DEPARTMENT. Table EMPLOYEE references DEPARTMENT using field SYS_DEPT_ID. When SYS_DEPT_ID is not indexed, and EMPLOYEE has large no of rows, this can cause long-running TM lock on delete of a DEPARTMENT row because oracle has to figure out if there are any employees working on this department or not. You can use Oracle Grid control to see the wait events and if you see a TM contention wait event than use the following query to identify these types of missing indexes so they can be added. SELECT * FROM ( SELECT c.table_name, cc.column_name, cc.position column_position FROM user_constraints c, user_cons_columns cc WHERE c.constraint_name = cc.constraint_name AND c.constraint_type = 'R' MINUS SELECT i.table_name, ic.column_name, ic.column_position FROM user_indexes i, user_ind_columns ic WHERE i.index_name = ic.index_name ) ORDER BY table_name, column_position;

How to find constraints with same columns but different name between two databases.

How to find constraints with same columns but different name between two databases. select prodschema.cons prod_constraint, prodschema.tbl prod_table, prodschema.cols prod_cols, localschema.cons local_constraint, localschema.tbl local_table, localschema.cols local_cols, 'ALTER table '|| prodschema.tbl ||' rename constraint ' || prodschema.cons || ' TO ' || localschema.cons || ';' sqlchg from (select constraint_name cons, constraint_type cons_type, table_name tbl, ltrim(max(sys_connect_by_path(column_name, ',')) keep (dense_rank last order by curr), ',') as cols from (select ucc.constraint_name, uc.constraint_type, ucc.table_name, ucc.column_name, row_number() over (partition by ucc.constraint_name, ucc.table_name order by ucc.position) as curr, row_number() over (partition by ucc.constraint_name, ucc.table_name order by ucc.position) -1 as prev from user_cons_colu

How to find index with same columns but different name between two oracle databases.

How to find index with same columns but different name between two databases. select targetDB.idx targetDB_index, targetDB.tbl targetDB_table, targetDB.cols targetDB_cols, sourceDB.idx sourceDB_index, sourceDB.tbl sourceDB_table, sourceDB.cols sourceDB_cols, 'ALTER INDEX ' || targetDB.idx || ' RENAME TO ' || sourceDB.idx || ';' sqlchg from (select index_name idx, table_name tbl, ltrim(max(sys_connect_by_path(column_name, ',')) keep (dense_rank last order by curr), ',') as cols from (select index_name, table_name, column_name, row_number() over (partition by index_name, table_name order by column_position) as curr, row_number() over (partition by index_name, table_name order by column_position) -1 as prev from user_ind_columns@sourceDB where index_name not like 'SYS_%') group by index_name, table_name connect by prev = PRIOR curr and index_name = PRIOR index_n

Be remarkable

Seth Godin talks on why the Software you build should market itself instead of Marketing department doing it for you. Be Remarkable and create a tribe of your own if you want to succeed. Seth Godin on why marketing is too important to be left to the marketing department

Changing jobs in recession

Its a tough decision to change jobs in recession as finding a new job in case of eventuality can be tough. I have been through those times once when I had landed in US and just 3 months after the VCs decided to close the company. It was a tough time at that moment to find a job without a car. But this time its a different story. I am now in a stable company and it has a recurring revenue model and it will run for 5-10 years easily. Looks like I have become comfortable in the job. Even though I put in 10-11 hours daily at the job for 5 days a week I just feel from inside that its time to change. The job is great and I am working in the platform team that develops frameworks that are used by other teams but something is missing. Not sure what but sometimes you keep on asking yourself this question is it time for a change? I need a new spark in my life and job. That's why when the co-founders of my previous company contacted me for a job I was dreading on it for 3-4 months but were

Hadoop - Thinking at scale

Nice article on how to think for problems that are distributed and how not to think like distributed computing of 90s. Yahoo is running a 10000 cluster of machine to drive it web search. Now that microsoft will power yahoo search, what will yahoo do with that cluster ;). http://www.cloudera.com/hadoop-training-thinking-at-scale

Samsung Epix is the worst phone I have used

I was using Samsung BlackJack II before and was pretty happy with its features and performance. Though I am not much of a windows mobile fan it did solved the purpose pretty well. I was very excited when my contract was getting over and saw that the big brother Samsung Epix was available from AT&T. I placed the order and waited for a loooong week to get my hands on it and Boy the touch screen and optical mouse was amazing. Problems started when I tried to connect this phone to wifi. Stupid phone wont connect to wifi. It will keep asking me for the network key. I turned off security on my wireless router and still this phone will continuously ask for Network key. I did a hard reset on phone and tried again and finally it connected to wifi. But after few mins the wifi connection was lost and it keeps asking for network key again. After 4 hours of struggling to get wifi working I gave up on it. Than I saw that an ID1 patch from Samsung is available. It took me 1 hour to get it up and

What I wish had known when I came to USA

When I first came to USA 4 years back no one told me about 401K plans and IRA and others. So I was paying uncle Sam a bucket loads of money. Like USA in India there is no formal education about money in Schools and colleges. If it were not my curiosity about the latest stock market bust I wouldn't have read books about Money and wouldnt have known the basic Rule about Pay yourself first. I guess know I know the basic rules. I wonder what I wish I had known when I was young. Get Rich slowly puts it in a nice post http://www.getrichslowly.org/blog/2009/07/31/what-we-wish-we-knew-when-we-were-younger/

"Maker" schedule vs. "Manager" schedule

Interesting post about how programmers think v/s managers think about meetings http://www.paulgraham.com/makersschedule.html I myself feel like if there is a meeting scheduled at 11 AM than between 8:00 - 11:00 AM I should not pick a task that takes more than 2-3 hours. The reason is that context switch is so expensive that if I leave a task in between than coming back and picking it up again will again require additional 15-20 mins to reestablish the context. Hats off to Paul for writing such a good post.

ASCENT of Money

Recommended viewing for anyone wanting to know the history of Bonds, Stock market, Insurance and how banking system works. http://www.pbs.org/wnet/ascentofmoney/featured/watch-the-two-hour-the-ascent-of-money/24/

DWR like Javascript client for REST

Was trying to find a Javascript client for REST api. Seems like there isnt a one available. The idea is simple if you have a Java class annotated using JSR 311 annotations than one can write a tool like DWR that can at compile time or at runtime introspect Java classes and generate a stub. If there is a class like 1 // The Java class will be hosted at the URI path "/helloworld" 2 @Path("/helloworld") 3 public class HelloWorldResource { 4 5 // The Java method will process HTTP GET requests 6 @GET 7 // The Java method will produce content identified by the MIME Media 8 // type "text/plain" 9 @Produces("text/plain") 10 public String getClichedMessage() { 11 // Return some cliched textual content 12 return "Hello World"; 13 } 14 } than requesting a script like /Jersey/RESTClient/HelloWorldResource.js should generate a javascript class that takes primitives