Skip to content

Instantly share code, notes, and snippets.

@nkpart
nkpart / CrazyIO.hs
Created February 3, 2015 02:47
CrazyIO - binary deserialization using mmaped I/O and Data.Vector.Storable
{-# LANGUAGE ScopedTypeVariables #-}
module CrazyIO (module CrazyIO, mmapFileByteString) where
import qualified Data.Vector.Storable as V
import qualified Data.ByteString as BS
import qualified Data.ByteString.Internal as BS
import Foreign
import System.IO.MMap
crazyLoad :: forall a. Storable a => FilePath -> Maybe (Int64, Int) -> IO (V.Vector a)
@ion1
ion1 / ListCat.hs
Created March 4, 2012 21:54
A toy category instance for monoids
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
import Overture
import Prelude ()
data Foo m a b where
Foo :: m -> Foo m a a
instance Show m => Show (Foo m a a) where
@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()