Skip to content

Instantly share code, notes, and snippets.

@muhuk
muhuk / create_virtualenv.sh
Created May 25, 2010 06:15
Script that creates a virtualenv according to the instructions from the Ministry of Packaging
#!/usr/bin/env sh
if [ $1 ]; then VIRTUALENV_PATH=$1; else VIRTUALENV_PATH=.; fi
echo "virtualenv path: $VIRTUALENV_PATH"
if [ $2 ]; then REPOSITORY=$2; echo "repository: $REPOSITORY"; fi
virtualenv --no-site-packages --clear --distribute $VIRTUALENV_PATH
cd $VIRTUALENV_PATH
#!/usr/bin/env python
import sys
import os
import cherrypy
def get_options():
host, port = '0.0.0.0', 8010
if len(sys.argv) > 2:
bits = sys.argv[2].split(':')
@muhuk
muhuk / gist:7c4a2b8db63886e2a9cd
Last active August 29, 2015 14:00
clojure: Idiomatic tokenizing and performance
(defn match-ident
[cs]
(let [start (first cs)]
(if (ident-first-char? start)
(let [ identseq (cons start (take-while ident-tail-char? (rest cs)))
^String ident (apply str identseq)]
[(drop (.length ident) cs) [:ident ident]]))))
(defn match-num
[cs]
@muhuk
muhuk / gist:08bc80611590f2fe79b1
Created May 17, 2014 02:06
Is there a better way for creating anonymous constants?
(def my-fn (let [a (idempotent-fn x)
b (idempotent-fn y)]
(fn [i] (some-ops i a b))))
@muhuk
muhuk / console output
Created June 21, 2014 08:57
Midje prerequisites & apply
FAIL at (test.clj:12)
These calls were not made the right number of times:
(--m-- :something ..a.. ..b..) [expected at least once, actually never called]
FAIL "foo" at (test.clj:10)
Expected: ..result..
Actual: java.lang.AbstractMethodError
@muhuk
muhuk / ttf2love.py
Created September 30, 2014 13:36
Converts TTF fonts to a PNG file recognized by Love2D game engine.
#!/usr/bin/env python
import sys
from PIL import Image, ImageChops, ImageDraw, ImageFont
BACKGROUND_COLOR = (0, 0, 0, 0)
FONT_COLOR = (255, 255, 255, 255)
MARKER_COLOR = (255, 255, 0, 255)
(ns typing-deferred
(:require [clojure.core.typed :as t]
[manifold.deferred :as deferred]))
(t/ann ^:no-check manifold.deferred/deferred (t/All [a] [-> (TDeferred a)]))
(t/defalias TDeferred
(t/TFn [[d :variance :invariant :< (t/TFn [[x :variance :covariant]] manifold.deferred.Deferred)]]
@muhuk
muhuk / EDNTest1.java
Created September 17, 2015 14:08
Frege/eclipse-plugin #14
/*
Source code is in UTF-8 encoding. The following symbols may appear, among others:
α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω « • ¦ » fi fl ƒ
If you can't read this, you're out of luck.
This code was generated with the frege compiler version 3.23.313-g02654a8 from
test/frege/com/muhuk/EDNTest.fr Do not edit this file!
Instead, edit the source file and recompile.
*/
@muhuk
muhuk / split-coll.clj
Created December 18, 2015 14:36
But will it chunk?
(defn split-coll-1 [elem coll]
(loop [coll coll
parts []
part []]
(if-let [e (first coll)]
(if (= e elem)
(recur (rest coll) (conj parts part) [])
(recur (rest coll) parts (conj part e)))
(if (seq part)
(conj parts part)
{:annotate
{[vector-of-variable-length :invalid]
{:results
((true true true)
(true true true)
(true true true)
(true true true)
(true true true)
(true true true)
(true true true)