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.
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!
Thursday, March 22, 2007
RGB Vs YCbCr , Static Globals not allowed in BREW
I presume you know RGB. Any image is made up of two components, brightness and color information. Brightness information is high frequency information and color is low frequency information. Human Visual System (HVS) is more sensitive to brightness then color. Means it can identify brightness more better then change in color.
Chroma is the color information of the picture. It is determined by seperating luma (Y) value from blue and red signal. If you need a quick formula here it is
For taking advantage of this YCbCr model was developed. In this Y is calculated from weighted R, G and B. And then Cb and Cr are calculated. Then Cb and Cr are comressed more aggresively then Y.
If same principle [compressing low frequency color information] is applied to RGB model, image would not be of that quality as of JPEG. This is the difference of RGB and YCbCr.
Sources
http://www.impulseadventure.com/photo/jpeg-color-space.html
http://en.wikipedia.org/wiki/Ycbcr
Why static and global varibles in BREW dynamic apps are not allowed ?
Very crude reason : There is no data section in .mod files created by BREW. Static variables are allocated in data segment of programme. And they are offseted from a global "SB" static base register. Now BREW loads application anywhere in memory so if it were to allow static variables it would have to remember SB for evey applet which apparently BREW does not want to do. Though there are some hacks for it. For more information search BREW forums @ Qualcomm.com
Meanwhile Linux server in our company location is still not up and I am waiting for it to compile my QT code.
Friday, March 16, 2007
Telnet to Internet ?
But the servers mentioned there were too out of date. So I again used google to find out Free Linux Shell Account.
Lets see if something works out here! But list here seems to be quite latest. I tried the a/c available with http://www.freeshell.org. It is pretty simple you just type the command telnet tty.freeshell.org on your command prompt. If you are a new user type in "new" post some text screens which you should read you would be able to create your linux a/c. So even if you are using Windows, dont have Linux installed but want to learn some basic Unix this is great!
But you can not use all the commands on this server unless you give around 5 USD to them. Also you can not do stuff like exporting display on the server to your local machine and then launching some graphics application like Netscape navigator or any thing. That means I can not run my QT applications there, even if I am able to somehow put my QT there. Too bad! So let me stop this thread, but I learnt some thing new today ... and served the basic purpose of this blog.
Next three days we have a big week end so may be I would not be learning anything new on next three days :)
Thursday, March 15, 2007
Mocha X-Server
Now another problem. Looks like I need root permission to install QT under Linux ! At least thats what the INSTALL file says. It says ..
To install the library, demos, examples, tools, and tutorials,
type: su -c "make install" Obviosuly this would need root permission which I dont have. So let me search google to see if I can install QT without being a root!So I posted this question on QT news group and got a very quick and early response. They told me that I can use ./configure
./configure -prefix $HOME/qt or ./configure --prefix=/home/arvind/qt-libs
Now when I tried to do that I figured out there is some problem with my office linux server. It is not even compiling a simple .c file. It is fuming with "cc1: No space left on device: error closing /tmp/ccpDlsaM.s" error. Directory name after /tmp is completely random. Meanwhile IT has reinstalled my Cygwin. Looks like I am much closer to have QT run in office environment!
Still trying to run QT ..somehow... Also learning QT.
(1) Install MingW and have it live peacefully with Cygwin, then use MingW to compile QT.
(2) Try to compile QT with just Cygwin.
(3) Login to company linux server, run QT apps there, export the display from there. On Windows PC run Cygwin/X.
I had already exhausted options (1) and (2). I spent a lot of time on that. And while working on (3) I corrupted my existing Cygwin which we need to compile my offical project :). So I logged call for IT ops to reinstall Cygwin. I would also see if they can install Cygwin/X for me. If that happens then I would just have to take care of installing QT in my linux home directory and wow!
Meanwhile I searched google for some other free X-server for windows and I got a link where it was mentioned that there is X-Server called X-Deep which is free. But when I went to their site it was mentioned that Free version is no longer there! I installed 15 days trial period! So now first hurdle is gone at least for next 15 days I can run my xserver and may be even QT applications! Now let me try to install QT in my home directory!
Lets see what happens.
Meanwhile I have also started learning QT. Going through world of Signals, Slots and Widgets. Coming weekend is a big weekend so am hoping that I would at least be able to make some simple programs in QT once this weekend is over! Amen!
Also I am uploading my remaining photos on photos.yahoo.com. Great to see the technology advancement. I am planning to take backup of my entire photos on yahoo photos. So they are kind of permanent.
Wednesday, March 14, 2007
Cleartext property
10 things you should do to every windows PC ( http://builder.com.com/5100-6404_14-5906772.html )
I especially liked Turn on ClearType and adjust Desktop settings. Here are the things you need to do ....
1. Right-click on the desktop.
2. Go to the Appearance tab.
3. Click the Effects button.
4. Check this option in the Effects dialog box: Use The Following Method To Smooth Edges Of Screen Fonts.
5. Select ClearType from the drop-down box.
6. Click OK.
Above text is taken from http://articles.techrepublic.com.com/5100-22_11-5100472.html
Now I am trying to install Cygwin/X on my Cygwin installation. With this I intentend to export my linux machine to export its display to my Windows PC. And then I would try to run QT applications on my linux server. LEts see how it goes!
OH NO !!!
My previously installed company provided cygwin has gone!! I dont seem to be having a directory named C:\Cygwin!! And when I run any linux command line ls I get the error . Whose text is "The procedure entry point __getreent could not be located in the dynamic link library cygwin1.dll" ... Again one more call to IT.
Looks like I am still a long way before I can install Cygwin/X and run QT apps either on Cygwin or in linux server. Going for break now !!
Trying to run QT on linux.
So I gave hope of compiling QT even on Cygwin! But not running QT. Then I remembered that our company has some linux server as well. Now am trying to login to linux server.
Oops I forgot the password as last time I logged into system was two years back ! So I raised trouble ticket with IT. Am waiting for that ! Meanwhile I need to download XFree server so that I can export display on my telnet session to my windows PC so that I can run QT app in telnet session! Hope this works!
Trying to compile QT under Cygwin.
So far I am not able to do so. I am getting an error saying ....
In file included from generators/makefiledeps.cpp:30:
../mkspecs/win32-g++/qplatformdefs.h:45:21: windows.h: No such file or directory
Then I opened file qplatformdefs.h and saw that it is able to include many files. like tchar.h. So I did a global search of tchar.h in my C drive to find out where the hell this guy is picking tchar.h from I would put the windows.h in same location. [Of course I did dir /s windows.h in C: to find out there six copies of windows.h in my PC !].. Lets us see where are all the places where I find tchar.h
Meanwhile another idea strcuk. I figured out that mingw32-make was coming from C:\Mingw\bin. I removed its path from path variable. And copied mingw32-make.exe to C:\utils\Cygwin\usr\bin. After that I found out that it started cribbing about tchar.h.
Then I copied windows.h to c:\mingw\include where tchar.h was there and then add c:\ming32\bin back to path. Then it cribbed about lots of other .h file like windef.h etc. etc. I copied them from c:\utils\cygwin\usr\include\mingw to c:\mingw\include then I got following error
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:432: error: `__gnuc_va_list' has not been declared
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:433: error: `__gnuc_va_list' has not been declared
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:434: error: `__gnuc_va_list' has not been declared
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:435: error: `__gnuc_va_list' has not been declared
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:467: error: `__gnuc_va_list' has not been declared
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:469: error: `__gnuc_va_list' has not been declared
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:471: error: `__gnuc_va_list' has not been declared
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:473: error: `__gnuc_va_list' has not been declared
and still I am struggling to compile QT under Cygwin !!!
