Skip to content

Instantly share code, notes, and snippets.

View thumphries's full-sized avatar

Tim Humphries thumphries

View GitHub Profile
@thumphries
thumphries / ckill
Created January 27, 2013 15:51
cocoa kill - useful for killing Mac OS X GUI applications. (Use with care!)
#!/bin/sh
if [ -z $1 ]; then echo "$0: Please supply a label"; exit 1; fi
launchctl list | grep -i "$1" | cut -f1 | grep -ve "^-" | xargs kill
@thumphries
thumphries / loadavg.c
Created October 9, 2012 02:12
proper load average binary for OS X / BSD
// loadavg.c
// Simple load average spewer for BSDs and Mac OS X
// tim at utf8.me
// (Why is there no system binary for this?)
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
double loads[3] = {0};
@thumphries
thumphries / xdefaults2iterm.pl
Created October 8, 2012 03:27
Convert your terminal colours / Xdefaults to iTerm2 color scheme
#!/usr/bin/perl -w
# Convert .Xdefaults or similar terminal colors to iTerm2 scheme
# Only supports simple hex colors, no funny stuff
use strict;
print <<eof;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
#!/bin/bash
baseu="http://www.handbook.unsw.edu.au/vbook2012/brCoursesByAtoZ.jsp?StudyLevel=Undergraduate&descr="
basep="http://www.handbook.unsw.edu.au/vbook2012/brCoursesByAtoZ.jsp?StudyLevel=Postgraduate&descr="
if [[ ! $1 =~ ^[A-Z]{4} ]] || [ $# -eq 0 ]; then
echo "Usage: ./$0 TYPE"
else
baseu+="${1:0:1}"
basep+="${1:0:1}"
wget -q -O- $baseu $basep | w3m -dump -cols 150 -T "text/html" | grep -e "^$1" | sort | uniq | \
sed -re "s/[ \t]+[0-9]+$//g;s/[ \t]{2,}/ /g"