Skip to content

Instantly share code, notes, and snippets.

@vbajpai
vbajpai / gcc47-lion
Created July 31, 2012 13:25
Install GCC 4.7 on Mac OS X
>> bash
>> brew tap homebrew-dupes
>> brew install --use-lvm gcc
@vbajpai
vbajpai / gnuplot.gp
Created July 19, 2012 08:13
Pretty GnuPlots
>> cat gnuplot.gp
set terminal push
set terminal postscript eps font "Times" mono dashed
plot '$0' using 1:2:xtic(4) title "..." smooth csplines with lines, \
'$0' using 1:2 with points notitle pointtype 5 pointsize 1, \
'$0' using 1:3:xtic(4) title "..." smooth csplines with lines, \
'$0' using 1:3 with points notitle pointtype 5 pointsize 1
@vbajpai
vbajpai / run_pylist
Created July 18, 2012 13:46
Run All the Python Files in the Current Directory
>> ls | while read file; do python $file; done
@vbajpai
vbajpai / kv2v
Created July 18, 2012 09:31
Strip out Values from the KV pair in a Text File
>> cat input.txt
k1:v1 k2:v2 k3:v3 ...
...
>> cat input.txt | python -c "import sys; \
lines = sys.stdin.readlines(); \
values = [[i.split(':')[1] for i in item] for item in \
[line.split() for line in lines]]; \
import os; [os.system('echo %s'%v) for v in \
['\t'.join(value) for value in values]]" > output.txt
@vbajpai
vbajpai / ft2ftz.bash
Created July 16, 2012 15:54
Create Compressed Flow-Tools Traces from a List of Uncompressed Ones.
>> export FTEXT='.ft'
>> python -c "import os; list = os.listdir(os.getcwd()); \
print [os.system('echo converting: %s && flow-cat %s -z 9 > %sz'%(file, file,file)) \
for file in list if os.path.splitext(file)[1] == os.environ['FTEXT']]"
@vbajpai
vbajpai / md2tex.py
Created July 11, 2012 09:22
Convert a Directory Listing of Markdown Files to LaTeX using Pandoc.
>> export MDEXT='.md'
>> python -c "import os; \
filelist = os.listdir(os.getcwd()); \
print [os.system('echo executing: %s;pandoc --listings %s -o %s.tex'%(f, f,os.path.splitext(f)[0])) \
for f in filelist if os.path.splitext(f)[1] == os.environ['MDEXT']]"