Friday, April 27, 2007

Followup foto from Xtina's Conert

2 weeks after Xtina's concert. The photos are finally liberated from my chuncky Canon. No surprise, anything with me in it shows a dark hole on the background. The stage is not recognizable at all. Luckily, a zoomed stage shot captures the first scene of "ain't no other men".



The diva was wearing all white suit and pants. Sexiness exuberates from all over. Her appearance made all the wait worth it.

Wednesday, April 25, 2007

Change margin temporarily in TEX

Add this to the preamble

\def\changemargin#1{\list{}{\topmargin#1}\item[]}
\let\endchangemargin=\endlist

Usage

\begin{changemargin}{-1in} %this shrink topmargin (add space for large table)
\end{changemargin}

Tex solution to seperate appendix for each chapter and headings

This example code can generate subappendix for each chapter and also add it to toc, and change the headings into appendix

\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendix}
\markboth{Appendix}{Appendix}
\begin{subappendices}
Appendix content
\end{subappendices}

Thursday, April 5, 2007

Taking Screen Shots in Mac

* To take a screen shot of the entire screen, press Command Shift 3.
* To get a crosshair cursor to take a screen shot of just a portion of the screen, press Command Shift 4. Drag over an area.
* To take a screen shot of a selected item, such as an open window, an icon, or the Desktop, press Command Shift 4, then press the Spacebar. The pointer turns into a camera icon that highlights items beneath it, as shown on the left. When the item you want to shoot is highlighted, click the mouse.
* You can take a screen shot that will go straight to the Clipboard (it will not make a Picture file) so you can then just paste it directly into a document or into something like a Photoshop file: Press Command Shift 4 to get the crosshair, then hold down the Control key. Drag over an area. You'll hear a much smaller snapping sound.
Go to your document. If it's a text document, click the insertion point where you want the graphic to paste in. Then press Command V to paste the screen shot onto the page.

Wednesday, April 4, 2007

Constrained Least Square in R

Here's the solution to constrained least square, where the coefficient sum up to one.


Given the linear predictor lp:
b0+b1X1+b2X2
as b2=1-b1 the lp becomes:
b0+b1X1+(1-b1)X2 => b0+b1(X1-X2)+offset(X2)

Hence for a generic GLM you can type
glm(y~1+I(x1-x2)+offset(x2))

Saturday, March 3, 2007

2-line unix solution to get rid of spaces in filenames

I have over 3000 filenames that looklike 123456789 .txt, to get ride of the space before ".txt". The following two lines will do

% ls *.txt | awk '{printf "mv %s %s\n", $0, substr($0,1,9) }' | bash
% ls | awk '{printf "mv %s %s.txt\n", $0, substr($0,1,9) }' | bash

The first line get rid of not only the space, but also the ".txt", the second line simply add them back.