Batch Resize Images
Step1: install ImageMagick
$ sudo apt-get install imagemagick
Step2: go to the images folder and type
$ mogrify -sample 1280 x 800 *.JPG
Here 1280 x 800 is the final size you want and *.JPG is the file set.
To get more info on command options, visit http://linuxuser32.wordpress.com/2007/06/16/batch-image-convert-scale-thumbnail-jpegs-pdf/
Playing with BlueProximity
1. Install blueproximity:
$ sudo apt-get install blueproximity
2. Pair up your computer with your phone using Bluetooth. You can use System -> Preferences -> Bluetooth to do so.
3. start blueproximity:
$ blueproximity &
You will see the blueproximity icon appearing on your system panel.
4. Configure blueproximity to suit your likings, i.e. the distance after which your screen will get locked, time duration, etc.
That's it.
Anyway it is not kicking unless I can write my own code :D
Lectures at UoM
Build Your Own SOA Middleware
Access Vista from Ubuntu
For this example say your Vista user account is vista-pc and password is vista-pw. Also say the IP is 192.168.1.2
----Do the following in your Vista machine----
1. Start/Run secpol.msc
2. Open Local Policies/Security Options, find "Network Security: LAN Manager"
3. Change it to "Send LM & NTLM"
4. share the folder that you want (say movies)
---Do the following in your Ubuntu machine---
1. sudo apt-get install smbfs
2. sudo apt-get install smbclient
3. sudo mkdir /mnt/hd
4. sudo mount -t smbfs -o username=vista-pc,password=vista-pw //192.168.1.2/movies /mnt/hd
That's it :) You can now access the shared Vista folder from /mnt/hd
NBQSA Merit Award for Rampart2
Hard Times
I broke my spectacles and got a new pair from George Gooneratne Optometrists. Guess what? They have taken wrong measurements and I had to visit them again to replace the glasses with correct measurements. After spending about two hours at their lab I finally got my sparkling shiny spectacles.
The day after I was playing basket ball at WSO2 when I got hit by the ball right on my face at a most unexpected time. I was actually catching my breath and I look up only to see something crashing on to me. The shiny new spectacles were broken into pieces and my nose got wounded. The wounds were not that serious and I was lucky not to bleed internally. I found the broken frame of my spectacles and thought, hey that's not too bad because I still have the frame to which I can get a pair of glasses fixed. I put all the pieces into my bag and came home. The next day I was getting ready to go and get new glasses fixed. I collected broken frame and believe me, one side arm was missing. What the hell? I told myself. I searched every possible place I could look into but came up with nothing. Hmm, that's life, I thought and went to optometrist and get a new spectacle fixed.
The next day I was happy with my new spectacles and spent the day peacefully at WSO2. The entire day I was in a meeting and later in the evening I and the others were invited to dinner at an Indian restaurant. The food was okay, but it didn't sound right for me. The next morning I woke up to find that I am suffering from a very bad stomach ache. I spent the entire day at home unable to do anything. The medication came to effect only in the evening. Today is the second day of the very unpleasant "Digesting Error", and there is yet another day to go to end the week. I am expecting what next :)
Google Chrome - Fast and Elegant
Java Strings: literal.equals(param) OR param.equals(literal)
1. helloStr.equals("hello")
2. "hello".equals(helloStr)
Both will do fine, but which is the better one? I've been using the second form but never thought of the difference (hmm, that's bad ;) anyway people do remember certain things bit later). In one of the code reviews at WSO2 it was revealed. The first form can lead to a Null pointer exception in the case when the helloStr is null. The second option will save you from this since the literal "hello" is not null always and you are invoking a method of a not null object. In this case even if the helloStr is actually null it doesn't matter because it'll only cause the program to check "hello" against null which results false.
If you are checking two String references then you have no option, but always try to invoke the equals() from the most probably not null reference.
Little things do matter :)
Setup Browser in Pidgin
Fixing this issue, however, was pretty much easy ;) Open Pidgin, go to Tools --> Preferences --> Network. Then you can find a button saying Configure Browser. You'll get a tool window where you can set the command you want to execute in order to open up the browser. In my case FF2 can be started by issuing firefox-2 %s
Just that. It works fine :)
Apache TCP Monitor - How To?
The following blog posts too give an insight into this tool.
http://charithaka.blogspot.com/2008/08/how-to-use-tcpmon-inside-eclipse.html
http://www.keith-chapman.org/2008/07/using-tcp-monitor-to-debug-web-service.html
Internet in Two Machines
Anyway if you want to know about how to setup IP forwarding see the following links.
http://www.ducea.com/2006/08/01/how-to-enable-ip-forwarding-in-linux/
http://www.linuxforums.org/forum/linux-networking/64083-simple-ip-forwarding.html
Default Browser Settings in Thunderbird
The solution was to tell Thunderbird the path of the browser to open. You need to create user.js file inside your ~/.mozilla-thunderbird/xxx.default/ (the xxx means any weird set of letters and numbers, e.g. 20art4c7). Type (or edit the path as to suit your browser) the following lines into that file and save it.
user_pref("network.protocol-handler.app.ftp","/usr/bin/firefox-2");
user_pref("network.protocol-handler.app.http","/usr/bin/firefox-2");
user_pref("network.protocol-handler.app.https","/usr/bin/firefox-2");
That's it :)
XPath with Axiom
The tricky part is, how to work with Namespaces? To get an idea on to the matter consider the following XML document.

The following code fragment will retrieve the ns1:c1 element and the two ns2:color attributes of each element.
// root is the document
OMElement root = builder.getDocumentElement();
AXIOMXPath xpath = new AXIOMXPath("//a:c1");
xpath.addNamespace("a", "http://namespace1.com");
OMElement c1 = (OMElement)xpath.selectSingleNode(root);
System.out.println(c1);
xpath = new AXIOMXPath("//@b:color");
xpath.addNamespace("b", "http://namespace2.com");
List
System.out.println(colors.get(0).getAttributeValue());
System.out.println(colors.get(1).getAttributeValue());
The important line in this code is the xpath.addNamespace(prefix, uri) method. This prefix doesn't have to be the exact prefix used in the actual document (which in fact is not known in most cases).
That's it, have fun with Axiom :)
ATI X1300 with Ubuntu 8.04 (Hardy)
So I tried with the Unofficial ATI Wiki and it worked just as expected. Try method 2 mentioned here.
The great news is hibernation works with it :)
Convert ByteArrayInputStream to String
ByteArrayInputStream bais = // get your ByteArrayInputStream instance
int length = bais.available();
byte [] buff = new byte[length];
bais.read(buff);
That's it!!
@ WSO2, Inc.
I joined WSO2 Inc. on 12th May and it has been few busy days until today :). I am waiting for some build to complete and thought to jump in and blog on this.
I feel life has changed a bit compared with the life at the university, yet it is the same old me sitting in front of the computer :)
