Skip to content

Instantly share code, notes, and snippets.

View rrnewton's full-sized avatar

Ryan Newton rrnewton

View GitHub Profile
@rrnewton
rrnewton / gist:7722109
Created November 30, 2013 17:49
Problems with import rows on fusion tables
This HTTP-conduit request:
Request {
host = "www.googleapis.com"
port = 443
secure = True
clientCertificates = []
requestHeaders = [("Gdata-version","999"),("Authorization","OAuth ya29.1.AADtN_XQl-SEQTTY39WMzrIZE_Vks4cF5bjUJ2FQvv42KPPGtx8GgeEbjMl1RcQ")]
path = "fusiontables/v1/tables/1R4x_Dqa0p5BoLBKX5sENGh4kkbGZhUVli_APIOw/import"
queryString = ""
@rrnewton
rrnewton / gist:7619107
Created November 23, 2013 19:50
An idris warm-up. Show this finite function forms a semi-lattice.
data AndState = Bot | TrueBot | BotTrue | TrueTrue | F
total
myjoin : AndState -> AndState -> AndState
myjoin TrueBot BotTrue = TrueTrue
myjoin TrueTrue TrueBot = TrueTrue
myjoin TrueTrue BotTrue = TrueTrue
myjoin Bot x = x
myjoin F _ = F
-- myjoin x y = myjoin y x
@rrnewton
rrnewton / RunParThenFreeze.hs
Created September 25, 2013 14:53
Attempt to design "runParThenFreeze"
{-# LANGUAGE RankNTypes, DataKinds, KindSignatures, MagicHash, CPP, DefaultSignatures #-}
{-# LANGUAGE TypeFamilies, TypeSynonymInstances, FlexibleInstances #-}
import GHC.Prim (unsafeCoerce#)
#if 0
import Control.LVish
import Data.LVar.IVar as IV
#else
@rrnewton
rrnewton / gist:6511352
Created September 10, 2013 15:45
proto services
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: fusiontables_v1_services.proto
package fusiontables;
public final class FusiontablesV1Services {
private FusiontablesV1Services() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
}
@rrnewton
rrnewton / bootstrap_ghc_dev.sh
Created August 21, 2013 14:32
Bash script to bootstrap GHC development within an Ubuntu 12.04 virtual machine.
#!/bin/bash
set -e
set -x
sudo apt-get install -y git gcc make autoconf libtool zlib1g-dev libgl1-mesa-dev libglu1-mesa libglu1-mesa-dev freeglut3-dev libncurses-dev libgmp-dev
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/
sudo ln -s /usr/lib/x86_64-linux-gnu/libgmp.so.10 /usr/lib/libgmp.so.3
sudo ln -s /usr/lib/x86_64-linux-gnu/libgmp.so.10 /usr/lib/libgmp.so
@rrnewton
rrnewton / MapTest2.hs
Last active December 19, 2015 06:39
MapTest extended with Shachaf's suggestion
import Control.Applicative
import Control.Monad
import Control.DeepSeq
import Control.Exception
import GHC.Stats
import qualified Data.Map.Strict as M
import Data.Time.Clock
import Data.Monoid
import System.Mem
@rrnewton
rrnewton / MapTest.ddump-simple
Last active December 19, 2015 06:39
GHC Core generated when using foldrWithKey to build up a monadic action to consume a large Map.
Result size of Tidy Core = {terms: 423, types: 423, coercions: 39}
lvl_r2uH :: [GHC.Types.Char]
[GblId, Str=DmdType]
lvl_r2uH = GHC.CString.unpackCString# "Got it!"
Rec {
Main.$sinsert_$s$sgo6 [Occ=LoopBreaker]
:: forall a1_X12s.
GHC.Prim.Int#
@rrnewton
rrnewton / Make_output
Last active December 19, 2015 05:09
Example output when compiling and running a GHC bug reproducer relating to getNumCapabilities.
rm -f *.o *.hi bugged.exe unbugged.exe
rm -rf ./bugged_dumps ./unbugged_dumps/
ghc -DACTIVATE_BUG -keep-tmp-files -dsuppress-module-prefixes -ddump-to-file -ddump-core-stats -ddump-simpl-stats -dcore-lint -dcmm-lint -ddump-ds -ddump-simpl -ddump-stg -ddump-asm -ddump-bcos -ddump-cmm -ddump-opt-cmm -ddump-inlinings -rtsopts -fforce-recomp -O2 -threaded PBBS.hs -main-is Util.PBBS.t4 -o bugged.exe
[1 of 1] Compiling Util.PBBS ( PBBS.hs, PBBS.o )
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
Inlining done: D:NFData{v r4f} [gid[DataConWrapper]]
@rrnewton
rrnewton / example_output.txt
Last active December 17, 2015 20:29
Example output from a very simple hsbencher run.
$ cat > minimal.hs
import HSBencher
main = defaultMainWithBechmarks
[ mkBenchmark "bench1/bench1.cabal" ["1000"] $
Or [ Set NoMeaning (RuntimeParam "+RTS -qa -RTS")
, Set NoMeaning (RuntimeEnv "HELLO" "yes") ] ]
$ runghc minimal.hs
* Executing: hostname -s --> 1 line(s)
* Executing: git name-rev --name-only HEAD --> 1 line(s)
@rrnewton
rrnewton / double_read_WRONG.hs
Created April 2, 2013 17:39
An example of a concurrency bug that is upstream from the point of the concurrentMerge.
import qualified System.IO.Streams as S
import System.IO.Streams.Concurrent
import Control.Concurrent
import Data.IORef
import Data.ByteString.Char8 as B
main = do
cnt <- newIORef 0
s1 <- S.makeInputStream $ do