Skip to content

Instantly share code, notes, and snippets.

View thumphries's full-sized avatar

Tim Humphries thumphries

View GitHub Profile
#!/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"
@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">
@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 / 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 / QR.hs
Last active August 29, 2015 14:06
{-# LANGUAGE OverloadedStrings #-}
import Data.QRCode
import Data.Text (Text, pack, unpack)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Word8
import System.Environment
import System.IO
@thumphries
thumphries / Client.config
Last active August 29, 2015 14:17
HaLVM XenStore bug
name = "Client"
kernel = "Client"
memory = 16
seclabel ='system_u:system_r:domU_t'
@thumphries
thumphries / Client.config
Last active August 29, 2015 14:17
HaLVM IOM/scheduler bug
name = "Client"
kernel = "Client"
memory = 16
seclabel ='system_u:system_r:domU_t'
@thumphries
thumphries / quickstart.md
Last active April 26, 2016 23:55
Mafia quick start

Mafia Quick Start

Mafia is a wrapper for cabal-install that eliminates most of the pain points, without the need for a blessed set of packages.

Install, use, upgrade

Put the wrapper script somewhere on your path:

cd $HOME/bin &amp;&amp; wget https://raw.githubusercontent.com/ambiata/mafia/master/script/mafia
@thumphries
thumphries / ghc-cross-linux-darwin.md
Created June 2, 2016 00:54
GHC cross-compilation

Notes on cross-compiling GHC for a Darwin target.

TL;DR I managed to get most of a stage1 to build. I got a linker failure during ghc-prim, but most of the libraries had already built successfully, including some C FFI-heavy packages like bytestring. I suspect my toolchain was just in the wrong spot, and/or libraries misconfigured.

  • We need a normal host GCC toolchain (build-essential), autoconf, happy, alex, and a platform copy of GHC (the Stage0).
  • As per the GHC CrossCompiling page on Trac, we need a GCC crosschain. I used osxcross.
@thumphries
thumphries / Dockerfile-7.10.3
Last active July 6, 2016 13:12
ghc-musl bootstrapping
FROM alpine:latest
COPY build.mk /tmp/
RUN apk add --update curl xz alpine-sdk perl gmp-dev file gmp openssh openssl zlib-dev strace vim less jq ncurses-dev bash autoconf
RUN cd /tmp && \
wget http://ghc-musl-dist-apse2.s3-website-ap-southeast-2.amazonaws.com/ghc-7.8.4/ghc-7.8.4-x86_64-unknown-linux.tar.bz2 && \
tar xvf ghc*.tar.bz2 && \
cd ghc-7.8.4 && \