Wednesday, September 12, 2007
How to use MS Excel sheet to track portfolio
Then I thought how nice it would be if I can use it to calculate my capital gains from this sheet given the transactions. So I learnt some excel programming to come up with very crude way to do it. You can find this excel sheet here. And I have created one ppt with screenshots telling how to use it. You can download it here. Please let me know your feedback at my email id purohit under score arvind at the rate of yahoo.com
Wednesday, September 5, 2007
JPEG Encoding
Its quite long time since I blogged about what I am learning. Blogging should be a regular job. And regularity is toughness. Anyways here is what I have learnt today about JPEG Encoding
JPEG Encoding
JPEG is a lossy image compression and it exploits two limitations of human vision system
(1) We are more sensitive to brightness then the color
(2) We are more sensitive to color change at lower brightness over large area then at higher frequency brightness.
So to exploit it we do following things
(1) Convert RGB color space to YCbCr model. Then reduce Cb and Cr component by as much as half! Thus use limitation (1) listed above
(2) Now split images in 8x8 blocks.
(3) Each of the Y, Cb, and Cr component of this 8x8 block goes through DCT phase.
(4) Then we quantize the output of DCT.
(5) Once quantized we know which part belong to high frequency brightness and which one belong to low brightness. We compress high intensity component more aggressively or may discard them altogether. This is the step in which major loss of information occur in encoding. Here we are exploiting limitation (2) listed above
(6) Remaining components are encoded using lossless compression technique like Huffman Encoding.
Note: YCbCr is color model in which Y stands for Luma(brighness) and Cb and Cr stands for chrominance for blue and red.
Question: What is DCT? You can explore more on it.
Decoding should be the reverse process of it.
Friday, May 4, 2007
Shape changing dialogs in QT4
I was not able to get QT4 book so I started learning from QT3 book which is freely available. Now when I started reading chapter 2, it talks of self changing dialogs. But here I had to spent a lot of time! The book which is based on QT3 tells that make “resizeMode” property from “Auto” to “Fixed”. But I did not find this property in QT4 at all! And I tried all the permutations and combinations of size of all the widgets.
But then I looked in one dialog example. Here I saw that top level grid layout should call setSizeConstraint with argument as QLayout::SetFixedSize. And when I did this code change manually in ui_sortForm.h it worked liked magic! [Note ui_sortForm.h is generated by QT Designer from sortForm.ui file]
One thing I don’t understand now is how come you cant change top most grid layout’s property in QT Designer? I may find out more about this when I learn more about QT.
Thursday, April 12, 2007
Finally got QT working in office computer
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
Wednesday, March 28, 2007
Cygwin g++ error!
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/../../../../i686-pc-cygwin/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
Go though following steps.
First try to find where you /usr/lib is mapped. Use Cygpath -w /usr/lib
Above command would tell you the windows directory path where /usr/local/lib is mapped. Go to that directory. In my case it was c:\utils\cygwin\lib. cd into this directory. And search for file libstdc*. You would get a file named libstdc++.a.2.10.0. Create a link named libstdc++.a for the same file in this directory. Here is sequence of commands.
C:\> Cygpath -w /usr/lib
c:\utils\cygwin\lib
C:\>cd c:\utils\cygwin\lib
C:\utils\Cygwin\lib>ls libstdc++*
libstdc++.a.2.10.0
C:\utils\Cygwin\lib>ln -s libstdc++.a.2.10.0 libstdc++.a
And thats it. And even if above trick does not work, try creating link to libstdc++ in directory given by cygpath -w /usr/local/lib.
The problem is g++ can not find out libstdc++ on its own, it needs to be told about this. Here are more threads on this.
http://ubuntuforums.org/archive/index.php/t-15120.html
http://gcc.gnu.org/ml/libstdc++/2002-05/msg00353.html
Monday, March 26, 2007
Undefined referrence to 'vtable for MyWidget'
I had put the class definion in my .cpp file and was struggling to get it compiled. But it would never compile and throw above compiler error along with some other random erros. When I googled, I got below link
http://www.qtforum.org/article/302/Fixing-undefined-reference-to-vtable-.html
Sometimes the linking stage of compiling might fail with the rather confusing error:
undefined reference to `vtable for MyWidget`
So theme is don't put class definitions in .cpp files when they have the Q_OBJECT macro.
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
Darwin Server from Apple.
(1) You need to install DSS. Once it is installed, it would ask you to create admin user name and password. Do that. If all is okay it would start the server. In my case it was not so I had to close the command prompt window [because of perl]
(2) Since I have Cygwin on my machine [The very reason my QT cant be compiled ;)] I could not install DSS, since it works only with Active Perl. So I had to install Active Perl and then had to remove " Cygwin Perl"'s path from my Path.
(3) Then associated "Active Perl" with all .pl files through file assocication. This is not a problem once Cygwin Perl is removed from path and you click on some .pl files, windows would automatically ask you which program to select to run this. Just choose Active Perl.
(4) On two command prompts I had to run DarwinStreamingServer.exe -d [NOTE :: DONT forget "-d" option from command prompt] and streamingadminserver.pl.
(5) Now your server is up and in your web browser you can type http://your.ip.add.ress:1220. It would open DSS Server Admin. Enter your userid and password which you created in step (1).
(6) Now comes streaming part. Remember that by default your media directory is c:\Program Files\Darwin Streaming Server\Movies\. So in case you want to stream some mp3 files put them here. Also dont forget to go to "Port Settings" and enable Port 80, in case you are behind firewall and intend to listen to this server from outside your LAN.
(7) Create Playlists. Go to Playlists on your left pane, click on "New MP3 Playlist", give your playlist name like "sample" and give it a mount point "sample". Now you would see all the mp3 files below it. Add the files you want to add.
(8) Now dont forget to choose your Playmode. NEVER set it as sequential. Or else once all the songs are played, there would not be any thing on your server. I chose "Sequential Looped". And thats it!
(9) Go to Winamp and type http://your.ip.add.ress/sample and you would listen the songs.
Foolishness which I did :- Created a mount point "/", added one file called "sample.mp3", chose the play method as "Sequential" and was trying to access http://my.ip.add.ress/sample.mp3, which of course would not work!
Now I would try to set up straming movies server and then would see if it works too! Meanwhile I have thought of bringing precompiled QT libs from my home laptop and put them on my office PC to see if QT can then be make workable!
