Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/runhaskell
import Data.Char
translate_char tmap c = helper tmap where
helper [] = c
helper ((c',ct):ps)
| c == c' = ct
| otherwise = helper ps
translate_string tmap = map $ translate_char tmap
@MichaelBlume
MichaelBlume / find-in.clj
Last active August 29, 2015 14:06
Find-in
; http://an-animal-imagined-by-poe.tumblr.com/post/97790330928/i-have-been-busy-distracted-absent-for-the-past
(defn find-in
([needle haystack] (find-in needle haystack 'x))
([needle haystack varname]
; varname remminds us of how we got the haystack we're looking at from x
(or
; base case
(when (= needle haystack)
varname)
(defn swap-out! [a new-val]
(loop []
(let [old-val @a]
(if (compare-and-set! a old-val new-val)
old-val
(recur)))))
execute pathogen#infect()
let g:paredit_electric_return=0
let g:lisp_rainbow = 1
set nocompatible
" create a backup of files when editing in /tmp
set backupdir=~/tmp
" swap file directory
set dir=/tmp
set background=dark
(defn read-to-maps [rows]
(let [headers (->>
rows
first
(take-while (complement #{""}))
(map keyword))]
(for [row (rest rows)]
(zipmap headers row))))
@MichaelBlume
MichaelBlume / gist:ebf2cd75536c612eace9
Last active February 28, 2017 03:59
git testscript
echo "somebody should really delete this build"
echo "please"
echo "I keep getting messages when it fails and I can't delete it"
echo "I was the one maintaining it and I'm not there anymore, so there's not much point in it"
exit 0
@MichaelBlume
MichaelBlume / gist:a8ae240eab8006d9f931
Last active February 24, 2017 06:31
bisect-script
echo "someone should really delete this build"
echo "there's not much point in it without me there to maintain it"
echo "I can't delete it anymore I don't have access"
echo "and it keeps e-mailing me whenever it breaks"
echo "I mean I guess I could alter this gist and make it delete itself but that sounds hard"
exit 0
1
2 3
4 5 6
7 8 9 10
@MichaelBlume
MichaelBlume / gist:aa26fc715cbbdf711290
Created December 11, 2014 21:29
Clojure build failure
compile-clojure:
[java] Compiling clojure.core to /Users/michael.blume/workspace/clojure/target/classes
[java] Exception in thread "main" java.lang.LinkageError: loader constraint violation: loader (instance of clojure/lang/DynamicClassLoader) previously initiated loading for a different type with name "clojure/core/VecNode", compiling:(clojure/gvec.clj:124:1)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6715)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6499)
[java] at clojure.lang.Compiler.analyze(Compiler.java:6460)
[java] at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5840)
[java] at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5271)
[java] at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3900)
[java] at clojure.lang.Compiler.analyzeSeq(Compiler.java:6706)
; passes
(let [{:keys [bar foo]
:or {foo 1
bar (inc foo)}} {}]
(assert (= foo 1))
(assert (= bar 2)))
; does not compile
(let [{:keys [foo bar]
:or {foo 1