Saturday, February 28, 2009

Remove Solid Border

If you want to crop a picture stripping it from a border of some solid color, in linux you can use convert command which is a part of ImageMagick package:

convert original.jpg -trim modified.jpg

In a case you have a set of pictures, use find command to execute convert:
find *.jpg -exec convert {} -trim out/{} \;

Where out is a directory for converted images.

Monday, February 23, 2009

Extract Config from zImage

It was hard for me to find this simple thing in internet, so I gonna make life for someone a little bit easier.

If you want to extract config file from existing linux image, zImage or bzImage, do the following:
  • Download archive file with linux sources.
  • Unpack linux kernel sources
  • Go into root directory of the kernel sources
  • Run chmod 755 ./scripts/extract-ikconfig
  • Run ./scripts/extract-ikconfig /tmp/zImage > /tmp/config
Where /tmp/zImage is a file you want to extract a config from. And /tmp/config it is a filename for the extracted config.

Sunday, February 22, 2009

Top Delusions About Google Sites

As far as I can see from forums, the most common delusion about Google Sites are:
1. Google Sites doesn't support custom domains. This is not true. Google Sites supports custom domains. You can map any part of google site to any domain.
2. Google Sites gives you absolute freedom to populate your site with legal content. This is not true. For example you are not allowed to use adsense units on your Google Site.

Saturday, February 21, 2009

Google Blogger & AdSense

Blogspot had build-in way to insert AdSense ads in blog. But for some reasons it was not enough for me. For instance, I wanted to leverage channels feature of Google AdSense, but it was impossible with build-in AdSense widget. On the other hand, Google Blogger made it possible to edit a blog template, even insert arbitrary Javascript code. So I decided to go this way to insert my custom adsense code. It seemed to be simple to do, but I wasted 3 hours of my time trying to make it work. For these 3 hours I had been trying to understand why a code generated by AdSense and inserted into HTML Template of my blog didn't work. Instead of any advertisement I saw empty space where an advertisement should be. And even empty space was of wrong size (not the size I chose for the unit). An investigation revealed some details. With a help of firebug I discovered that browser sent a request to and got response 400 Bad Request. Why request was baaaaad, adsense server didn't bother to tell. I compared behavior of an adsense unit that was working and behavior of the non-working unit. I noticed that the non-working unit didn't provide a client id and other info to the AdSense server in request, there values were undefined. The reason for the response 400 was clear now. I suspected that problem could be in javascript code generated by AdSense. The code looked like this:
<script type="text/javascript"><!--
[... something like var blah=blah-blah-blah; ...]

Although there was nothing wrong with this code, I considered to remove <!-- and //--> chunks. The chunks I removed were there just to support old browsers or browsers without javascript turned on. And it helped! Everything went fine. But AdSense prohibited any modifications to generated code. And then I suspected a problem with HTML Template itself, not with AdSense code. I rewrote code to make it look like this:
<script type="text/javascript">&lt;!--
[... something like var blah=blah-blah-blah; ...]

And that worked as well!

There is a possible reason for this. It looks like BlogSpot engine parses template to some internal structure. And then, from this internal structure (DOM tree) it generates HTML code. And the problem is that it doesn't preserve new line characters inside a comments <!-- -->. A browser cuts off this comment before javascript engine begins it work.

Wednesday, February 18, 2009

LooxLight 2007-11-19

I don't know why I didn't write anything about the new version one year ago. But here I am going fix this mistake.

LooxLight is a tool for PDA Fujitsu Siemens C550/N560 (click here to find more information).

In version 2007-11-19 I added a new feature. It was ability to block (turn it off) the device's screen. Before I implemented this feature, I had used wossname program to turn PDA's screen off. But this wossname program had been buggy. So I had decided to implement the same feature in my LooxLight app but make it less buggy. And I implemented it. It allowed me to turn off the screen and block keyboard (including suspend button, that was what no other program could do!). It appeared that with screen turned off, the PDA consumed up to 50mA less battery power. This helped to prolong time I could enjoy music/audiobooks.

Here is the cab file with LooxLight 2007-11-19. Remember that it is for Fujitsu-Siemens Loox C550/N560 and maybe for 720, but I can't give you any guarantee.

How to use. After you have installed LooxLight 2007-11-19, run LooxLight Control and check "Permit blocking" option. Then setup up "Unblock by" keys. Remember, when your PDA is blocked, you will have to press these buttons one after another in order to unblock the PDA. By default these buttons are button 2 and button 4. Then, go to Settings/Button assign "LooxLight Block" to a button that will be used to block PDA. That is it, the configuration is over. Enjoy new feature.

New versions and latest news about LooxLight will be published right here.
Another project helps reduce power consumption on Fujitsu-Siemens Loox N560/C550.

Tuesday, February 17, 2009

text & jdbc & sybase

If you see the following error: "A wrong datastream has been sent to the server. The server was expecting token 236 but got the token 33. This is an internal error."

Then it means that you haven't sepcified the correct jdbc type for a column. If you use iBatis, the proper insert statement should look something like:

INSERT INTO users (login_name, description)
VALUES (#loginName#, #description:LONGVARCHAR#)