Skip to content

Instantly share code, notes, and snippets.

View thumphries's full-sized avatar

Tim Humphries thumphries

View GitHub Profile
build/
node_modules/
@thumphries
thumphries / Getting.hs
Created October 4, 2017 12:38
Simulating first-class patterns by combining prisms into `Getting First`
{-# 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 August 24, 2017 05:56
Demonstration of SIMD performance gap
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 04:17
Example of a redirect vulnerability
{-# 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 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 && \
@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 / 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 / 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 / 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 / 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