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
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
abstract-deque-0.3
abstract-par-0.3.3
acid-state-0.14.2-b0a14c9b7efb1ffc84302b7fbc879ab6cdd987ae
adjunctions-4.4
aeson-1.2.4.0
aeson-compat-0.3.8
aeson-diff-1.1.0.5
aeson-extra-0.4.1.0
aeson-pretty-0.8.7
ansi-terminal-0.8.0.4
@erikd
erikd / cabal.project
Created Jun 15, 2018
cabal.project file for cardano-sl
View cabal.project
packages:
networking/cardano-sl-networking.cabal
, 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
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
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 : https://plus.google.com/u/0/+DobesVandermeer/posts/bTgxxsVkRwY
-- All of the ideas here are from the exercises for the NICTA Haskell course
-- available here : https://github.com/NICTA/course
-- 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.
--------------------------------------------------------------------------------
View keybase.md

Keybase proof

I hereby claim:

  • I am erikd on github.
  • I am erikd (https://keybase.io/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
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
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="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:annotation>
<xs:documentation xml:lang="en">Jenkins xUnit test result schema.
</xs:documentation>
</xs:annotation>
<xs:element name="testsuite" type="testsuite"/>
@erikd
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
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.