Skip to content

Instantly share code, notes, and snippets.

@spl
spl / keybase.md
Created October 15, 2014 14:11
keybase.md

Keybase proof

I hereby claim:

  • I am spl on github.
  • I am seanleather (https://keybase.io/seanleather) on keybase.
  • I have a public key whose fingerprint is FBC2 C295 60BE A74A D943 B84A 8841 5DD3 E6DE AB1D

To claim this, I am signing this object:

@spl
spl / ToBoundedIntegral.hs
Last active August 29, 2015 14:09
toBoundedIntegral: an adaptation of fromIntegral that respects bounds
{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
#include "MachDeps.h"
import GHC.Base
import GHC.Int
import GHC.Word
import Foreign.C.Types
@spl
spl / EitherFail.hs
Last active October 5, 2015 18:09
Either fail
$ ghci
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
-- This is a similar to a function found in some library somewhere.
Prelude> let lookupM k v = maybe (fail $ show k ++ " not found in " ++ show v) return $ lookup k v
Prelude> :t lookupM
lookupM
:: (Eq a1, Monad m, Show a, Show a1) => a1 -> [(a1, a)] -> m a
-- What happens when you use Either as the monad?
@spl
spl / copy.hs
Last active December 16, 2015 02:19
This is a simple file to demonstrate how to copy an input file to an output file in Shake. It was written with Shake 0.10.2.
{-# OPTIONS_GHC -Wall #-}
module Main where
import Development.Shake
main :: IO ()
main = shakeArgs shakeOptions $ do
want ["output-file"]
"output-file" *> \dst ->
copyFile' "input-file" dst
@spl
spl / copyWithDependency.hs
Last active December 16, 2015 02:38
This is a simple example of using Shake (version 0.10.2). It demonstrates how to copy an input file to an output file with a file that is an additional dependency for a target even though it is not used in the rule itself.
{-# OPTIONS_GHC -Wall #-}
module Main where
import Development.Shake
main :: IO ()
main = shakeArgs shakeOptions $ do
want ["output-file"]
"output-file" *> \dst -> do
need ["dependency-file"]
copyFile' "input-file" dst
@spl
spl / Main.hs
Last active December 26, 2015 11:29
Test case for cabal sandbox+repl bug with Ctrl-C
module Main where
import System.Console.Haskeline
import System.Environment
import Control.Exception (AsyncException(..))
{--
Testing the line-input functions and their interaction with ctrl-c signals.
Usage:
@spl
spl / ovpn-writer.sh
Created January 5, 2016 15:23 — forked from renatolfc/ovpn-writer.sh
Script to generate an OpenVPN client configuration file in the unified format
#!/bin/sh
##
## Usage: ./ovpn-writer.sh SERVER CA_CERT CLIENT_CERT CLIENT_KEY SHARED_SECRET > client.ovpn
##
server=${1?"The server address is required"}
cacert=${2?"The path to the ca certificate file is required"}
client_cert=${3?"The path to the client certificate file is required"}
client_key=${4?"The path to the client private key file is required"}
@spl
spl / instance_comparison.lean
Last active April 4, 2016 15:59
Type class instance comparison with/-out naming, with/-out include
/-
First, we add the necessary preliminary declarations:
-/
import data.list
open list
variable {A : Type}
/-
@spl
spl / .project
Last active July 31, 2016 14:08
Import and use a class without open in Lean
+ *.lean
- flycheck*.lean
- .#*.lean
@spl
spl / math.vim
Created August 3, 2016 17:24
Vim unicode TeX key bindings
" Originally from Dan Piponi
:map! \lolly ⊸
:map! \comp ∁
:map! \turn& ⅋
:map! \lneg ⅂
:map! \union ∪
:map! \cup ∪
:map! \cap ∩
:map! \alpha α
:map! \alpha α