Skip to content

Instantly share code, notes, and snippets.

@honza
honza / config.fish
Created April 24, 2014 18:17
Cabal Sandbox Fish Shell
function cabal_prompt
if [ -e "cabal.sandbox.config" ]
printf '(cabal sandbox)'
end
end

Keybase proof

I hereby claim:

  • I am honza on github.
  • I am honza (https://keybase.io/honza) on keybase.
  • I have a public key whose fingerprint is 70E0 3E0A A2E5 40EA A2FB 4422 67C0 AD96 97D5 AB41

To claim this, I am signing this object:

@honza
honza / fff.hs
Created March 17, 2014 16:04
Typeclasses
class Functor f where
fmap :: (a -> b) -> f a -> f b
class (Functor f) => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b
(<$>) :: (Functor f) => (a -> b) -> f a -> f b
class Monad m where
@honza
honza / Rocket.hs
Last active August 29, 2015 13:56
BSD/MIT licensed
-- This is a Haskell implementation of aphyr's
-- "Clojure from the ground up - modeling"
--
-- http://aphyr.com/posts/312-clojure-from-the-ground-up-modeling
--
-- Compile this with:
--
-- $ ghc -O Rocket.hs
import GHC.Exts
@honza
honza / update-keys.clj
Created February 4, 2014 10:32
Update keys
(defn update-keys [m ks f]
(let [g (fn [c k]
(update-in c [k] f))]
(reduce g m ks)))
(update-keys {:a 1 :b 2} [:a :b] inc)
;; => {:a 2 :b 3}
@honza
honza / loc2gpx
Created January 19, 2014 12:26
loc2pgx
#!/usr/bin/env python
"""
This script parses a geocaching.loc file and produces GPX files suitable
for loading into a GPS unit.
Usage:
$ ./loc2gpx geocaching.log
@honza
honza / wsgi.py
Created November 14, 2013 09:43
Django import fail
# This doesn't work
import os
from django.core.wsgi import get_wsgi_application
os.environ["DJANGO_SETTINGS_MODULE"] = "project.settings_staging"
application = get_wsgi_application()
# ... but this does?
import os
os.environ["DJANGO_SETTINGS_MODULE"] = "project.settings_staging"
from django.core.wsgi import get_wsgi_application
@honza
honza / get.py
Created October 3, 2013 06:23
Clojure's get-in in Python
"""
Clojure-inspired ``get_in`` function which gets value from nested dicts,
returning ``None`` if a key is not found.
"""
def get_in(obj, *keys):
for k in keys:
v = obj.get(k, None)
@honza
honza / gist.md
Created June 30, 2013 23:03
Clojure vs Haskell

Haskell vs Clojure

The JSON data is in the following format

{
    "Genesis": {
        "1": {
            "1": "In the beginning..." ,
            "2": "..."
@honza
honza / tweetable.md
Last active December 18, 2015 17:09
Tweetable Bible verses (ESV)

Total results: 17,257.

Genesis

1:1, 1:3, 1:4, 1:5, 1:6, 1:8, 1:10, 1:13, 1:15, 1:16, 1:17, 1:18, 1:19, 1:23, 1:27, 2:1, 2:3, 2:6, 2:8, 2:10, 2:11, 2:12, 2:13, 2:14, 2:15, 2:16, 2:17, 2:18, 2:22, 2:24, 2:25, 3:2, 3:4, 3:5, 3:9, 3:10, 3:11, 3:12, 3:13, 3:18, 3:20, 3:21, 3:23, 4:1, 4:2, 4:3, 4:5, 4:6, 4:8, 4:9, 4:10, 4:11, 4:12, 4:13, 4:16, 4:18, 4:19, 4:20, 4:21, 4:22, 4:24, 4:26, 5:1, 5:2, 5:3, 5:4, 5:5, 5:6, 5:7, 5:8, 5:9, 5:10, 5:11, 5:12, 5:13, 5:14, 5:15, 5:16, 5:17, 5:18, 5:19, 5:20, 5:21, 5:22, 5:23, 5:24, 5:25, 5:26, 5:27, 5:28, 5:30, 5:31, 5:32, 6:1, 6:2, 6:3, 6:6, 6:8, 6:9, 6:10, 6:11, 6:12, 6:14, 6:15, 6:21, 6:22, 7:3, 7:5, 7:6, 7:7, 7:8, 7:9, 7:10, 7:12, 7:15, 7:16, 7:17, 7:18, 7:19, 7:20, 7:22, 7:24, 8:2, 8:3, 8:4, 8:6, 8:7, 8:8, 8:10, 8:12, 8:14, 8:15, 8:16, 8:18, 8:19, 8:22, 9:1, 9:3, 9:4, 9:6, 9:7, 9:8, 9:9, 9:13, 9:14, 9:17, 9:18, 9:19, 9:20, 9:21, 9:22, 9:24, 9:25, 9:26, 9:27, 9:28, 9:29, 10:1, 10:2, 10:3, 10:4, 10:5, 10:6, 10:7, 10:8, 10:9, 10:10, 10:11, 10:12, 10:13, 10:14, 10:15,