Skip to content

Instantly share code, notes, and snippets.

View bitemyapp's full-sized avatar
🐺
aroo

Chris A. bitemyapp

🐺
aroo
View GitHub Profile
λ> import Unsafe.Coerce
λ> let isJust' = unsafeCoerce :: Maybe a -> Bool
λ> isJust' $ Just 1
True
λ> isJust' $ Nothing
False
@bitemyapp
bitemyapp / gist:8810135
Created February 4, 2014 19:04
Examples of my glorious commit messages
heap stuff
trailing slashes in URLs are the bane of programmer sanity
docstrings
helps if you add the bloody migration
merged
inheritance is copy-pasta
persona
decent start
well that was unnecessary
god dammit mixpanel
08:01 < prophile> unsafePerformIO is such an unwieldy name, I think it should be called 'run'
08:01 < bitemyapp> prophile: evil haskell tip
08:01 < bitemyapp> prophile: alias unsafePerformIO to run so you can use it more.
@bitemyapp
bitemyapp / gist:9028726
Created February 16, 2014 03:15
Don't debug

Debugging is reification of manual and tedious imperative traversal of logic.

Don't debug.

Decompose and interrogate - coarse and fine.

λ> let blah = 1
λ> let blah = 2
λ> blah
2
λ> let blah x = x
λ> blah 1
1
λ> :t blah
blah :: t -> t
λ> let (blah x = x) :: Int -> Int
import Control.Lens
dna = "CCATATGGGACGAATCAAAGGTTTGCCAATCACCCAAATGTCCAGTGAGGATAACGAAGACATTACGCCACCCTAGTATGAGGGCTTTATTTCGGAATAACTCTTATACTGCCATCCTGTACCACGGGGATCATAATTAAGGATCCAAGGTTAGAACGGGTTCCCCCGACGGGGCCACAACTTCCTCGCCTAGCACTCCTGCGGTCTCACGCATAAGGCACATACGAGCTGAGAAAGGGTACACCTCATGAAATGAGCGGCGACCCGCATCACCGTACTGCGCTGATCCGCAACCATTCGAAAATGATCTGGTCATCTGGGTTGTAAAACCTCGCTTGGCGGCCCGTCAGGCAAGTCGCTCATATGAACTACGCTCAGCGGCCCCTGGAGTGGTCGTGTGTCGAGTATGTGGGAGAAACACTAGGGCCATCCTTGCTAACACCACGCCGAGACAAGTTGCTTGAGCAGTTACGGTGTGCCTTGAATTCTGTGGAAGAACAGAGTGCGAGGCTGCATAGTCAGTAGAATTAGGCCTGCAGGTGCCGTCACTAATTTGATATCAGTCCAGCCACGGCGTTTGAATACAATGTTGTCGAGCCTCATCCCGACACCATGAGATCGTGAGCACTGTACAGTCTCCAGACAGATGTCATTGGTTTTCTGGGTTTCAGTTAGTCCCTTAGTACGGTCTGGAACACACCTACACCGGGCAATCTCGGTCACTAGCTAGTAATAAACGGTCGTTGCCGGCATGGTGTCTTGCTGCGGAAAGAGTCCGTTGTGTAGAGTAACTCGAAATCGCCTATAAATCCAAATCTCCGAGACCGCCCGCGACTGCATTGTTATATAC"
data Nucleobase = A | G | C | T
data Counter = Counter {_a :: Int, _g :: Int, _c :: Int, _t :: Int} deriving (Show)
makeLenses ''Counter
pickN
@bitemyapp
bitemyapp / gist:9629513
Last active August 29, 2015 13:57
Database data structuring question

I need to normalize relative ordering of the contents of an array into something that can be efficiently indexed and queried against.

Given data: [".content", "blah", "woo"] that should be discovered by a query ".content" FOLLOWED_BY "woo"

Note the sparseness. It's contingent on the relative ordering of the elements, not the absolute values of the indexes.

I'm trying to figure out if there's a way to represent the relative ordering as neatly indexable, absolute values.

To index these relative positions I would have to index an explosion of paired off values. [".content", "blah", "woo"] would return into (".content", "blah", OBJ_ID), (".content", "woo", OBJ_ID), ("blah", "woo", OBJ_ID).

[callen@localhost ~/code/lambdabot-4.3.0.1]$ cabal install -v2 --max-backjumps=-1
Using a sandbox located at /Users/callen/code/lambdabot-4.3.0.1/.cabal-sandbox
Reading available packages...
Reading available packages...
Reading installed packages...
'/usr/bin/ghc-pkg' 'dump' '--package-db=/Users/callen/code/lambdabot-4.3.0.1/.cabal-sandbox/x86_64-osx-ghc-7.6.3-packages.conf.d' '-v0'
'/usr/bin/ghc' '--print-libdir'
Reading available packages...
Choosing modular solver.
Resolving dependencies...
ghc-mod-3.1.5
fay-0.19.0.1
haskell-names-0.3.2.4
haskell-packages-0.2.3.3
ghc-mod-3.1.4
bin-package-db-0.0.0.0
ghc-7.6.3
fay-base-0.19
ihaskell-0.3.0.2
ghc-parser-0.1.0.0
Building happy-1.19.3...
Preprocessing executable 'happy' for happy-1.19.3...
[ 1 of 18] Compiling NameSet ( src/NameSet.hs, dist/dist-sandbox-57cd0ffb/build/happy/happy-tmp/NameSet.o )
src/NameSet.hs:7:1: Warning:
The import of ‘Prelude’ is redundant
except perhaps to import instances from ‘Prelude’
To import instances alone, use: import Prelude()
[ 2 of 18] Compiling Target ( src/Target.lhs, dist/dist-sandbox-57cd0ffb/build/happy/happy-tmp/Target.o )
[ 3 of 18] Compiling AbsSyn ( src/AbsSyn.lhs, dist/dist-sandbox-57cd0ffb/build/happy/happy-tmp/AbsSyn.o )