Friday, December 28, 2012

Wednesday, December 12, 2012

apple extra menu bar

/System/Library/CoreServices/Menu Extras

command + drag to move or delete 

Sunday, November 4, 2012

centos sudo

http://www.tuxradar.com/answers/635

/etc/sudoers 

$user ALL=(ALL) ALL 

Saturday, November 3, 2012

display file with line number

http://www.commandlinefu.com/commands/view/2085/display-a-file-with-line-number


nl file > more 

or less -N,

the former is better since all are in the console windows

Thursday, October 11, 2012

macvim font setting

:set guifont=*
This brought up my native font selector

and I got back the value of "guifont=Menlo Regular:h14″. 
To set this style in my .gvimrc file:

set guifont=Menlo\ Regular:h14"

Saturday, September 22, 2012

r profile.site change options permanently

It seems the following link points to an approach, however, it does not work well. 


So at least this file can be changed for this purpose, 

library/base/R/Rprofile 

Saturday, September 15, 2012

a couple tips for mac

terminal color

http://osxdaily.com/2012/02/21/add-color-to-the-terminal-in-mac-os-x/

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced

install wget

./configure --with-ssl=openssl 
make 
sudo make install 

short cuts

in particular: ctrl E and ctrl A might be helpful sometimes

Friday, August 24, 2012

configure windows 7 to support dnsmasq

Configure Windows 7 to resolve hostnames (source)

  1. Go into Network Connections (I just typed "Network Connections" om the start icon -> run box)
  2. Right click on your Network Adapter and go into Properties
  3. Select "Internet Protocol Version 4 (TCP/IPv4)"
  4. Under the General Tab click Advanced
  5. Under the DNS Tab select the radio button that says "Append these DNS suffixes (in order)"
  6. Click "Add…"
  7. Enter a single period in the text box and click "Add."
  8. Click OK in the "Advanced TCP/IP Settings" Dialog
  9. Click OK in the "Local Area Connection Properties" Dialog

And there you go.


copied from http://blog.edwards-research.com/2009/09/lan-dns-resolution-with-wrt54g-dd-wrts-dsnmasq-linux-and-windows-7/

Wednesday, August 8, 2012

Stop Mac from sleeping

pmset noidle

Friday, August 3, 2012

convolution theorem

convolution theorem:

For any two vectors a and b of length n, w here n is a power of 2, 

where the vectors a and b are padded with 0s to length 2n and  \cdot denotes the com-
ponentwise product of two 2n-element vectors.

copied from introduction to algorithm 


Saturday, July 21, 2012

take a look at the code of a s4 method

getMethod('sampling', signature='s4class')

Friday, July 20, 2012

linux search manual

apropos 

for example
# apropos open 

ap·ro·pos

 prep \ˌa-prə-ˈpō, ˈa-prə-ˌ\

trace files accessed

using strace on linux 

what is fs_usage on mac?

Thursday, July 19, 2012

git status -uno

  git status -uno

Sunday, July 15, 2012

R machine related limits & numbers

?.Machines 
sample.int(.Machine$integer.max, 1)

Friday, July 13, 2012

R's memory limits

?"Memory-limits"

Sunday, July 8, 2012

windows 7 chinese characters

when file name in chinese is not squares, delete c:\windows\system32\fontcache.dat 

Tuesday, July 3, 2012

support chinese fonts on debian

http://en.wikipedia.org/wiki/Help:Multilingual_support_(East_Asian)

Simply put, two packages:
ttf-arphic-uming ttf-wqy-zenhei

Monday, July 2, 2012

git diff for files in different branches

git diff master:main.c branch1:main.c

Saturday, June 30, 2012

xfce application shortcuts

it turns our now <Primary> is the control key. :)

and <Super> is the windows key

Monday, June 11, 2012

dso how to

http://www.akkadia.org/drepper/dsohowto.pdf

.a to .so

ar -x mylib.a  gcc -shared *.o -o mylib.so

Wednesday, June 6, 2012

LMDE 12 disable beep

and the following to /etc/modeprob.d/blacklist.conf
blacklist pcspkr
 
add the following to alsa-base.conf
options snd_hda_intel beep_mode=0

not sure which one do the trick, but who cares?

Monday, May 21, 2012

Sunday, May 20, 2012

list 2 env in R

list2env {base}R Documentation

From A List, Build or Add To an Environment

Description

From a named list x, create an environment containing all list components as objects, or "multi-assign" from x into a pre-existing environment.

c++filt - Demangle C++ and Java symbols.

c++filt <symbol>

Example:
c++filt -n _Z1fv

 -n
       --no-strip-underscores
           Do not remove the initial underscore.


Saturday, May 19, 2012

a couple of git branch cmds

1. create a new branch from origin's branch

git checkout -b serverfix origin/serverfix

2. get everything from origin

git fetch origin 

3. deleting remote branch

git push origin :serverfix

Note that the syntax for git push is
git push [remote name] [local branch]:[remote branch]

source:

Sunday, May 13, 2012

using the default constructor

From page 460 of C++ Primer (4th ed)

A common mistake among programmers new to c++ is 
to declare an object initialized with the default constructor
as follows

// oops! declares a function, not an object
Sales_item myobj();

The problem is that our definition of myobj is interpreted as
a declaration of a function taking no parameters and returning 
an object of type Sales_item --- hardly we intended.  The correct
way to define an object using the default ctor is to leave off the 
trailing, empty parentheses. 

// ok: defines a class ojbect ...
Sales_item myobj;
On the other hand, this code is fine:

// ok, create an unnamed, empty sales_item and use to initialize myobj
Sales_item myobj = Sales_item();

Here we create and value-initialize a Sales_item object and to use 
it to initialize myobj.  The compiler value-initializes a Sales_item by running
its default ctor. 

Sunday, April 22, 2012

add date/time stamp to jpg

convert DSC00497.JPG -font Arial -pointsize 72 -fill white -annotate +100+100  %[exif:DateTimeOriginal] output.jpg

Thursday, March 8, 2012

vim tips

go the last non-whitespace on current line: g_

go the file from which gf is used: bf, ctrl + 6, ctrl + ^


Tuesday, March 6, 2012

unix env for ld and execution

use environment variable:
ld_library_path
and 
ld_run_path

if not adding the path to ld.so.conf.d 

Thursday, February 23, 2012

create variables in a created environment inside global environment inside a function

# create an environment inside the global 
# environment and create variables inside
# that environment 

# ref: http://goo.gl/GCQhZ
foofun <- function() {
   assign("env1", new.env(parent = globalenv()),  envir = globalenv()) 

   # this would not work 
   # env1 <- new.env(parent = globalenv());
   assign("tmpv", "tmpv", envir = globalenv()$env1) 
} 

foofun() 

ls() 

ls(envir = globalenv()$env1) 

rm("env1", envir = globalenv()) 
ls() 

#

Friday, February 17, 2012

lme4 nested example

http://lme4.r-forge.r-project.org/book/
chapter 2, we have example of nested factors

cask is nested in batch

so
strength ~ 1 + (1 | cask) + (1 | batch)
is problematic,

the correct one is
strength ~ 1 + (1 | cask) + (1 | batch:cask)
though
it is equivalent to
strength ~ 1 + (1 | batch / cask).

Saturday, February 11, 2012

symbolic description of factorial models for analysis of variance

Symbolic Description of Factorial Models for Analysis of Variance

G. N. Wilkinson and C. E. Rogers


Y_ij = m + a_i + b_j + (ab)_ij

A + B + A : B

Y_ij = m + a_i + (ab)_ij

A + A : B

---
A * B = A + B + A : B
A / B = A + A : B

blocks / plots 
nitrate * density 

Friday, February 10, 2012

sftp by shell script

though sftp is not used nowadays, it is still needed, 

copied from somewhere cannot quite remember

#! /bin/sh
ftp -n ftp.ftp.com <<_FTPEND
quote USER anonymous
quote PASS aa 
bin
cd incoming
put file.tar 
quit
_FTPEND

Thursday, February 9, 2012

R code to fit varying intercepts with nested structure linear model


## sim some data and fit an varying intercept model
##

<- 1:3
<- 1:4

intercepts <- rnorm(12) 
intnames <- outer(a, b, FUN = function(x, y) { paste(x, y, sep = ':')} )
names(intercepts) <- as.vector(t(intnames)) 

<- 10000; 
<- round(abs(rnorm(N)) * 10, 2)
noise <- rnorm(N); 
ai <- sample(a, N, replace = TRUE) 
bi <- sample(b, N, replace = TRUE) 
beta <- 4; 
<- intercepts[ai * 4 + bi - 4] + x * beta + noise 

ai <- as.factor(ai)
bi <- as.factor(bi)
table(ai:bi) 
print(intercepts) 
# varying intercepts model specification
fita <- lm(y ~ -1 + ai : bi + x) 
# in R lm and lmer's model specification, A * B = A + B + A : B
# where A : B is the interaction of A and B. So in the above,
# ai : bi is used to specify varying intercepts and -1 to
# get rid of the global intercept. 

short name for host under ssh

ssh config:
http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&sektion=5

for example, file ~/.ssh/config, we have 

Host  google 

Saturday, January 28, 2012

R draw ellipse

 1
 2 <- 100;
 3 <- numeric(N);
 4 <- numeric(N);
 5 x[1] <- -100;
 6 y[1] <- -100;
 7 for (in 2:N) {
 8   x[i] <- rnorm(1, 2 + (y[i - 1] - 3) / 6, sqrt(115 / 3))
 9   y[i] <- rnorm(1, 3 + (x[i] - 2) / 4, sqrt(115 / 2))
10 }
11 library(mixtools)
12 plot(y ~ x);
13 mu <- c(2, 3);
14 Sigma <- matrix(c(40, 10, 10, 60), ncol = 2)
15 ellipse(mu, Sigma);
16 

Tuesday, January 24, 2012

detailed explanation of interp.lin in bugs/jags

Essentially, vector x and y define a line connects all the dots [dot i
is (x_i, y_i)].  The function give the y-coordinate for any x-coordinate given
by argument e. 


Thursday, January 12, 2012

matrix to vector by row of by col in R

m <- matrix(....) 
as.vector(m)   # by column 
as.vector(t(m)) # by row 

Monday, January 9, 2012

Grep Recursively Through Single File Extension


grep tab

After some searching I found out the answer is to not use \t but to use Ctrl-v and then the <tab> key to put the tab character directly in the command. Odd. So it looks like:
 grep -R "   $" *
where the tab character is inserted as Ctrl-v and then Tab.



Sunday, January 8, 2012

See Where a Package is Installed on Ubuntu

copied from
http://www.howtogeek.com/howto/ubuntu/see-where-a-package-is-installed-on-ubuntu/

 

See Where a Package is Installed on Ubuntu

Once you use the apt-get utility to install a package, sometimes it seems to disappear into nowhere. You know it's installed, you just have no idea where.

If you know the name of the executable, you can use the which command to find the location of the binary, but that doesn't give you information on where the supporting files might be located.

There's an easy way to see the locations of all the files installed as part of the package, using the dpkg utility.

dpkg -L <packagename>

Tuesday, January 3, 2012

use gs to reduce pdf size somehow

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf a.pdf