This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | |
""" |
This file contains hidden or 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/env python | |
from Tkinter import * | |
import colorsys | |
import optparse | |
import random | |
""" | |
Use genetic algorithms to create graphical rainbows. |
This file contains hidden or 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
I have a table of accounts and a table of transactions. There's a | |
one-to-many relationship between accounts and transactions; | |
transactions.account_id is a foreign key into accounts. For all | |
accounts where < 50% of transactions are authorized, I want to | |
get the account id and that percentage: | |
SELECT a.id, SUM(t.authorized=1)/COUNT(*) AS percentage | |
FROM accounts a, transaction_info t | |
WHERE a.id=t.account_id | |
GROUP BY a.id |
NewerOlder