Skip to content

Instantly share code, notes, and snippets.

View tathagata's full-sized avatar
🐢
debugging

Tathagata tathagata

🐢
debugging
View GitHub Profile
@tathagata
tathagata / about.md
Created August 15, 2011 01:17 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@tathagata
tathagata / gist:1270692
Created October 7, 2011 16:15
code for benchmarking resist
cat docword_as_id | sort -t',' -k1 | uniq | awk -F"," '{if (index($2," ")>0) print$0}' | wc -l --tathagatadg Tue 13 Sep 2011 04:15:20 PM CDT
@tathagata
tathagata / dirnav.py
Created November 28, 2011 18:30
Directory tree navigation using os.walk
import os
#So much can be done with these two simple lines .. have to always lookup!
for root, dirnames, filenames in os.walk('root/'):
for filename in filenames:
absfn = os.path.join(root, filename)
print absfn
filecontents = open(absfn, 'rb').read()
print filecontents
@tathagata
tathagata / gist:1406654
Created November 29, 2011 21:39
How to get the command line equivalent of eclipse GUI run
1. Change the perspective to Debug
2. Right click on the class containing main in Debug box
3. Select property. Copy the code
@tathagata
tathagata / snippets.sh
Created November 30, 2011 20:53
Random bash snippets
#Stop tomcat started from Eclipse, helpful when it throws java.lang.OutOfMemoryError: PermGen space
kill -9 `ps aux | grep java | grep tomcat | cut -d' ' -f7`
#list all sizes of the directory
du -sh *
@tathagata
tathagata / md5.java
Created December 1, 2011 09:56
MD5 java
String plaintext = "your text here";
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(plaintext.getBytes());
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16);
// Now we need to zero pad it if you actually want the full 32 chars.
while(hashtext.length() < 32 ){
hashtext = "0"+hashtext;
}
@tathagata
tathagata / allany.py
Created December 30, 2011 12:09
all any list comprehension python
#if there is a -1 in a list
x = [1,1,1]
any(i for i in x if i==-1)
True
# if all elements of the list are equal
x = [1,1,1]
all(x[0] == i for i in x)
True
@tathagata
tathagata / infin.py
Created December 30, 2011 14:42
Python infinity
min = float('inf')
for x in somelist:
if x<min:
min=x
@tathagata
tathagata / quickies.vim
Created December 31, 2011 13:07
Vim quickies
1. visually comment out block
- select section visually
- go to command mode
- s/^/# enter. comments
- s/#/ enter. uncomments
NERDTree
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript" ></script>