Skip to content

Instantly share code, notes, and snippets.

@erantapaa
erantapaa / process-hoogle.hs
Created October 24, 2015 15:47
processing a .tar.gz file
{-# LANGUAGE OverloadedStrings #-}
-- build-depends: tar, bytestring, zlib
-- Example of how to iterate through a .tar.gz file
module Lib
where
import qualified Codec.Archive.Tar as Tar
@erantapaa
erantapaa / build-threadscope.sh
Last active October 22, 2015 22:01
building threadscope
# Script to install threadscope.
#
# Also see:
# - http://www.edsko.net/2015/03/09/sandboxes-revisited/
# - http://stackoverflow.com/a/33105802/866915
cabal sandbox init
export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig
brew install gtk+
brew install poppler
@erantapaa
erantapaa / upload-hackage-docs.sh
Created October 21, 2015 15:57
upload docs to Hackage
#!/bin/bash
#
# Found at: https://github.com/andrewthad/lens-prelude/blob/master/scripts/hackage-docs.sh
set -e
if [ "$#" -ne 1 ]; then
echo "Usage: scripts/hackage-docs.sh HACKAGE_USER"
exit 1
fi
@erantapaa
erantapaa / NOTES.md
Created October 21, 2015 15:32
installing etsy/hound
brew install golang

# For info on building go programs, see: https://golang.org/doc/code.html#GOPATH
mkdir build-hound
cd build-hound
mkdir src bin
export GOPATH=$PWD
export PATH=$GOPATH/bin

mkdir -p src/github.com/etsy

@erantapaa
erantapaa / NOTES.md
Last active September 29, 2020 23:31
building cgit on OS X
brew install gettext

git clone git://git.zx2c4.com/cgit
cd cgit
git submodule init
git submodule update

Then modify the definitions of CFLAGS and LDFLAGS in git/Makefile:

@erantapaa
erantapaa / pipes-file-example.hs
Created October 21, 2015 10:10
pipes-file example
import Pipes
import Pipes.Files
import Pipes.Safe
import Data.Monoid
import Data.Time.Clock
import System.Posix.Files.ByteString ( fileSize )
example = do
let megs = 1024 * 1024
days = 86400
@erantapaa
erantapaa / pretty-html-conduit.hs
Created October 20, 2015 16:54
pretty printing HTML with Conduit
{-# LANGUAGE NoMonomorphismRestriction #-}
-- build-depends: base >= 4.7 && < 5, xml-conduit, text, conduit, transformers, resourcet, html-conduit, conduit-extra
module Lib
where
import qualified Text.XML.Stream.Parse as P
import qualified Text.XML.Stream.Render as R
import qualified Data.Conduit.List as CL
@erantapaa
erantapaa / Timed.hs
Last active April 14, 2024 15:31
non-blocking I/O examples in Haskell
import System.Environment
import System.Timeout (timeout)
import Control.Concurrent
import Control.Concurrent (forkIO, threadDelay, killThread)
import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)
import System.Process
import System.IO
-- blocking IO
@erantapaa
erantapaa / oralist-examples.lhs
Last active October 9, 2015 10:56
ordlist example
A gist collecting examples of how to use `Data.List.Ordered`
> import Data.List.Ordered
Sieve of Eratosthenes
===
From the Haskellwiki entry on the [Sieve of Eratosthenes][HaskellWikiSieve]:
@erantapaa
erantapaa / bowl.lhs
Last active November 8, 2015 13:26
using parsec to score a bowling game
Using Parsec to score a bowling game.
===
In this gist we'll see how to use Parsec to solve the problem of
scoring a bowling game. This was inspired by a
Reddit Daily Programmer problem:
https://www.reddit.com/r/dailyprogrammer/comments/3ntsni/20151007_challenge_235_intermediate_scoring_a/