## Friday, December 28, 2012

### aptosid nvidia driver problem with kernel 3.7.0+

http://forums.opensuse.org/english/get-technical-help-here/pre-release-beta/481597-warning-kernel-3-7-1-1-breaks-fglrx-12-6-legacy-driver.html

fix a problem with nvidia driver for kernel 3.7.0+

### debian experimental repo

In particular, install a package

apt-get update
apt-get -t experimental install packagename

## Wednesday, December 12, 2012

command + drag to move or delete

ssh -D

proxytype: sock5

/etc/sudoers

?"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

### .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

options snd_hda_intel beep_mode=0

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

## Monday, May 21, 2012

### vim set path to find more included file

see

let vim be more powerful for editing c/c++ code

## 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

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

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

## 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

## 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 --include=*.py -lir "delete" .

### 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