Skip to main content

Posts

Showing posts from July, 2010

IE CSS size limit

We ran into an interesting issue with IE, we aggregate CSS at build time per JSP file and recently we introduced Jquery and colorbox into the current release that caused the css size to grow beyond 300K. Everything would work find locally as we dont do aggregation in development mode but things wont work in QA environment on IE, Firefox would work fine. Some of the images wont show up in IE no matter what you do and one of the developer found that IE will ignore any css beyond 288 KB and even gzipping content doesn't matter because its the final size the IE will have to parse that matters. Fortunately the solution was to just create two aggregate css instead of one and that solved the issue.

More details on this are at http://joshua.perina.com/africa/gambia/fajara/post/internet-explorer-css-file-size-limit

SVN revert a changeslist

Just discovered SVN uses merge command to revert a changelist. Suppose some developer checks in a changelist number 20404 in wrong branch, use the below command to revert it
svn up svn merge -r 20404:20403 http://zzz.xxx.com:8080/repos/trunk svn st svn diff svn ci Just remember to give the higher changelist number before lower one and use svn diff to diff the changes before commiting it.

Dumping RabbitMQ queue contents

Apparently there is no easy way to look at the content of messages in RabbitMQ. the list_queues only will give you a count but if you want to look at all the messages content then there is no easy way. I had few thumbnail generation messages in the queue that the code failed to ACK because of exceptions in code. Now I want to see what files are stuck for thumbnail generation. The best way is to restart the program and Rabbit would redeliver the messages but we cant restart a live system. So the trick is to just write a python program that would consume the message but wont acknowledge it.


import sys from amqplib import client_0_8 as amqp def process_message(msg): print "=================================================" print "Properties =" print msg.properties print "Body=" print msg.body if __name__ == '__main__': if len(sys.argv) < 5: print "Usage python list_queue_messages.py mq_url mq_user mq_pas…

Parsing xml file using SAX file in python

Again I love simplicity of python. I had a xml file that sometimes can range from 1KB to 100MB so I can't use ElementTree. Python SAX  seems similar to java minus the verbose nature of java.

My xml file looks something like
<restorezipmeta messageid="UUID" outputzippath="test.zip" resultendpoint="http://XXX.7080/rest/private/RestoreRestService/1.0" userid="1">

  <restoreentry logicalpath="/Shared/kpatel/CustomRules.rtf" physicalpath="/home/kpatel/try/About_Ubuntu_[Russian].rtf"></restoreentry>

  <restoreentry logicalpath="/Shared/kpatel/BrowserPAC.doc" physicalpath="/home/kpatel/try/Derivatives_of_Ubuntu.doc"></restoreentry>
</restorezipmeta>

 and here is a small sample to parse the xml using SAX api and create the zip. All you need to do is to create the ContentHandler like you do in Java minus the verbose nature


import zipfile import os, sys import logging from xml…

creating zip file in python and compression

I am a java programmerr but sometimes program in python.I must say python is very easy to do stuff that requires very verbose coding in java. To create a zip file in python all you need to do is :

import zipfile
restoreZip = zipfile.ZipFile("test.zip", "w")
restoreZip.write(physicalPathOfFile, logicalPathOfFileInZip)
restoreZip.close()

Now python doesnt compress by default so you need to add compression mode while opening zip file

restoreZip = zipfile.ZipFile("test.zip", "w", zipfile.ZIP_DEFLATED)

solved the issue

Java redis client for begineers

I had to use redis in our project in both python and Java. In this post I will cover a basic example of generating counters using Redis. I had to use cassandra db to push data but cassandra doesnt have autoincrement counters at this moment so we will use redis till the new version of cassandra supports it. Redis has memcache like API but the advantage is that its has atomic operations and the data is saved so server restarts will survive the data. The only disadvantage I see is that the java client yet doesnt support consistent hashing but eventually it will.


 Install the redis server by following http://code.google.com/p/redis/wiki/QuickStart run it using ./redis-server Download JRedis client from http://github.com/alphazero/jredis/downloads Run the below program.
import org.jredis.JRedis; import org.jredis.RedisException; import org.jredis.connector.ConnectionSpec; import org.jredis.ri.alphazero.JRedisService; import org.jredis.ri.alphazero.connection.DefaultConnectionSpec; public …

Eclipse disable pydev CTRL+SHIFT+T and enable Java open type binding

I am a java programmer but I can code in python too so for some work I had to code in python and I installed pydev in eclipse but It messed up with my Open Type (CTRL +SHIFT+ T) binding and when I now hit that it asks me a popup to tell whether to open python class browser or java open type, off course I hate it because 99% of the time I want Java open Type. The way to get it working back was to go to

Windows->preferences->General->Keys  and go to the python "Show Class Browser" binding and instead of choosing "In Windows" choose "Pydev editor scope" and you are all set.

Ubuntu VirtualBox and no sound in Windows7 issue

My Windows7 crashed and as we do our most of the development in ubuntu it makes sense to install ubuntu as host. But when I installed Windows7 there was no sound coming in it. Thanks to ubuntu community the solution was tedious due to my mistake but finally I did it. The way to do is :

1) Make sure you have proper virtualbox version. I had the OSE version but my ubuntu is lucid version so I needed that virtual box.  If you get "Error: Conflicts with the installed package 'virtualbox-ose'" that means you have to use Applications->Ubuntu Software Centre to uninstall all virtualbox OSE package (in my case there were 3 packages).
2)  Download and install the virtualbox lucid version. It will automatically detect old hardisks and upgrade it.
3) You need to VM settings in virtualbox and go to audio and select Alsa Ac97 driver.
4) start your VM and now go to realtek AC97 driver http://www.download3k.com/System-Utilities/System-Maintenance/Download-Realtek-AC-97-Drivers.h…