Interesting links:

email
jke000 at gmail.com
engj at uw.edu


helpful commands for myself:

grid engine

   qstat -j jobid | grep error              to see error message
   qmod -cj jobid                           to restart/resubmit jobs in Eqw state
   qlogin -l h=q003                                to log into a specific node, "q003" in this example
   qlogin -l mfree=1.6G -l h=q003 -pe serial 8     to log into specific node (q003), using 8 cores and 8*1.6GB RAM

git commands:

   git status
   git diff
   git add <files>
   git commit -m 'commit message'
   git push

print out column 3, a tab, then column 1 and save to a new file:

   cat somefile.txt | awk '{print $3 "\t" $1}' > newfile.txt

assume column 2 has numbers, to sum up that column:

   cat somefile.txt | awk 'BEGIN {s=0} {s=s+$2} END {print s}'

skip first line, add numbers in column 1 & 2, and separately column 2:

   more +2 somefile.txt | awk 'BEGIN {s=0; t=0} {s=s+$1+$2; t=t+$2} END {print s "\t" t} 

in-place substitution using perl:

   perl -i -pe 's/from/to/g;' -pe 's/FROM/NEW/g;' somefile.txt

my preferred source indentation formatting (Allman or ANSI/ISO C++ style with indentation size 3):

   indent -i3 -bls -bli0 -bbo -bfda -cbi0 -cli3 -cd3 -sc -nut -lp -npsl -npcs -di7 somefile.txt

pepXML Viewer peptide text regular expression:

   include string "115" and exclude peptides with G or N

   ^(?=.*115)((?!G|N).)*$

change EOL format in Vi:

   :set ff=unix
   :set ff=dos


find files without group/other read/write permission:

   find . ! -perm -g+r,-o+r

simple C strtok example:

   char *tok;
   char delims[] = "\t";  // tokenize by tab
   tok = strtok(szString, delims);
   while (tok != NULL)
   {
      printf("token '%s'\n", tok);
      tok = strtok(NULL, delims);
   }

tokenize on single character (from http://www.cplusplus.com/faq/sequences/strings/split/):

   #include <sstream>
   string s = "string, to, split";
   istringstream ss( s );
   while (!ss.eof())
   {
      string x
      getline( ss, x, ',' );
      cout << x << endl;
   }

custom strtok that doesn't skip empty tokens (from Stack Overflow):

   char *mystrtok(char **m,char *s,char c)
   {
      char *p=s?s:*m;
      if( !*p )
         return 0;
      *m=strchr(p,c);
      if( *m )
         *(*m)++=0;
      else
         *m=p+strlen(p);
      return p;
   }

   char *p, *t;

   for (t=mystrtok(&p, szBuf, ','); t ; t=mystrtok(&p, 0, ','))  // comma token
      printf("token %s\n", t);

   OR tokenize two strings at same time (which strtok does not do):

   char *p1, *t1;
   char *p2, *t2;

   for (t1=mystrtok(&p1, szBuf, ','), t2=mystrtok(&p2, szNormLine, ',') ; t1 ; t1=mystrtok(&p1, 0, ','), t2=mystrtok(&p2, 0, ','))
      printf("token %s %s\n", t1, t2);

grab specific columns in tab-delimited text file:

   cut -f1-6,8- somefile
   cut -f1,2,3,9-12,15- somefile

combine/merge multiple VOB files into one in a DOS prompt:

   copy /b vts_01_1.vob + vts_01_2.vob + vts_01_3.vob + vts_01_4.vob new.vob 

create histograms in gnuplot:

   gnuplot> binwidth = 0.01
   gnuplot> bin(x,width)=width*floor(x/width) + binwidth/2
   gnuplot> plot 'datafile.txt' using (bin($1,binwidth)):(1.0) smooth freq with boxes

valgrind to gdb thanks to ppatrick; maybe I can actually fix some bugs now:

   valgrind --leak-check=yes --db-attach=yes --db-command="/usr/bin/gdb -nw %f %p" <executable>

resubmit job in Eqw state:

   qmod -cj jobnumber

simple bash shell script to loop over input files:

   #!/bin/bash

   shopt -s nullglob

   for i in *.txt
   do
      echo "file $i"
      cat $i
   done

ffmpeg transcoding script:

   #!/bin/bash

   # test for proper usage
   if [ $# -eq 0 ] ;
   then
      echo ""
      echo " usage:  convertmp4.sh file1.avi file1.mkv"
      echo ""
      exit
   fi

   # for every argument passed on the command line
   for arg do

      echo "input: '$arg'"

      # test that the file exists and is a regular file
      if [ -f "$arg" ] ;
      then
         basename=${arg%.*}
         echo "basename: '$basename'"
         ffmpeg -i "$arg"                               -metadata title="$basename" -vcodec libx264 -acodec aac -strict -2 "$basename.mp4"
#        ffmpeg -i "$arg"                               -metadata title="$basename" -vcodec copy    -acodec copy -strict -2 "$basename.new.mp4"
#        ffmpeg -i "$arg" -vf subtitles="$basename.srt" -metadata title="$basename" -vcodec libx264 -acodec aac -strict -2 "$basename.mp4"
#        ffmpeg -i "$arg" -vf scale=720:-1 -ss 5        -metadata title="$basename" -vcodec libx264 -acodec aac -strict -2 "$basename.mp4"
      else
         echo Argument '$arg' not a regular file
         exit
      fi
   done

delete blank lines in Vi:

   :g/^$/d