This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
google.com | |
facebook.com | |
yahoo.com | |
youtube.com | |
live.com | |
wikipedia.org | |
blogger.com | |
baidu.com | |
msn.com | |
yahoo.co.jp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -not \( -name .git -prune \) -type f -print0 | xargs -0 sed -i 's/foo/bar/g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from Growl import GrowlNotifier | |
import time | |
import sys | |
import os | |
import optparse | |
""" |
NewerOlder