Skip to content

Instantly share code, notes, and snippets.

@mcescalante
mcescalante / netstatmav.sh
Created June 10, 2014 16:28
Mavericks netstat -tlpn equivalent
sudo lsof -i -n -P | grep TCP
@mcescalante
mcescalante / xorprng.c
Last active August 29, 2015 14:02
XORshift PRNG
//PRNG using XOR shifting for performance reasons
func GenRand(gen *uint32) int {
*gen += *gen
*gen ^= 1
if int32(*gen) < 0 {
*gen ^= 0x88888eef
}
a := *gen
return int(a)
}
@mcescalante
mcescalante / findstuff.sh
Created May 27, 2014 13:43
Find large things with Linux
#ncdu is another utility that might be useful (and it's interactive)
#Find 10 largest files
find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
#Find 10 largest directories (change f to d)
find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
@mcescalante
mcescalante / gist:10916956
Created April 16, 2014 18:24
Count lines of code in directory
find . -name '*.py' | xargs wc -l
@mcescalante
mcescalante / gist:10152645
Created April 8, 2014 16:33
FreeNAS kernel/driver commands
#In order to output all kernel devices, just run this
dmesg
#Alternate
camcontrol devlist
@mcescalante
mcescalante / gist:10097027
Last active August 29, 2015 13:58
pip Xcode clang 3.4 workaround
#Add this line before the "pip install..." command to bypass annoying errors on build with clang 3.4 Xcode tools
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
@mcescalante
mcescalante / gist:10022068
Last active August 29, 2015 13:58
FreeBSD iotop
top -m io -o total #include virtual memory & paging
top -m io #smaller scope
@mcescalante
mcescalante / gist:10013657
Created April 7, 2014 01:38
List users on FreeBSD box
cat /etc/passwd | cut -d: -f1 | grep -v \#
@mcescalante
mcescalante / gist:8809602
Created February 4, 2014 18:36
Force check all filesystems
sudo fsck -Af -M
@mcescalante
mcescalante / gist:7921270
Created December 12, 2013 00:35
Remove punctuation from python list
#Removes all of the punctuation in any item in a list. The characters to be removed are a string, "punctuation" from your list, "list"
list = [''.join(c for c in s if c not in punctuation) for s in list]