Skip to content

Instantly share code, notes, and snippets.

View eliasson's full-sized avatar
🎧
.

Markus Eliasson eliasson

🎧
.
View GitHub Profile
@eliasson
eliasson / Makefile
Created August 31, 2014 20:12
Example Makefile for small projects in golang
PACKAGES := \
github.com/eliasson/foo \
github.com/eliasson/bar
DEPENDENCIES := github.com/eliasson/acme
all: build silent-test
build:
go build -o bin/foo main.go
@eliasson
eliasson / addcss.py
Last active August 29, 2015 14:02
Add CSS class for form widget in Django Templates
from django import template
register = template.Library()
@register.filter(name='addcss')
def addcss(field, css):
"""
Adds the given class to the class attribute of the given field.
E.g. adds the class 'bar' to the foo widget:
@eliasson
eliasson / digest.clj
Created October 20, 2011 19:16
Clojure md5 digest
(defn md5
"Generate a md5 checksum for the given string"
[token]
(let [hash-bytes
(doto (java.security.MessageDigest/getInstance "MD5")
(.reset)
(.update (.getBytes token)))]
(.toString
(new java.math.BigInteger 1 (.digest hash-bytes)) ; Positive and the size of the number
16))) ; Use base16 i.e. hex