Thursday, November 8th 2007


Windows much slow to handshake on tcp port 3306 compared to ubuntu’s
posted @ 14:00 in [ Programming - geek ]

Really! Thats what I just noticed. The test machine #1 is my XP has no firewall, is a 1Gpbs intel ethernet card on a 100mbps network. The test machine #2 is a ubuntu 7.04 workstation again on the same network as me with its own static IPv4 address. The great server is also ubuntu 7.04 with mysql 5.x. Now the case noticed was that telnetting from my xp (#1) to server at port 3306 took least 6 seconds for the handshake response from the mysql server. Telnetting from the ubuntu (#2) to the server at the same port actually responded the moment I pressed the return key. Ethereal’ed the whole transaction to find what strange in #1 TCP packet and the #2 TCP packet. Did not notice anything great. Googling on this also did not result any problem of this sort. But the results are true. Ubuntu connection to 3306 is taking under 5ms compared to XP which is taking least 6000ms. There are no slow down process running except maybe TeaTimer.So makes me wonder. Im sure no guru in TCP so i can’t dig more on this.

The reason why we had to conduct this test in my office is cause of a typical development floor setup. There is just one Mysql on the network and clients use their localhost apache’s to connect to this remote server. Server ping takes around 0.3ms with no loss. The guy on XP was killing himself due to the delay it took for his localhost to render php database pages. The other guy on ubuntu was on mercedes. His apache ran like he owned everything on his machine itself. So there it is. Since google did not report any similar case with anybody else, I await if someone can share this case. Cya!




Sunday, April 15th 2007


My First VB4
posted @ 13:52 in [ My First - Programming ]

It was a small handbook I got hold of at Ramakrishna Mission Institute of Culture, Gol park, Calcutta around 1998. The book was Visual Basic 4 Tips and Tricks or something like that. Then I had just started my NIIT’s GNIIT course. The first semester had started which was about DOS and all other crap. I had good knowledge of QBasic syntax before this. Anyway I had done lot of DBase III Plus programming and even played with C using the K&R - The C Programming language. Therefore, the syntax and fun that I learned from book got me excited to play with real VB4. That was the first time I had made windows program and a MsgBox “Hello world”. Wow. I had learned this too easy language syntax for RAD within the next 3 months. We had a picture box. A grid based windows form editor. Later in after an year I had to enter Visual C++ SDK programming followed by the official study of RAD using VB4. ha.




Friday, March 30th 2007


The pain of goto statements in c#
posted @ 13:02 in [ asp dot net - geek ]

Here is another account of a very irritating experiance I had with the c# language. A guy from C really has to struggle with stupid non-geek compile errors. check this code. This was very correctly written for C. All i wanted to do was save my object code with duplicate code.

if (Request.QueryString[”CID”] != null)
CategoryID = Int32.Parse(Request.QueryString[”CID”].ToString());
else if(artwork_id>0)
{
CategoryID = Artwork.GetArtworkCategoryID(artwork_id);
    goto tr;
}
else
{
CategoryID = Artwork.GetCategoryID(ArtistID);
tr:
Server.Transfer(”work.aspx?AID=” + Request.QueryString[”AID”] +
“&CID=” +CategoryID + (debug?”&debug=true”:”"));
}

all that compiler said was  error CS0159: No such label ‘tr’ within the scope of the goto statement. I do understand that jumping to other code is to be done carefully.  you might skip some variable initialization or derive into some invalid stack. Having siad that, an average coder would know all that. Therefore, jumping to any code using goto should be very much allowed by default.




Thursday, March 15th 2007


first week with typo3
posted @ 12:27 in [ My First - Programming ]

Setup is easy. Graphics are neat. Documentation is good but with not beat for first timers like me. I have had experiance only with EPiServer before this one. That is a windows dot net CMS. Its fair but besised being closed source, it ignores the performance aspects. TYPO3 is open so we can’t complain. :) (I like this feling). Has template support and also a nice typoscript language too. The language is very simple just like advanced configuration script. There are loads of extensions too.

It took 3 full days by the time I could run my first few page with one most simple menu and a simple template. That was fine till that point. Beyond that, I need my own custom menu and very complicated templates. Documentation for doing these is very less. I have to figure out the trick based on what what expansion API are supported. Tutorials are good but none for thinking differently.

Today is day 4 and I have got to finish the menu hacking exersize. I need to compose my own menu with my own choice of wrapping tags and content as already built images.




Saturday, March 10th 2007


MySQL Case Insensitive Optimization
posted @ 11:20 in [ Programming - geek ]

This trick was developed in one of my biggest database. It has 7 million records with 160 fields each. Half as text fields. the size of database after converting to best field size and database had come from 17GB (raw fixed width text) to 5GB MYI with neat RDBMS. Data was 35% while indexes were 65%. It was like this for best search performance. Now the text data like First Name and Last Name were problems. They take ~25 letters each and indexing them was not solving most of the problem.

I knew MySQL like operator was case insentivite. This may sound like good news but it’s not. For every search it anyway has to setcase the field of every record before applying the search function. MySQL is very good in group indexes. Suppose you are searching for vehicle type 17 and widht as 19, a index which uses both will have better performance than index of both independently. Secondly, fixed width indexes are too fast then character. Numeric comparisions are even then varchar comparisions. My problem was to search First Name matches.

The trick uses all the ticks together.

  1. I made fiurst three letters to upper case.
  2. I converted first three letters into a 16bit integer (field F).
  3. Created field L as the balance letters from first name.
  4. Created index A with field F as the first and field L as the second.

VOLA! Mysql loves me. Explain listed that to scan a particular first name, it did not need a table scan any more. First three letters used to make the scan into very small number of records. Also first three letter were index therefore easily approached from the index.

There must be a question of how was three upper case letters converted to 16 bit integer. Well, it was 15 bits that were used. :) 26 possible letters means 5 bit scope. Multriply that with 3 letters and we have 15 bits.





Thursday, March 8th 2007


Firmware SDK
posted @ 13:14 in [ Electronics - Photography - Programming - geek ]

I’m badly looking for a method so I can extend or create my own firmware for the camera of my choice. All camera have their own RTOS and hardware. Therefore I should not expect same SDK for many camera companies. But I can expect same SDK for many models since same companies very much use same environment. More critical than anything is that the manufacturers hate to offer any such feature. I have a Casio EXILIM EX-P505. The camera is very good. I can’t say that more. Its so good that I want to extend it. I use it for Time lapse imaging. If I could automate the clicks for every 60 seconds or so, it would be very easy to do such photography. Yes, web cams can help me on that but web cams are very low of resolutions. Added they will need a whole computer along therefore no portable at all. I have been googling a lot for my cam model and few others but not found any crack to the problem. Some have parsed the firware update and split the files into ROM and JPG and music etc. ROM is assembly compiled written most likely in C. Reading the ROM of my casio i find paths as A:. Means the RTOS is very much like DOS STDLIB. That is good news but again getting a compiler or decrypting the compiled code is going to be hard. Then there are other problems as missign documents and interrupts. What button does what. How to trap events. All will have to be reverse engineered. Pain Big Time. Its sure possible for Pro. And thats not me! So I wrote this blog so anybody of similar interests or with leads on thsi topic can have some thoughts. I will write more on this topic soon.

Blogged with Flock




Sunday, August 27th 2006


General Public Licence v3 (draft 2)
posted @ 00:33 in [ Programming - geek ]

The first software licence which I had actually read and enjoyed. The days were of DJGPP. I needed to compile C++ and all I had was win98. Every software came with a CPOYING file. Did a edit and began reading. Just so you don’t know what it is, here is the draft you can read. v2 has been here for more than a decade. With new patent and DRM issues coming up in EU, v3 is attempting to include vaccines for those too. you might also like the new concept of copyleft, which is exactly what you think it is - opposite of copyright.




Friday, August 4th 2006


firefox fix to height as 100%
posted @ 15:11 in [ Programming ]

the page was a strict xhtml. the design was tableless. IE was showing my left menu with all available hieght by the parent. Firefox was not. poor FF i’d say. (if it was IE, i would have cursed it. cheating huh?). The solution found after a simple googly. FF is inheriting the available height. so you would have to give 100% from the top to the bottom of the element tree.

html, body, #mainsextion, #leftmenu {height: 100%;}




Friday, July 28th 2006


CSS float, center and float bugs
posted @ 15:59 in [ Programming ]

The approach is to have the left and right nav bars floating while the center on the baseline. This approach makes sure that baseline is not lost till the bottom of the page. Both Firefox and Internet Explorer aparently are treating this apprach with their own ways.

We give width to the left and the right bar. Incase the width is given to the center as well, the behaviour starts. Firefox will render it from the left most pos regardless of the floating left. The patch is to give a margin-left. IE will render a strange 3 pixel left adn right padding which in spite of anything you do won’t go. There is not known solution to fix this.

The only way no to get into this trouble is never give a width to the center block. Everyone will be happy that way..

Cheers.




Tuesday, July 25th 2006


Strict XHTML won’t load CSS file
posted @ 11:35 in [ Programming ]

Why was my strict XHTML page on a webserver not loading a external CSS file. The reason found was that the content type returned by the server on my CSS was text/html. in strict mode, just declaring the type in the LINK tag is not enough. Even the server has to return a happy content type as text/css. Once it did, all worked out. I know this info was a waste for those with IE.