Skip to content

Instantly share code, notes, and snippets.

Erik de Castro Lopo erikd

Block or report user

Report or block erikd

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
erikd / storable-vector.hs
Last active Aug 14, 2018
Write Storable Vector to disk
View storable-vector.hs
import Data.Vector.Storable (Storable, Vector)
import qualified Data.Vector.Storable as SVector
import Data.Word (Word32)
import Foreign.ForeignPtr (mallocForeignPtrArray0, withForeignPtr)
import Foreign.Storable (sizeOf)
-- Need this so it builds on Posix and Windows!!!!
import GHC.IO.Handle (hFileSize)
View gist:3033a37565851d01efa6aec808f69c3b
erikd / cabal.project
Created Jun 15, 2018
cabal.project file for cardano-sl
View cabal.project
, binary/cardano-sl-binary.cabal
, binary/test/cardano-sl-binary-test.cabal
, util/cardano-sl-util.cabal
, util/test/cardano-sl-util-test.cabal
, crypto/cardano-sl-crypto.cabal
, crypto/test/cardano-sl-crypto-test.cabal
, core/cardano-sl-core.cabal
, core/test/cardano-sl-core-test.cabal
erikd / pretty-print-sql.hs
Created Jul 22, 2014
Pretty print Persistent debug SQL statements
View pretty-print-sql.hs
#!/usr/bin/runghc -Wall
-- Trivial little script to pretty-print safe SQL from Yesod's logging mechanism.
-- It can be run simply using:
-- prety-print-sql.hs <SQL statement string>
import System.Environment (getArgs, getProgName)
import System.Exit (exitSuccess)
erikd / functor-list-maybe.hs
Created Jun 13, 2014
Re-implement Haskell's List and Maybe types (plus a generic fmap) in Haskell.
View functor-list-maybe.hs
-- In response to :
-- All of the ideas here are from the exercises for the NICTA Haskell course
-- available here :
-- Basically we re-implement, from scratch, the List and Maybe types, the
-- Functor typeclass, the Functor instances of our List and Maybe type and then
-- write a little program to use them.

Keybase proof

I hereby claim:

  • I am erikd on github.
  • I am erikd ( on keybase.
  • I have a public key whose fingerprint is 6A91 A5CF 22C2 4C99 A35E 013F CFDC F91F B242 ACED

To claim this, I am signing this object:

erikd / gist:9518636
Created Mar 12, 2014
Nested resource proof of concept
View gist:9518636
import Control.Monad.State.Strict
type NestedResourceM a = StateT [IO a] IO a
main :: IO ()
main = runNestedResource $ do
nestIO (putStrLn "Do A") (putStrLn "Undo A")
nestIO (putStrLn "Do B") (putStrLn "Undo B")
erikd / xunit.xsd
Created Dec 3, 2012
xUnit XML Schema (XSD)
View xunit.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs=""
<xs:documentation xml:lang="en">Jenkins xUnit test result schema.
<xs:element name="testsuite" type="testsuite"/>
erikd / warp-tls-test.hs
Created Feb 8, 2012
Test/demo program for WarpTLS
View warp-tls-test.hs
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.Trans.Resource
import Network.TLS
import Network.Wai
import Network.Wai.Handler.Warp
import Network.Wai.Handler.WarpTLS
import Blaze.ByteString.Builder (fromByteString)
import Control.Concurrent (forkIO, killThread)
erikd / readInt.hs
Created Jan 23, 2012
Benchmarking and QuickChecking readInt.
View readInt.hs
{-# LANGUAGE OverloadedStrings #-}
-- A program to QuickCheck and benchmark a function used in the Warp web server
-- and elsewhere to read the Content-Length field of HTTP headers.
-- Compile and run as:
-- ghc -Wall -O3 --make readInt.hs -o readInt && ./readInt
import Criterion.Main
import Data.ByteString (ByteString)
You can’t perform that action at this time.