29 May 2012

Making a definition at make command

For emergency use, when an extra define is needed outside source code / Makefile.
When running make command,
make CPPFLAG=-DMYFLAG
which is equal to,
#define MYFLAG
in cpp file.

Warning: this will replace the CPPFLAG defined in the Makefile.

23 May 2012

Inkscape Troubleshooting

Recently installed a pen tablet?
Recently Inkscape become unusable?
Cannot draw / click?
File->Input Devices...->Configuration untick the pen and eraser

source

17 May 2012

Emacs Coloring

For example, when you have a Makefile named other than "Makefile", emacs by default will not color the syntax.
To force the color syntax:
M-x shell-script-mode

Pointer and Const

int n = 5; //normal int variable
int *const nptr = &n; //nptr always point to n, cannot be changed
*nptr = 6; //OK since n is non-const

const int *cnptr = &n; //treats the pointed variable as a const
n = 7; //OK
*cnptr = 8; //NG since n is treated as const

const int cn;
const int *const cnptr = &n; //cannot redirect pointer, cannot change value


source: pointers and const

Syntax Highlighter

I used to use it with Wordpress.
It's actually much easier to use it in Blogger.
Just need to attach scripts in the head section.
And use it with pre blocks.

adding syntax highlighter to blogger

13 May 2012

R commands

/tmp/data.txt
2000 2001 2002 2003 2004
9.34 8.50 7.62 6.93 6.60

clear data rm(list=ls(all=TRUE))
read from file da <- data.txt
read.table tmp
row da[1,]
column da[1]
run script source("/tmp/sc.r")
write to file write.table(year,file="/tmp/year.txt",col.names=F,row.names=F)
install package from CRAN install.packages("name")
install car package for old ubuntu sudo apt-get install r-cran-car

linear regression


blogger ruined my post!!!! *A*

03 May 2012

ssh and vnc

to be used to connect with network behind router.
done from mac osx 10.6

ssh for scp
1. establish porting to localhost
ssh -N -f -L 22000:192.168.x.x:22 your_login@your_server.com
a. for ssh to the computer with ip 192.168.x.x
ssh -p 22000 your_login@localhost
b. to copy files from 192.168.x.x
scp -P 22000 your_login@localhost:~/Pictures/x ~/Downloads

ssh with X11
opening a GUI from a remote computer
1. porting as done above
ssh -N -f -L 22000:192.168.x.x:22 your_login@your_server.com
2. connect to pc
ssh -X -p 22000 your_login@localhost
3. type a program
emacs
4. X11 will open emacs
(to compensate Meta key, press Esc instead)

ssh for vnc
1. port to localhost
ssh -L 5959:192.168.x.x:5901 -i .ssh/id_name -l your_login your_server
2. open finder
3. Cmd-K (connect to server)
vnc://localhost:5959