Skip to content

Instantly share code, notes, and snippets.

@bos
bos / pygit2.patch
Created March 14, 2012 03:59
5x to 8x speedup in "hg convert"
# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# Date 1331697209 25200
# Branch stable
# Node ID 9c15f20c0418fbad1da202f72dc894372538beba
# Parent 6344043924497cd06d781d9014c66802285072e4
imported patch libgit2.patch
diff -r 634404392449 -r 9c15f20c0418 hgext/convert/git.py
--- a/hgext/convert/git.py Sun Jan 01 13:37:30 2012 -0600
@bos
bos / index.patch
Created March 14, 2012 22:14
incremental parsing for mercurial index
# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# Date 1331763158 25200
# Branch stable
# Node ID 268ae4d69a012f47cb1ef2bf65a8a96f561ce672
# Parent ca5cc2976574d820dad5774afd8c7b3c39ec11cd
[WIP] lazy index file parser
Only parse entries in a revlog index file when they are actually needed.
@bos
bos / AesonPlayground.hs
Last active October 18, 2016 13:56
A proof-of-concept of a new approach to encoding JSON values for aeson.
{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances,
OverloadedStrings #-}
import Data.Monoid (Monoid(..), (<>))
import Data.String (IsString(..))
import Data.Text (Text)
import Data.Text.Lazy.Builder (Builder, singleton)
import qualified Data.Text.Lazy.Builder as Bld
import qualified Data.Text.Lazy.Builder.Int as Bld
basicPost = do
r <- post "http://httpbin.org/post" (binary "wibble") >>= json
let body = r^.responseBody :: Value
assertEqual "POST succeeds" status200 (r ^. responseStatus)
assertEqual "POST echoes input" (Just "wibble") (body ^? key "data")
assertEqual "POST is binary" (Just "application/octet-stream")
(body ^? key "headers" . key "Content-Type")