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
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
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
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
thumphries / Dockerfile-7.10.3
Last active Jul 6, 2016
ghc-musl bootstrapping
View Dockerfile-7.10.3
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 && \
View ghc-cross-linux-darwin.md

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 / quickstart.md
Last active Apr 26, 2016
Mafia quick start
View quickstart.md

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 https://raw.githubusercontent.com/ambiata/mafia/master/script/mafia
@thumphries
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
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
thumphries / ckill
Created Jan 27, 2013
cocoa kill - useful for killing Mac OS X GUI applications. (Use with care!)
View ckill
#!/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
You can’t perform that action at this time.