Skip to content

Instantly share code, notes, and snippets.

@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
(defn read-to-maps [rows]
(let [headers (->>
rows
first
(take-while (complement #{""}))
(map keyword))]
(for [row (rest rows)]
(zipmap headers row))))
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 swap-out! [a new-val]
(loop []
(let [old-val @a]
(if (compare-and-set! a old-val new-val)
old-val
(recur)))))
@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)
#!/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
(ns schema->gen
"Functions for generating test data from schemas."
(:require [four.stateful :as four]
[re-rand :refer [re-rand]]
[schema.core :as sch]
[simple-check.generators :as gen]))
(defn ^:private re-randify-regex
"schema requires ^$ while re-rand forbids them"
[re]
#!/bin/bash
echo -n "Updating system so it uses the new JDK..."
update-alternatives --quiet --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 2
update-alternatives --quiet --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 2
update-alternatives --quiet --set java /usr/lib/jvm/jdk1.8.0/bin/java
update-alternatives --quiet --set javac /usr/lib/jvm/jdk1.8.0/bin/javac
echo "done."
exit 0
from itertools import takewhile, ifilter
def fibs():
fib0 = 1
fib1 = 1
while True:
yield fib0
newfib = fib0 + fib1
fib0 = fib1
fib1 = newfib
@MichaelBlume
MichaelBlume / Chat.hs
Last active January 3, 2016 06:59
Transforms gchat logs into tumblr chat posts
#!/usr/bin/env runhaskell
module Main (main) where
-- When you copy a conversation out of your google chat logs, it looks like
-- this
--
-- Alice
-- hi
-- how are you
-- Bob Smith