Skip to content

Instantly share code, notes, and snippets.

Tim Humphries thumphries

Block or report user

Report or block thumphries

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
thumphries / Getting.hs
Created Oct 4, 2017
Simulating first-class patterns by combining prisms into `Getting First`
View Getting.hs
{-# LANGUAGE TemplateHaskell #-}
module Lens where
import Control.Lens
import Data.Monoid (First, (<>))
data FooBar =
Foo (Either Int Bool)
| Bar (Maybe Bool)
thumphries / Bench.hs
Created Aug 24, 2017
Demonstration of SIMD performance gap
View Bench.hs
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as B8
import Criterion.Main
import Criterion.Types (Config (..))
import qualified Mystery
thumphries / client.hs
Last active May 11, 2018
Example of a redirect vulnerability
View client.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
import Control.Applicative
import Control.Lens
import Control.Monad
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as BSL
import qualified Data.IORef as IORef
thumphries / Dockerfile-7.10.3
Last active Jul 6, 2016
ghc-musl bootstrapping
View Dockerfile-7.10.3
FROM alpine:latest
COPY /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 && \
tar xvf ghc*.tar.bz2 && \
cd ghc-7.8.4 && \

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 /
Last active Apr 26, 2016
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 && wget
thumphries / Client.config
Last active Aug 29, 2015
HaLVM IOM/scheduler bug
View Client.config
name = "Client"
kernel = "Client"
memory = 16
seclabel ='system_u:system_r:domU_t'
thumphries / Client.config
Last active Aug 29, 2015
HaLVM XenStore bug
View Client.config
name = "Client"
kernel = "Client"
memory = 16
seclabel ='system_u:system_r:domU_t'
View QR.hs
{-# 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 / ckill
Created Jan 27, 2013
cocoa kill - useful for killing Mac OS X GUI applications. (Use with care!)
View ckill
if [ -z $1 ]; then echo "$0: Please supply a label"; exit 1; fi
launchctl list | grep -i "$1" | cut -f1 | grep -ve "^-" | xargs kill
You can’t perform that action at this time.