Wednesday, December 8, 2004

ssh without password howto

 
1. Run "ssh-keygen -t rsa".

2. Save the generated key in the default location.

3. Leave the passphrase blank.

4. Change to the .ssh directory, and append the contents of id_rsa.pub
to the file "authorized_keys." If no authorized_keys file exists, you
can just run "cp id_rsa.pub authorized_keys".

Now you should be able to ssh to department machines without typing
your password. Note that if you're doing this from a non-department
Linux machine, you should do steps 1, 2, and 3 from the command prompt
of your machine, and step 4 from the command prompt of any department
Linux machine. If you're doing this from a department Linux machine,
do all steps on that machine.

- Elliot

R legacy help galton

## calling C functions from R
gcc -c kendall.c
R CMD SHLIB -o libkendall.so kendall.o
R
dyn.load('libkendall.so')
xd <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
yd <- c( 2.6,  3.1,  2.5,  5.0,  3.6,  4.0,  5.2,  2.8,  3.8)
.C("kendall",as.double(xd),as.double(yd),as.integer(9),
result=as.integer(1))$result

## header
rm(list=ls())
options(contrasts=c("contr.treatment","contr.poly"))
setwd("/mnt/win_c/my documents/stat/ammonia")

## plot function
plot(fun,-5, 5, ylim = c(-.2, 1))

eval.parent(expr) 
## example eval.parent(media <- 1), used inside
## functions to change global variables
media <<- 1 ## does the same

rep(x,n) replicates x n-times

mtext("texto",side=3,line=.5)

install.packages("fields","/aa/haky/R/Library")
library("fields",lib="/aa/haky/R/Library")
detach(package:fields)

setenv R_LIBS /aa/haky/R/Library (then no need to specify lib=...)

xmat <- matrix(NA,n,n)

#print
dev.print()
dev.copy2eps(file="filename.ps")
#
postscript(file="plot.ps",horizontal=F,heigth=9,width=7)
dev.off()

as.numeric(x<1)

# stop watch
tic<-Sys.time()
....do something here
toc<-Sys.time()
print(toc-tic)

paste(s1,s2,sep="")

system("mail -s something haky@galton.uchicago.edu < output")<

## strip an object's attributes:
attributes(x) <- NULL
x # now just a vector of length 6

kk[names(kk)=="site"] is same as kk$site

unlist(x)

debug(myfunction)
undebug(myfunction)

call R from emacs (ESS): alt-x R

par(mfrow=c(3,2))

legacy galton help

# synchronize file system
rsync -avz --exclude '*.eps' Penalty aitken:~/donnpc/ .
# dry run - shows only what would have been transferred
rsync -avzn --exclude '*.eps' Penalty aitken:~/donnpc/ . | less

# indent region mode dependent
M - C - \

# rigid tab region
C - x - TAB

# restart pcmcia, network
/etc/rc.d/init.d/pcmcia restart
/etc/init.d/network restart

# create symbolic links
ln -s /home/azubrow/CMAQ_v4.3/data/emis/M_36_EUSA ./emisfiles

# run identical command in all nodes
sshall uptime
sshall w

To run batch jobs in ravana
chmod u+x batch
./batch &

batch:
#!/bin/sh
/usr/bin/nohup nice -5 R BATCH mplefft.r output

Ctrl-z (suspend)
bg (sends process to background)
fg(bring process to foreground)

rm
rmdir
mkdir
mv
chmod 700 mydir (no access to others)

ftp
$ scp * ravana:~/

gunzip filename: unzip
gzip filename: zip
tar xvf filename.tar: extract tar
tar cvf filename.tar filename or directory: merges files

get rid of the ^M:  in vi type
:%s/(ctrl-v)(ctrl-m)//g
in emacs
M-x replace-regexp RET C-q C-m $ RET RET

chsh #changes shell in unix

mail -s "subject" email@galton <> mkdir work_dir
> cd work_dir
> Splus5 CHAPTER
> touch .Data/.Audit
> chmod 0 .Data/.Audit
emacs kk.s   alt-x S+6

Wednesday, June 2, 2004

cdms quick tutorial

> cdat This starts the CDAT shell, identical to the Python shell.
> import cdms Imports the CDMS module.
> f=cdms.open('wind_comps.nc') Opens the NetCDF file and assigns the file object to variable 'f'.
> f.listvariables() Shows the variable names in the file.
['u', 'v']
> u_wind=f('u') Reads the variable 'u' and assigns it to the Python variable 'u_wind'.
> u_wind.attributes Displays all the attributes pertaining to the variable 'u_wind'.
> v_wind=f('v') Reads the variable 'v' and assigns it to the Python variable 'v_wind'.
> wspd=(u_wind**2+v_wind**2)**0.5
Calculates the combined wind speed and assigns it to the Python variable 'wspd'.
> wspd.id='wspd' Sets the 'id' attribute on the 'wspd' variable.
> wspd.long_name='Wind speed' Sets the 'long_name' attribute on the 'wspd' variable.
> wspd.units='m s**-1' Sets the 'units' attribute on the 'wspd' variable.
> import vcs Imports the VCS (Visualisation Control System) module.
> p=vcs.init() Initialise a VCS canvas and assign Python variable 'p' to it.
> p.plot(wspd) Plot the wind speed variable on canvas 'p'.
> fout=cdms.open('output.nc', 'w') Open a file to write out the wind speed variable to.
> fout.write(wspd) Write the wind speed variable to the output file.

> fout.close() Close the output file.
> CTRL^D Press Control and D to close CDAT.

Contributors

google