wpe7.jpg (11495 bytes)

我的征尘是星辰大海。。。
The dirt and dust from my pilgrimage forms oceans of stars...

----Memory could be deceiving, impression could be misleading, only can we rely on digital storage for our total recall.

2011


30/01/08

What a shame! The only available tool for png file is "libpng" which is as ugly as "ijg". I spent a whole day to compile and made a small adept for convinience. Here it is zlib which is required for libpng

08/02/08

What is new?

19/02/08

int x=10; ++x=x++; printf("x=%d\n", x);

What is output? I said 10, microsoft said 12, Linux said 11. What is your answer? I think this is a purely compiler issue. Imagine that VC++ simplifies "x=x++;" to be simply "x++;". And if you believe x=x++; is equal to x++; then you may not find surprised about x=12. I tried vc2005 and change optimisation settings, but it remains 12.

(WH informs me that x=x++; is syntactically nonsense to C++ standard because they don't think it makes senses. Therefore it is up to compiler to decide what they are going to do. In VC, it translates into x++. That is why x=x++; is different from y=x++;)

The phrase "the pursuit of happiness" is originated from "Declaration of Independence" and it is used as a film title which reflects the "American Dream" of many common people. It took American eight years and tens of thousands of lives to pursue their independence and for a common mortal such as you and me it may take more. So, naturally I am not happy now because I am in the procedure of pursuit of my happiness which may never come even till the end.

ok,ok, finally I read the STL careful enough and find my solution. If the system doesn't support set<T>::insert(set<T>::iterator, set<T>::iterator); then you can use this "copy(set<T>::iterator, set<T>::iterator, inserter(set<T>, set<T>::iterator));". Isn't it a lovely solution? I get this from the book <C++ STL> by Nicolai. The heap is very neat.

25/02/08

There are countless problems waiting for you in TopCoder and I am pretty slow in coding. Here are what I have done in past few days.

12/03/08

Question: Should Http server be stateless? Why is HttpHeaderKeepAlive not working? Because it is, quote "massively misunderstood", end quote. By default http1.1 allows connection be persistent unless client asks to stop. My mistake is to assume "request id" remains the same between requests which is wrong.

Windows Live starts a new free service called "sky drive" and it gives me a chance to store my project there because I really run out of my space in this web hosting. Sadly I think I will not continue my little GDI SDK(I called it for myself.) Let's save it here for future.  In my home old computer, I start a purely C-based web service. It is using "my SQL" C-API to access database, using "windows httpAPI" to implement the simplest http server. Currently it only concentrates on binary files web browsing which I think is only challenging part for me. So, in all, it is a purely C program. (http server part are mostly borrowed from MSDN sample, but I changed and plan to change a lot.)

This is a stand alone "MySQL" access project which also acts a dataset inserter. By the way, it calculates MD5 of file as a signature to make sure no repeat picture or music is inserted. Of course the MD5 part is downloaded from wiki, but it is not that complicated.

My HttpServer+MySQL kit requires a small thing for compiling. It needs http.h+basetsd.h(replace) from "platformSDK". PlatformSDK is supposed to be compatible between VC6 and VC200X, but you need to update the "basetsd.h".

By the way, here is my experimental web site with my home old computer.

25/03/08

Finally I finished my multi-threaded version. It takes me so long because I am quite busy and the conflicting problem between VC6 and platformSDK takes me about one week to fix. Now it is a stateless http-server with one listening thread + multiple DB threads. Here is the backup. And here is the server, (The content may contain nudity and mature material, viewer's discretion is recommended. The purpose of this website is purely for research and doesn't represent my viewpoint.) :  http://nickhuang99.dynalias.com

02/04/08

This is very educational and I copy the discussion here for future reference!

24/04/08

OK, this is tough, the routing is really complicated.

The server-2102 is somewhere with an ip of 205.205.105.114:59102, I guess this is a kind of proxy server which redirect to its real ip or even it is running as windows server virtual machine. (just a guess.)

I can access it through this by VNC, however, if I need to upload file, it is a kind of difficult.

So, I run winscp from VNC and connect to so-called pier1 server which is mci's gate or something. Its ip is 66.199.179.39:22 and this is the common place I can also exchange files.

Say, I am running winscp locally to access this pier1. and also run winscp within VNC to this.

The reason for this, I guess, is that 205.205.105.114 is a kind of web-server routing service.

And on server 66.199.179.39 has this sftp service.

Then, how do I find this?

In VNC, I run winscp and go to the default place which they saved the session, named as pier1. In that "pier1", I run a command within winscp which can not accept user input, just displaying info, say "ifconfig". I noticed that the ip is 66.199.179.39 and plus a lot of multi-cast stuff.

DC is almost driven crazy by Raja because I think this is really a nightmare for all programmer. You see, he is doing his server in virtual machine of windows server running on winXP and later he tells me that it is a big mistake to use NTFS because there is a lot of security issues. The new version of server keeps crashing while the old one is running OK. Almost everything can be the reason. The security, the certificate, the registry, the environment, the dll, the tlb, and of course his new code which uses some windows hook to do something and the service, the server, etc...I can see he is a kind of crazy as he said this is his worst bug and I believe it because for any programmer who doesn't obey those rules of server programming this is the price to pay. The session is running somewhere you can only watch with VNC which is quite difficult to debug. And finally he asks to bring those server physically back to office to be connected by KVM. I saw him installing VC6 in those servers for tracing before I leave office. This seems the only convenient way. The strange thing I noticed about service is that it can start by "system" or by my user. This is also something I don't understand in cluster. Those remote sessions are started and later are failed to be shut down, living as zombies.

My eyes hurt.

27/04/08

OK, finally I finished some feature about my picture browser. The permanent domain name is http://nickhuang99.dynalias.com .  The source code is here.

Thank you so much for your tips about firefox and I think I just fix the problem. You know, firefox seems to me like baby toy which doesn't even do a simple guess work as IE. If you give it a picture file, firefox doesn't even try to check what type of image or even check if it is some image file like bmp, jpg, png etc.
I didn't give a correct character encoding about html which is utf-16 and firefox simply assume it is ansi char, I guess. Now please try it again.

07/05/08

The old mission: DC wants me to make a debugging tool such that it uses pipe instead of socket to recv server data and shows exact image of client.

1. Instead of using standard pipe, I choose named pipe which allows more flexibility between processes.

2. Instead of restructure client/server project to compile a new modules which uses both codes, protocol, configs between client/server, I choose the easy way--only using dll'export functions from client so that compilation is not an issue. Also, I don't have to merge different data structure between server/client side which is really a painful job. No one expect namespace of server project will conflict with client side.

3. To allow emulator run exactly same as real device, you need to setup emulator exactly as device. DC is not doing this properly as his "real" emulator of device is written in VB and not easy for me to read code. I decide to intercept all function calls from VC gui to a "padcore.dll" which implements all "drawing", communicating logic in C. So, I hardcoded the configure for real device and then use them in my "emulator".

4. The pipe communication is running in non-blocking mode ONLY after socket communication with "real" emulator of device receives successfully so that it will not impact performance of real session as much as possible. However, within the same server process, my fake emulator conduct twice pipe communications so it is a kind of slow. The first is from server to "padcore.dll" and then from padcore.dll to window in server. Note, padcore is part of server process now, still we use pipe to communicate because we don't want to change too much code along with socket asynchroneous communication.

Now, DC wants me to solve the "old cache" issue.

a) To check if the device and my emulator are using same size cache size.

b) To synchronize the cache memory between real emulator and my fake emulator, he added that this tool has more meaning than simply check same image between server/client because he wants to check the cache mechanism. This makes much senses to me !

volatile is a solution against compiler optimazation error, but as long as there is some assignment operation, compiler should NOT do optimazation. so it is NOT necessary to use volatile. When debugging, outputdebugstring is very handy. And output to log service is sometimes the only way for debugging, say service.

25/05/08

save stable version of my three little projects. httpserver-stable httpClient-stable  mySqlTools-stable and here is the small trivial handy tool for md5.

01/06/08

Now it is 100k pictures and just guess how soon I can make it one million?

09/06/08

Congratulations! The number of pictures reaches 200k.Within 24 hours, I placed more than a dozen of spiders and the most lucky one grabs almost 50k pictures from one website. In total, they collected about 150k pictures for me. Of course many of them are actually replica which I already collected before. You know, guys in China are doing the same thing as me to collect picture all over the world. DC's tip is that file name starting with "\\" will be saved in root directory and this is better since you may not know where to find your program running. He also mentioned about "getsystemdirector" which maybe different to "getwindowsdir". I never used them, but it is always good to know. Driver has a lot of to read and it is interesting.

01/07/08

Congratulations! The database is approaching 400k! And my three tools are all upgrading.

a) httpclient now uses mysql to store links so that in near future spiders will work in groups and they can be specialized to work as pure link-finders or image-downloaders. There will be no memory limit, no time limit. i.e. I can shut down any program without losing all data collected.

b) httpserver now has a better user interface to allow you browse one picture step or one bunch of pictures step. (This sounds trivial? Yeah, not too much to improve server side.) I use port 1000 for internal testing. http://nickhuang99.dynalias.com:1000/

c) mysqltools now has a new function to add watermark to each picture and I keep the original picture in tact so that later the picture can be reproduced without watermark.

09/07/08
 
DC has a small tip for debugging release version by adding debugging information into release version. Also you need in c/c++ tab, add program database.

OK, according to DC, there is no significent difference between debug and release version because you can make a release exactly debug or verse versa.

1. optimization, both you can do

2. macro: debug/assert etc. you can do.

3. debug info/ program database: you can do.

What else? Oh, maybe debug library is different. yes, they are different. In release/debug mode, you are linking to different library.

17/07/08
 
The real artist lives in that narcotic moment of creative bliss. <The Art School Confidential>

Let me repeat the line of Blackadder: Without you the life is like a broken pencil: pointless. I think I have recorded this sentence before.

03/08/08
 
There is a big flaw in my spider program because of encoding. You see, some Chinese moron add Chinese characters inside their links and my parser can only deal either pure ansi or unicode strings. (Or more probably they are using utf8 and I simply don't know how to translate them.) Now I can only assume they are mixing ansi and gb2312 together in their links and try some experiment. Before that this is the latest version of spider and decription of database.

17/08/08
 
I think the only solution for encoding is to translate gb2312 into unicode by "multibytetowidechar" which is a windows API, then parse html document by my little parser. I believe google or all other spiders should do it this way. So, here comes my httpclient-6.0.

16/09/08
 
What a life of mine. I have heard more of my sighs than seen my signs. My eyes used to be blind because I didn't realize I should use more of my ears. This is a simple common sense. Which organ is developped first, eyes or ears? Obviously the second ones as sound signal is much simpler than picture one! Is this difficult to perceive? Why am I so obscute?

20/09/08
 
Finally my database hit one million and now you can really call it "millions of Asian chicks".

23/09/08
 
700Billion US dollars bail out! Wall Street has hijacked US Administration by frozen money market and Administration is playing "show-hand" game with Congress to ask for a worse choice from worst choices. Who is bluffing?

28/09/08
 
Plan: cloud computing of GO. 1. Which is faster, searching or computing? No idea, so do both.
2. How to store? What to store? Go-map=361bytes. Index? md5=16bytes.
3. What to store? sequence of md5.
4. How to find server? each md5 is a table? too much?? a record with unique key? record: key-md5, next-md5,data , gateway hash md5 to map ip of relative server.

5. How to run? search or compute? both.

6. Is it possible? No, because too much data. How to do? abstract map to converge data set to one. (forget details.)

02/10/08
 
Big Brother Is Watching You! Here is my first jitty version of small project. If you allow it running and if my server is running, then you will see on my server what your desktop is like. So, basically speaking it is peeking your privacy. Gosh, I hope I can make some kind of trojan horse to plant it in your PC. And of course the server side needs more improvement.

06/10/08
 
Big Brother Is Watching You!  After the first prototype I then remember that Intel ijl15.dll is used as running dll. This is inconvenient for deployment, especially you consider the size of file to download. So, I just rush to use my ugly modification of IJG lib. Then the "peeker" will only be about 130k running in "no-window" mode. Maybe in future let's make it a service??? (There are three sub projects: myPeeker is the client deployed in user PC; staticIJG will be a static lib used for compilation of "myPeeker"; bigBrother is the server running in my server PC.)

12/11/08
 
My first spyware or trojen.

16/11/08

I am wondering and pondering, cannot figure out ends or means.

They are such beatiful lines and I have to repeat them by heart whenever I watch the movie.

I’ve been watching but the stars refuse to shine
I’ve been searching but I just don’t see the signs
I know that it’s out there
There’s gotta be something for my soul somewhere

A temporary version of my resource injection, or infection.

14/06/09

This is a simple tool and it can be treated as a little practicing for STL. And for those kids who claim they know how to program, it would be some kind of fun.

10/09/09

In order to remember, I need to forget and when I forget details the abstraction emerges.

27/09/09

Suppose you are feeling extremely bored with your tedious life and have infinite free time to kill, it is only then recommendable to read these garbage.

05/10/09

I wonder if the percentage of population is above 0.001% in any country who enjoy and understand this marvellous political satire series. Yes, PrimeMinister. Yes, Minister.

19/10/09

As ring bearer, you have to be alone.

28/10/09

Life is a kind of meaningless here and I don't know why I stay and how long I am going to stay. I do miss Canada. Maybe the only good thing here is that you can do your jogging along bus line in winter so that you can save s few coins and relieves your mind from thinking. In Montreal, you don't have to try this hard by running 5km because the chilling wind will make your brain totally numb for working. However, the effect is similar. Give me a reason to stay or to go, not just some pathetic excuses.

10/02/10

A true artist only lives in his narcotic creative moment of bliss. ---from <Art School Confidential>

I say there exists only one law in China, the law of jungle. The only evidence of human civilization is that the winner does NOT take the loser's body as food.

I say the PRC stands for Preparing the Rising of China. However, whenever there is a rise of power of country in each century accompanied with some significant discoveries or inventions, such as new continents, steam engines etc. What on earth do people of China discover or invent? Just as Mr. Bill Gates says, China discovers new ways of capitalism.

21/03/10

Ticket is booked and I am doomed to be back to Canada on next weekend. Back to home? Back to track? Home is becoming such a strange concept for me as I have to apply tourist visa in order to stay here. Can you call this place my home town? Even though I speak the so-called mother tongue, I feel I don't understand what I am talking about. A minute ago, I woke up from nap in crouch while watching CCTV channel 9 which is introducing an American-Chinese or Chinese-American musician, Kaisser Kuo. For a few seconds, I wasn't sure where I was when I woke up. Now I understand this sort of typical feeling when you just wake up from a dream.

26/04/10

Ticket to New York cannot be booked until the documents are received as I am not sure about the visa at all. Funny? Isn't it? How should I describe my own private wish? This is a typical speaking in <Yes, Prime Minister>:

Certainly one doesn't have ambition to seek money as one always place one's life achievement before one's wealth. However, if one's best interest for one's life achievement is to seek one's fortune, one might take that direction persuaded by one's friend or any interest group no matter what one's own private wish might be.

And if you know the context, you understand what is called pathetic.

26/07/10

I think condor is a kind of joke as they claim to run in heterious platform. Then there must be a simple answer to my simple question: how to let condor run job in windows while central manager is a linux machine?

condor simply doesn't work for the easiest job submittion!

1. condor_submit will automatically add those garbage "requirements" which I don't know how to remove. Even I try to overwrite them, it doesn't seem working.
2. condor simply does a stupid thing to create "log" messed up with linux/window system. see below,
"Hold reason: Error from slot2@192-168-1-2.rendermax.com: Failed to open '/home/nick/work\runblender.out' as standard output: No such file or directory (errno 2)"


The following is command and result.
********************************************************************
nick@nick-desktop:~/work$ condor_submit -append "" myjob.sub
Submitting job(s).
1 job(s) submitted to cluster 34.
nick@nick-desktop:~/work$ condor_q -better-analyze


-- Submitter: 192-168-1-3.rendermax.com : <192.168.1.3:9625> : 192-168-1-3.rendermax.com
---
032.000:  Request is held.

Hold reason: Error from slot2@192-168-1-2.rendermax.com: Failed to open '/home/nick/work\runblender.out' as standard output: No such file or directory (errno 2)

---
034.000:  Run analysis summary.  Of 5 machines,
      3 are rejected by your job's requirements
      0 reject your job because of their own requirements
      0 match but are serving users with a better priority in the pool
      2 match but reject the job for unknown reasons
      0 match but will not currently preempt their existing job
      0 match but are currently offline
      0 are available to run your job
    Last successful match: Sun Jul 25 12:28:57 2010

The Requirements expression for your job is:

( ( target.Arch == "INTEL" && target.OpSys == "WINNT51" ) &&
( target.Memory * 1024 >= 256 ) && ( RequestMemory * 1024 >= 256 ) &&
( TARGET.FileSystemDomain == "192-168-1-2.rendermax.com" ) ) &&
( target.Disk >= DiskUsage )

    Condition                        Machines Matched    Suggestion
    ---------                        ----------------    ----------
1  ( 1024 * ceiling(ifThenElse(JobVMMemory isnt undefined,JobVMMemory,9.765625000000000E-04)) >= 256 )
                                      0                  REMOVE
2  target.OpSys == "WINNT51"        2                   
3  ( TARGET.FileSystemDomain == "192-168-1-2.rendermax.com" )
                                      2                   
4  target.Arch == "INTEL"            5                   
5  ( 1024 * target.Memory >= 256 )  5                   
6  ( target.Disk >= 1 )              5                   
 

While another small issue with ubuntu10 is ssh server by default is NOT installed. You have to check if sshd is running by ps aux| grep sshd. To install ssh server: sudo apt-get install openssh-server. Another trivial issue is that when you connect to some server, you have to make sure they don't delete or change their public key. To be on safe side, just delete your past history in ~/.ssh/known_hosts.

28/07/12

I think I might be wrong with condor as it seems that the executer is trying to create files of log/in/output in submitter side. This is a fundemental concept of condor and I didn't get it. So, it must be a permission problem. Indeed, googled and they said executer would run under user of "nobody" if authentication is not passed. One of them is the "domain name". In my case, there is no true dns server, therefore maybe I should set "trust_uid" =true. As for "filesystem_domain", I better comment it out as it is said to be related with share file system etc. Then in my two ubuntu, the job is held for two unknown reasons. Damn it!

28/08/10

In ec2, sqlserver maybe wrong with login as computer name changes from last time you made AMI. So, just login as .\servername without hostname. As a result, using windows authentication instead of sqlserver authentication as it uses hostname\username as login name.

In condor, condor_store_cred add only. When prompted, input password. This works fine with all windows. Let me try with mix of window/linux. Also, pls note this is for submitter host only. For other machines... maybe this only works for windows in which user/passwd are all same in all machines. Time is short, life is fast and my memory slips away.

12/08/10

sudo apt-get install smbfs

sudo mount -t smbfs -o username=nick,password=123456 //NICK-PC/data /mnt/data

in case error, try 1. shut down windows firewall. 2. smbclient //NICK-PC/data -U nick

13/08/10

Shifu says to Panda:"Tomorrow is a mystery. Yesterday is a history. And today is a gift which is why it is called present." While I think today is a misery which is so identical to tomorrow because you cannot compare today with tomorrow, even though you maybe comparing today with yesterday everyday. A mystery and misery.

14/08/10

T says something I never know. Using VC to compile even same code twice, the binary are different. Indeed, I calculate their MD5 and they are different. Why?

15/08/10

So, I think it is very difficult to submit executable from windows to run in Linux, which I mean script. Therefore you have to use script as parameter for executable already in linux instead of copying scripts to run directly. At least I didn't succeed after more than one and half days struggling. Here is the sample which works:
universe = vanilla
Executable    = /bin/bash
Requirements = OpSys == "LINUX" && Memory >= 500
log             = c:\work\linux.$(PROCESS).log
output          = c:\work\linux.$(PROCESS).out
error           = c:\work\linux.$(PROCESS).err
should_transfer_files   = YES
transfer_executable = false
input = myblender.sh
transfer_input_files = myblender.sh
#Arguments         =  myblender.sh
when_to_transfer_output = ON_EXIT

Queue

17/08/10

It was said that 0.7% of population in China controls more than 70% of treasure and till recently I just understand how this figure comes from. Very simple. The total number of communist party memeber of china is about 70million and the total population in China is about 1.3billion. So, you know 70m/1.3b is roughly 0.7%. Hail the communist dictatorship!
19/08/10
Shell script doesn't support Unicode, I have to rewrite the list. This is the little program. Unfortunately webhosting doesn't allow wide char as folder, so this might not be true and I have not defined "UNICODE" macro. So this is just a fake. Anyway I don't have time for programming except an hour in the morning.

21/08/10
Install smbfs is like a magic and if you have some dependency error of samba-common, simply remove --purge and retry. Now you can just sudo mount -t smbfs //192.168.1.2/myweb ~/myweb
22/09/10
I suppose this is a kind of educational. When you run multiple instances of blender to render different frames in same scene, you might experience failure. The reason is blender writes its temp file to /tmp by default, unless you define environment variable TMP or TMPDIR. However, when I tested in my local ubuntu64, I still suffered failure except one success. Why is that? It turns out this is due to memory. Blender consumes huge amount of memory. 32bit platform cannot even work.  So, you see, my pc has 4G physical memory, but I only setup a 4G for swap. Three instance actually requires more than 8G. So, I decide to make a 15G swap. I boot with ubuntu64 DVD and create a new partition. However, you have to enable it by sudo swapoff -a, and sudo swapon -a. In between, you need to call sudo /sbin/mkswap /dev/sda3. To know the partition, you need sudo fdisk -l. And to make it static, you need to edit /etc/fstab. To know the UUID, sudo blkid. 

now it runs with 3.6G+6G=9G

up.gif (335 bytes)