Skip to content

Instantly share code, notes, and snippets.

View bitemyapp's full-sized avatar
馃惡
aroo

Chris A. bitemyapp

馃惡
aroo
View GitHub Profile
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
位> 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
@bitemyapp
bitemyapp / gist:9402223
Last active June 24, 2016 14:25
Getting Scala users moved over

Play Framework vs. the relative messiness of Yesod/Snap/Happstack/Scotty/raw WAI. Clojure has a similar (to Haskell's) story here. I'm understating it here, but this is pretty big. Most web applications are not special snowflakes, a framework to wrap-up common-case nonsense concisely is very valuable. Micro-framework stacks like using WAI directly or Scotty are good to have, but insufficient.

Specialized NLP libraries (in Java, at present) such as for medical lexicons. Might be replicable by being layered on top of existing Haskell NLP libs, but doesn't yet exist to my knowledge. Hardening up libraries like this usually takes a lot of time.

Slick is nicer and easier to get started with than Persistent. Partly due to documentation, partly because Slick isn't silly and embraces relational databases directly, partly because Persistent is just kind of hairy. Supporting MongoDB isn't a plus, it's a minus. Compromises the API anyway.

A migrations library of pretty much any sort at all.

Scala/xml equivalent i

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...