sed -ne 's/[^,]*,//2p'
awk multiline csv flattener
March 10, 2011
awk 'BEGIN{RS="";FS=",[\n]*";OFS="";ORS=""}{for(i=1;i<NF;i++) print $i ",";print $NF "\n"}'
Python 2 print headers and content of url
March 4, 2011
python -c 'import urllib2; resp = urllib2.urlopen("http://localhost:10888/cgi-bin/hello.py"); print resp.info(), resp.read()'
Python 3 print headers and content of url
March 3, 2011
python3 -c 'import urllib.request; resp = urllib.request.urlopen("http://localhost:10888/cgi-bin/hello.py"); print(resp.info(), resp.read().decode("utf-8"))'
Python 3 CGI web server with cgi-bin directory
March 2, 2011
python3 -c 'import http.server; http.server.HTTPServer(("", 10888), http.server.CGIHTTPRequestHandler).serve_forever()'
Reversing a string in python – version special case
February 25, 2011
python -c 'print "The rain in spain."[::-1]'
Reversing a string in python – version after sleeping on it
February 24, 2011
python -c 'print "The rain in spain."[-1::-1]'
Reversing a string in python – version the first
February 23, 2011
python -c 's = "The rain in spain falls mainly on the plain."; print "".join(s[c] for c in xrange(len(s) - 1, -1, -1))'
bash hello open tcp ports
July 5, 2010
bash -c 'for n in $(seq 1 1024);do (echo </dev/tcp/localhost/$n) &</dev/null && echo $n open;done'
perl one liners begin with -e
October 24, 2008
perl -e '$hw="hello world";$hw=~s/^(h)([^w]*)(w)(.*)$/H$2W$4\n/;print $hw'
Twitter
RSS