Skip to content

Instantly share code, notes, and snippets.

View vmirly's full-sized avatar

Vahid Mirjalili vmirly

View GitHub Profile
google.charts.load('current', {'packages':['geochart']});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['State', 'Value'],
['CA', 780],
['MI', 300],
['NY', 400],
@vmirly
vmirly / runjob.sh
Created November 16, 2013 02:38
Run a new job after an already running job finishes
# assume that job1.sh is already running
# we want to start jab2.sh right after job1.sh finishes
pid=$(ps -o pid= -C job1.sh)
while [ -d /proc/$pid ]; do
echo "process $pid still running"
sleep 60
done && ./job2.sh
@vmirly
vmirly / inputrc
Created October 17, 2013 21:28
/etc/inputrc command completion from history by pressing Pageup, PageDown, and arroe keys
$if Bash
# Search history back and forward using page-up and page-down
"\e[5~": history-search-backward
"\e[6~": history-search-forward
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
@vmirly
vmirly / .bashrc
Created October 17, 2013 21:26
.bashrc configurations
alias cp='cp -i'
alias rm='rm -i'
alias mv='mv -i'
alias ls='ls --color=auto '
alias grep='grep --color -E '
echo -e " \e[0;30m \\\e[0;30m \e[0;34m \\\e[0;34m \e[0;32m \\\e[0;32m \e[0;36m \\\e[0;36m \e[0;31m \\\e[0;31m \e[0;35m \\\e[0;35m \e[0;35m \\\e[0;35m \e[0;37m \\\e[0;37m \e[0m"
green='\e[0;32m' # '\e[1;32m' is too bright for white bg.
@vmirly
vmirly / genSfj.awk
Created October 14, 2013 15:05
Generate scaling factors for each atom of a PDB based on atom type
awk '{
printf "%s\n", substr($3,1,1)
}' amber/heat7.chm.pdb | awk '{
if ($1=="H") {print "Sfj(",NR,")=0.85"}
else if ($1 == "C") {print "Sfj(",NR,")=0.72"}
else if($1 == "N") {print "Sfj(",NR,")=0.79"}
else if($1 == "O"){print "Sfj(",NR,")=0.85"}
else if($1=="P"){print "Sfj(",NR,")=0.86"}
else if($1=="S"){print "Sfj(",NR,")=0.96"}
}'
@vmirly
vmirly / trainsize.awk
Created October 12, 2013 18:23
AWK: generate random sample for training and testing
awk 'BEGIN {srand()} !/^$/ {printf "%s %f\n",$0, rand()}' merged.arff | sort -n -k2 |
awk '{
if(NR<=10) {printf "%s\n", $1 >> "t01.csv"}
if(NR<=20) {printf "%s\n", $1 >> "t02.csv"}
if(NR<=40) {printf "%s\n", $1 >> "t03.csv"}
if(NR<=80) {printf "%s\n", $1 >> "t04.csv"}
if(NR<=160) {printf "%s\n", $1 >> "t05.csv"}
if(NR<=320) {printf "%s\n", $1 >> "t06.csv"}
if(NR>320) {printf "%s\n", $1 >> "test.csv"}
@vmirly
vmirly / analyze_memtknss.R
Last active December 25, 2015 02:29
R read files from a directory and plot them
# this R code, will read all the result files found in the specified directory,
# and plot the membrane thickness as a function of time
f.list <- list.files("run_05_rad8t6_den0.2/", pattern="res.tknss.*", full.names=T)
d.list <- lapply(f.list, read.table)
d <- do.call(rbind, d.list)
d$V1=as.numeric(rownames(d))/500
@vmirly
vmirly / conv_water.awk
Created October 7, 2013 22:24
AWK: randomly change 10% of water residues from TIP3 to TIPT
awk '
function prpdb(anum, aname, rnum, x,y,z) {
if(rnum<1000) {
printf "ATOM %5d %-3s TIPT0%4d %8.3f%8.3f%8.3f 1.00 0.00 WT00\n",anum, aname, rnum, x, y, z
}else{
printf "ATOM %5d %-3s TIPT0%5d %8.3f%8.3f%8.3f 1.00 0.00 WT00\n",anum, aname, rnum, x, y, z
}
}
BEGIN { srand() }