Skip to content

Instantly share code, notes, and snippets.

View alexras's full-sized avatar

Alex Rasmussen alexras

View GitHub Profile
@alexras
alexras / default.xml
Created August 5, 2011 06:15
This file configures MAME to use four controllers (I use XBox 360 wireless controllers) as inputs
<?xml version="1.0"?>
<!-- This file configures MAME to use four controllers (I use XBox 360 wireless controllers) as inputs -->
<mameconfig version="10">
<system name="default">
<input>
<port type="P1_JOYSTICK_UP">
<newseq type="standard">
JOYCODE_1_YAXIS_UP_SWITCH
</newseq>
</port>
@alexras
alexras / .screenrc
Created August 14, 2011 03:52
My .screenrc file
# Screen Options ##
shell bash # Tell screen your default shell
startup_message off # Turn off start message
defscrollback = 5000
shelltitle '$ |bash' # Dynamic window titled for running program
msgwait 1 # Set messages timeout to one second
nethack on # Turn on nethack error messages
backtick 0 0 0 whoami # Set "%0`" to equal the output of "whoami"
escape ^Oo
@alexras
alexras / find_ppc.py
Created September 24, 2011 18:04
Search for PPC-only or Classic apps on a Mac
#!/usr/bin/python
import plistlib
import subprocess
ppc_apps = []
command = ["system_profiler", "-xml", "SPApplicationsDataType"]
task = subprocess.Popen(command, stdout=subprocess.PIPE)
@alexras
alexras / Delaunay.pde
Created September 25, 2011 21:07
Quick-and-dirty Delaunay triangulation in Processing used to create http://youtu.be/dsrMjbR0usA
float dpLength(DelaunayPoint p1, DelaunayPoint p2) {
float deltaX = p2.x - p1.x;
float deltaY = p2.y - p1.y;
float deltaZ = p2.z - p1.z;
return sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ));
}
DelaunayPoint dpAdd(DelaunayPoint p1, DelaunayPoint p2)
{
@alexras
alexras / ssh-agent-snippets.sh
Created October 17, 2011 00:14
Bash snippets to automatically start and stop an ssh-agent process on login and logout
#!/bin/bash
## in .bash_profile
SSHAGENT=`which ssh-agent`
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
@alexras
alexras / count.json
Created October 26, 2011 00:12
Convert lines-of-code information found at https://docs.google.com/spreadsheet/ccc?key=0AszFIYMceP5EdEtQT3l4MlY2Q1Etb0JqWURHU0E3aUE&hl=en_US into something more easily manipulable
{
"emacs-21.3.tar.gz": {
"XML": {
"files": 2,
"comment": 106,
"code": 4262,
"blank": 91
},
"C": {
"files": 181,
@alexras
alexras / id3tagger.py
Created November 23, 2011 04:17
Quick-and-dirty script for tagging a bunch of MP3s based on title and artist data stored in a text file
#!/usr/bin/env python
import os
with open("names.txt", "r") as fp:
for file_num, line in enumerate(fp):
track_num = file_num + 1
artist, sep, title = line.strip().partition('-')
artist = artist.strip()
@alexras
alexras / markupserve-elisp.el
Created November 27, 2011 05:33
Emacs lisp functions for creating attachment directories and attaching files in MarkupServe
(defun markupserve-resource-dir-for-buffer (buffer)
(concat (buffer-file-name buffer) "/../" (file-name-sans-extension
(buffer-name buffer))
".resources"))
(defun markupserve-make-resource-directory ()
(interactive)
(if (buffer-file-name (current-buffer))
(let ((dirname (markupserve-resource-dir-for-buffer (current-buffer))))
(make-directory dirname)
@alexras
alexras / timed_kill.py
Created December 9, 2011 05:11
Execute a child process, redirecting its output and error to files. If it's not done after a predetermined number of seconds, KILL IT WITH FIRE. Tested on Python 2.4+
#!/usr/bin/env python
"""
Execute a child process, redirecting its output and error to files. If it's not
done after a predetermined number of seconds, KILL IT WITH FIRE
"""
from optparse import OptionParser
import shlex, subprocess, time, os, sys
@alexras
alexras / git_prune_remote.sh
Created December 17, 2011 00:30
Similar to gist:942899, deletes all remote branches that have already been merged into master. It's just a lot more nervous about doing the deletion.
#!/bin/bash
# -*- mode: shell-script -*-
EXPECTED_ARGS=1
if [ $# -ne ${EXPECTED_ARGS} ]
then
echo "Usage: git_prune_remote <remote name>"
exit 2
fi