Skip to content

Instantly share code, notes, and snippets.

@rasmusto
rasmusto / gist:3628326
Created September 5, 2012 00:06
next/prev buffer
map <esc>l :bn<cr>
map <esc>h :bp<cr>
#!/bin/sh
curl "http://<myhost>:8080/git/notifyCommit?url=<path-to-repo>"
@rasmusto
rasmusto / gist:3954024
Created October 25, 2012 16:56
multimethods in a macro
(defmacro defprop [multiname func kvs]
(eval
`(do
(defmulti ~multiname ~func)
~@(for [[k v] (seq kvs)]
`(defmethod ~multiname ~k [m#] ~v)))))
@rasmusto
rasmusto / fireplace.vim
Last active December 16, 2015 10:59
run clojure code from vim-fugitive buffer
function! s:repl.includes_file(file) dict abort
let is_zipfile = matchstr(a:file, '\C^zipfile:.*::')
let is_fugitive = matchstr(a:file, '\C^fugitive:\/\/.*')
if !empty(is_zipfile)
let file = substitute(a:file, '\C^zipfile:\(.*\)::', '\1/', '')
elseif !empty(is_fugitive)
let file = substitute(a:file, '\C^fugitive:\/\/\(.*\)', '\1', '')
let file = substitute(file, '\/\.git\/\/[^\/]\+', '', '')
else
let file = a:file
(ns clj-async-tests.core
(:require [clojure.core.async :as async
:refer [go chan >! <! >!! <!! timeout close! thread alts! alts!!]]))
(defn walk [t]
(cond (nil? t)
nil
:else
(let [[l v r] t]
(concat (walk l) [v] (walk r)))))
@rasmusto
rasmusto / init.el
Created August 17, 2013 22:57
simple emacs init.el
(require 'package)
(setq package-archives
'(("marmalade" . "http://marmalade-repo.org/packages/")))
(package-initialize)
(mapc
(lambda (package)
(or (package-installed-p package)
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package))))
@rasmusto
rasmusto / rhizome-fun.clj
Created February 4, 2014 16:36
random graphs w/ rhizome (graphviz) visualization
(ns rhizome-fun.core
; [rhizome "0.2.0"]
(:require [rhizome.viz :refer [view-graph save-graph]]))
(def alpha-nodes (mapv (comp keyword str)
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"))
(defn random-from [nodes]
(let [n (rand-int (count nodes))
pick (nodes n)
@rasmusto
rasmusto / dither.py
Created February 10, 2014 06:36
dither
import Tkinter
import Image, ImageTk
im = Image.open('pic.bmp')
root = Tkinter.Tk()
dither8 = [[ 0, 32, 8, 40, 2, 34, 10, 42],
[48, 16, 56, 24, 50, 18, 58, 26],
[12, 44, 4, 36, 14, 46, 6, 38],
[60, 28, 52, 20, 62, 30, 54, 22],
[ 3, 35, 11, 43, 1, 33, 9, 41],
@rasmusto
rasmusto / gist:9925149
Created April 1, 2014 23:29
:TLsource error
file looks like this:
; ras/test.tim
(ns ras.test)
; here's the error:
; Error detected while processing function timl#loader#source..timl#compiler#build..<SNR>95_emit..timl#call..150..timl#type#apply..timl#lazy_seq#seq..<SNR>97_val..timl#call..289..<SNR>72_predicate
..timl#coll#chunked_seqp:
(defn fact [n]
(cond (zero? n) 1
:else (* n (fact (dec n)) )))
(defn fact-tail [n]
(loop [n n acc 1]
(cond (zero? n) acc
:else (recur (dec n) (* acc n)))))