Code and Tips
Code Tips Chinese related

Various Code
2D Convex Hull Graham's algorithm with a Tcl/Tk demo
View source codeDownload .c fileDownload .h file |   Download tk file
Real camera to graphics camera Converting real camera calibration data to ray tracer view parameters
The easy part is to compute the view point and view direction. With X_c = RX_w+t, the view point is -R^{T}t. The view direction is the last column of R. The up viewing direction should the second column of R. But Radiance flips the -vu parameter, so we need to pre-flip it here. How to convert the intrinsic parameters to view angles and view shifts takes a little thinking. One thing for sure is that the size of the sensor (CCD chip or film) is mm-per-dot times dots (pixels). If we have the size of the sensor and the focal length, we are able to compute the view angles. The center of projection of a real (CCD) camera is usually not at the center of the picture, so we need to lift (-vl) and shift (-vs) Radiance's imaging plane. Lastly, specify the size of the image (-x -y) and enforce the aspect ration (-pa 0). Now if you have a Radiance scene description, you should be able to generate a very close image to that taken by the real camera. I leave out lens distortions, to do which, one has to however tweak the source code of Radiance.

View source codeDownload .c file 

Enumerating spanning trees Enumerating all the spanning trees of a graph
View source code;
Various Tips
Download a sequence of files As in http://foo.com/bar.XXX. XXX are numbers, say from 000 to 099.
  1. Using awk
      awk 'BEGIN{for(i=0; i<=99; i++)
          printf("http://foo.com/bar.%03d\n", i)}'
          |wget -i -
          
  2. Using jot

    Don't know jot (no, it is not the editor comes with IRIX)? Check your Unix Power Tools. You can get jot from here

    jot -w 'http://foo.com/bar.%03d'|wget -i -  
  3. Using plain shell
    foreach i ({0}{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9})
        wget http://foo.com/bar.$i
        end
        
  4. If there are just a few files and XXX are in single digit form,

    wget http://foo.com/bar.{1,2,4,5}


Print man pages man foo |col -b |lpr
or
groff -man -Tps /usr/man/man1/foo.1 |lpr

Netscape tricks For diehard Netscape users.
  1. To remove the Shop, My Netscape, Search buttons, add the following lines in the ~/.Xdefaults file.
        Netscape*toolBar.myshopping.isEnabled: false
        Netscape*toolBar.search.isEnabled: false
        Netscape*toolBar.viewSecurity.isEnabled: false
        
  2. To prevent Netscape from creating nsmail directory, add the following line to the ~/.netscape/preferences.js file.
        user_pref("mail.directory", "");
        
  3. Use Mozilla or MozillaFirebird and rejected by rude websites? Change your user-agent string:
        user_pref("general.useragent.override","Mozilla/5.0 (Windows; U;\
        Windows NT 5.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.3");
    
    Wget can use the same trick.

Fontset in XMMS The GUI of XMMS relies on GTK+ and can display multi-byte languages, such as Chinese. You'll need locales set up properly. But for most linux distributions, it's already done. The thing is that the Font dialog box (under Options) won't let you select a fontset, which is needed for displaying multi-byte characters. The tip is to type in a fontset by yourself (What? This is not a tip...) A screenshot is here.

Syntax highlighters I see people looking for syntax highlighters when they try to put programs on the web, all the time. There are couple of highlighters with names like c2html on the net. Most of them are perl scripts. You don't need them. You've already got at least two syntax highlighters with you.
  1. Vim.
  2. Enscript. From the man page of enscript
    enscript -E --color --lang html --toc -pfoo.html *.h *.c
    
LaTeX:Box around code Note: You shouldn't use this tip in the first place. Instead, you should use one of the several listing packages, e.g. fancyvrb or listings. If you really want to use the original verbatim, this is what you do.
\setbox0\vbox{
    \begin{verbatim}
    ... code here ...
	... more code here ...
	\end{verbatim}
}
fbox{\box0}
psfrag and eps bounding box One can use
dvips -E -o foo.eps bar.dvi
to create an EPS file from a LaTeX figure. But if the figure has psfrag replacements in it, the bounding box isn't right. For a more detailed description of this problem, refer this comp.text.tex pose. A quick dirty hack is to put the following code in your preamble.

As a side effect, this removes the PSfrag replacement... text in your DVI file.  But if the goal is to create an EPS file, it shouldn't be a problem.
NeoMagic Xvideo If you have a NeoMagic card (AV256) and your Xine (v1.beta12) and Mplayer (v0.90) have problems with the Xvideo lib, try put this
Option          "OverlayMem"    "829440"
in your XF86Config-4. Read the manpage (man 4x neomagic) for details.
Acroread EULA window Strangely, not everybody runs into such an annoying problem. Namely, everytime acroread starts, a window showing the EULA will pop up. Poking around, I found a line in .acrobat/prefs:

/avpShowUnixEula [/b true]

Changing it to false seems to solve the problem.