Skip to content

Instantly share code, notes, and snippets.

View jesstess's full-sized avatar

Jessica McKellar jesstess

View GitHub Profile
@jesstess
jesstess / cpu_cache_info.txt
Created January 27, 2011 01:18
CPU cache level, type, size, cache line size, associativity.
for path in /sys/devices/system/cpu/cpu*/cache/index*/
do
echo $path;
echo -n "Level: "; cat $path/level;
echo -n "Type: "; cat $path/type;
echo -n "Size: "; cat $path/size;
echo -n "Cache line size: "; cat $path/coherency_line_size;
echo -n "Associativity: "; cat $path/ways_of_associativity;
done
@jesstess
jesstess / tracer.c
Created January 24, 2011 02:11
A minimal tracer. Attach to a running process or run a process under it. Step through instructions or syscalls. Generate instruction and syscall summaries.
/*
* A minimal tracer. You can:
* - attach to a running process or run a process under it.
* - step through instructions.
* - step through syscalls.
* - generate a syscall summary.
* - count and time the number of instructions executed.
*
* If you are generating a summary with 'ci' or 'cs', send SIGTSTP (Ctl-Z) to
* pause the traced process and dump a summary (useful if you've attached to a
@jesstess
jesstess / music_through_dev_dsp.py
Created November 15, 2010 02:11
Construct tones yourself and play them through /dev/dsp
#!/usr/bin/python
# Play music without any external files (ie you create the notes yourself)
# through /dev/dsp! Inspired by
# http://www.tldp.org/LDP/abs/html/devref1.html#MUSICSCR
def generate_notes():
# See http://www.phy.mtu.edu/~suits/NoteFreqCalcs.html for details on
# calculating the frequencies
@jesstess
jesstess / ELF_strings
Created February 18, 2012 21:36
Where in an ELF executable do various types of strings live?
Where in an ELF executable do various types of strings live?
Inspired by "How to waste a lot of space without knowing": http://glandium.org/blog/?p=2361
Test file:
$ cat /tmp/test.c
char *ptr_global = "ptr_global_string";
char array_global[] = "array_global_string";
import sys
scores = {"A": 1, "C": 3, "B": 3, "E": 1, "D": 2, "G": 2,
"F": 4, "I": 1, "H": 4, "K": 5, "J": 8, "M": 3,
"L": 1, "O": 1, "N": 1, "Q": 10, "P": 3, "S": 1,
"R": 1, "U": 1, "T": 1, "W": 4, "V": 4, "Y": 4,
"X": 8, "Z": 10}
# Get the Scrabble rack from the command line.
if len(sys.argv) < 2:
@jesstess
jesstess / wget_spider_https
Created November 27, 2010 20:02
Use wget to spider a site as a logged-in user.
http://addictivecode.org/FrequentlyAskedQuestions
To spider a site as a logged-in user:
1. post the form data (_every_ input with a name in the form, even if it doesn't have a value) required to log in (--post-data).
2. save the cookies that get generated (--save-cookies), including session cookies (--keep-session-cookies), which are not saved when --save-cookies alone is specified.
2. load the cookies, continue saving the session cookies, and recursively (-r) spider (--spider) the site, ignoring (-R) /logout.
# log in and save the cookies
wget --post-data='username=my_username&password=my_password&next=' --save-cookies=cookies.txt --keep-session-cookies https://foobar.com/login
@jesstess
jesstess / alexa-top-10000.txt
Created November 25, 2011 04:37
How the Alexa top 10000 respond to unusual HTTP methods
google.com
facebook.com
yahoo.com
youtube.com
live.com
wikipedia.org
blogger.com
baidu.com
msn.com
yahoo.co.jp
@jesstess
jesstess / NASA_images_png2yuv
Created August 12, 2011 19:13
Turning NASA images into movies: png2yuv | mpeg2enc
Keith gave me the hook-up on turning NASA images into a high-quality movie. I had tried twiddling knobs starting from a basic ffmpeg incant:
ffmpeg -r 10 -i frame%03d.jpg frames.mov
but the movies looked terrible.
Keith said:
"""
Generally if you're making a movie out of separate frames, I prefer to use png2yuv and mpeg2enc from the mjpegtools package instead of ffmpeg -- it's pretty clean code designed for this task instead of an assemblage of random libraries.
@jesstess
jesstess / find_prune_dir
Created February 1, 2012 22:31
Change all instances of foo to bar in this directory, excluding files in .git or its subdirectories
find . -not \( -name .git -prune \) -type f -print0 | xargs -0 sed -i 's/foo/bar/g'
@jesstess
jesstess / flash_cards.py
Created January 11, 2011 03:09
Growl-based flashcards
#!/usr/bin/python
from Growl import GrowlNotifier
import time
import sys
import os
import optparse
"""