Skip to content

Instantly share code, notes, and snippets.

find ./ -type d -exec du -sh {} \;
find ./ -name *.txt -type f -exec sed -i 's/old/new/g' {} \;
ls -1 > ALLFILES
sort MANIFEST MANIFEST ALLFILES| uniq -u | xargs rm
ls -1 | sort MANIFEST MANIFEST - | uniq -u | xargs rm
#! /usr/bin/env python
import xml.etree.ElementTree as ET
import Image
import ImageDraw
import numpy as np
import sys, re, os
files = os.listdir(sys.argv[1])
files.sort()
regex = re.compile("[0-9]+\.xml")
# To Compile
javac -cp /path/to/libs:/more/libs *.java
# To run
java -cp /path/to/libs:/path/to/classes MyApp
// Will work as expected
"foo|bar|spam|eggs".split("\\|");
//will get a compilation error
"foo|bar|spam|eggs".split("\|");
//will split on each character
"foo|bar|spam|eggs".split("|");
@bricef
bricef / lookup-nobatteries.py
Created June 9, 2011 19:01
Python script to carry out a reverse hostname lookup. Version 1: The dummy way.
#!/usr/bin/env python
import sys, re, os, popen2
hosts_locs = [
"/etc/hosts",
"C:/Windows/system32/drivers/etc/hosts"
]
hosts = {}
@bricef
bricef / lookup-batteries.py
Created June 9, 2011 19:04
Script to do a hostname lookup on an IP address. Batteries included.
#!/usr/bin/env python
import sys
from socket import gethostbyaddr, herror
def usage():
print("[usage]: %s [ip]"%(sys.argv[0]))
print("")
print("performs a reverse lookup on a host ip.")
@bricef
bricef / timing_0.1.c
Created June 17, 2011 20:15
Naive Timing of C Code.
#include <sys/time.h>
// ...
{
struct timeval t1, t2, diff;
double interval;
int i;
gettimeofday(t1, NULL);
for ( i = 0 ; i < 10000 ; i++ ){