Skip to content

Instantly share code, notes, and snippets.

View elrikdante's full-sized avatar

Dante Haskell Elrik elrikdante

View GitHub Profile
@elrikdante
elrikdante / hspec-before-all.hs
Created March 7, 2016 05:06 — forked from nh2/hspec-before-all.hs
Example of ignoring hspec's beforeAll hook context
import Control.Concurrent (threadDelay)
import Test.Hspec
import qualified Test.Hspec.Core.Hooks as Hooks
main :: IO ()
main = hspec spec
-- | When a hook is set up with `beforeAll`, that changes the type
@elrikdante
elrikdante / iso6801-duration.hs
Created March 7, 2016 05:02 — forked from nh2/iso6801-duration.hs
Haskell module for parsing ISO8601 durations
{-# LANGUAGE ScopedTypeVariables #-}
module Data.Time.ISO8601.Duration where
import Control.Applicative
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as BS8
import Data.Attoparsec.ByteString.Char8
import Test.QuickCheck
@elrikdante
elrikdante / geo_world_map_migration
Created December 30, 2015 05:31 — forked from scicco/geo_world_map_migration
Rails migration for GeoWorldMap db into postgresql db
class CreatePlaces < ActiveRecord::Migration
# Rails migration for GeoWorldMap db into postgresql db
#(inspired by http://blog.inspired.no/populate-your-database-with-free-world-cities-countries-regions-in-2-minutes-using-a-rails-migration-273/ post)
#extract files from GeoWorldMap.zip archive from here
# http://www.geobytes.com/GeoWorldMap.zip
#
#and place them into #{Rails.root}/db/migrate/
##the archive has 'cities.txt' file, rename it 'Cities.txt'
#mv cities.txt Cities.txt
@elrikdante
elrikdante / AlaCarte.hs
Created December 13, 2015 04:14 — forked from puffnfresh/AlaCarte.hs
Coproduct to combine algebras for a free monad interpreter.
module AlaCarte where
-- Control.Monad.Free
data Free f a = Free (f (Free f a)) | Pure a
instance Functor f => Monad (Free f) where
Pure a >>= f = f a
Free r >>= f = Free (fmap (>>= f) r)
return = Pure