Skip to content

Instantly share code, notes, and snippets.

class VersionedAttribute:
def __init__(self, status_sequence):
self.value_status_mapping = {state: None for state in status_sequence}
def __get__(self, instance, owner):
return self.value_for(instance.status)
def __set__(self, instance, value):
@RobinRamael
RobinRamael / gist:1133895
Created August 9, 2011 12:18
Loading buffered images lazily gives OutOfMemoryException
(defn load-image [file]
(javax.imageio.ImageIO/read file))
(defn imgs-from-files [files]
(if (not (empty? files))
(lazy-seq
(cons (load-image
(first files))
(imgs-from-files (rest files))))))
(ns sier.core
(:import (javax.swing JFrame JPanel JButton)
(java.awt Dimension)))
(defstruct coord :x :y)
(defstruct triangle :c1 :c2 :c3)
(defn draw-line [g c1 c2]
(.drawLine g (:x c1) (:y c1) (:x c2) (:y c2)))
1 {
h
d
}
/^[A-Z]/{
G # append the hold space
s/\([A-Z]\)\n/\1/ # put what was in the hold space on the same line
s/\([A-Z][0-9]\).*$/\1/ # remove all but the first two chars
x # now we're going to work on the hold space
$ cat invoer1.txt
75160892
D
E
M
N
O
R
S
Y
(defn interweave [list1 list2]
(loop [s1 (lazy-seq list1) s2 (lazy-seq list2) out (empty s1)]
(cond
(empty? s1) (concat out s2)
(empty? s2) (concat out s1)
:else (recur (rest s1)
(rest s2)
(concat out (seq (list (first s1) (first s2)))))))
)
@RobinRamael
RobinRamael / gist:786623
Created January 19, 2011 18:48
find the classcastexception...
(defn semi-splay [tree el]
(loop [nds tree x el]
(let [to-splay (take 3 (get-path nds x))]
(if (> (count to-splay) 2)
(let [outer-trees (get-outer-trees to-splay)
sorted-to-splay (sort-by-vals to-splay)
new-root (:val (second sorted-to-splay))]
(recur (swap-nodes
nds (:val (last to-splay))
{:val new-root
==> Downloading http://cairographics.org/releases/cairo-1.10.2.tar.gz
File already downloaded and cached to /Users/robin/Library/Caches/Homebrew
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/cairo/1
==> make install
make install-recursive
Making install in src
make install-am
CC cairo-analysis-surface.lo
CC cairo-arc.lo
/bin/sh ../libtool --silent --tag=CC --mode=compile /usr/bin/cc -DHAVE_CONFIG_H -I. -I.. -I. -D_REENTRANT -I/usr/local/Cellar/pixman/0.21.2/include/pixman-1 -I/usr/X11/include -I/usr/local/include/freetype2 -I/usr/local/include -I/usr/local/Cellar/libpng/1.2.44/include/libpng12 -I/usr/X11/include -I/usr/X11/include -I/usr/local/Cellar/valgrind/3.6.0/include/valgrind -Wall -Wextra -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Werror-implicit-function-declaration -Wnested-externs -Wpointer-arith -Wwrite-strings -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes -Wpacked -Wswitch-enum -Wmissing-