Skip to content

Instantly share code, notes, and snippets.

View d11wtq's full-sized avatar

Chris Corbyn d11wtq

  • Melbourne, Australia
View GitHub Profile
@d11wtq
d11wtq / roman.clj
Last active August 29, 2015 14:22
Roman numerals
(ns roman.core)
(defmacro defpairs
"Helper macro to make ordered defs for pairs nicer."
[varname pairs]
`(def ~varname
(partition 2 ~pairs)))
(defpairs digits
["M" 1000
@d11wtq
d11wtq / declare.clj
Last active August 29, 2015 14:21
Implicit forward declarations for Clojure
(defn def?
[[a b]]
(if (#{'defn 'def} a) b))
(defmacro progn
[& sexps]
(let [names (->> sexps (filter def?) (map def?))]
`(do
(declare ~@names)
~@sexps)))
@d11wtq
d11wtq / atbash.clj
Last active August 29, 2015 14:21
Atbash Cipher in Clojure
(ns atbash.core
(require [clojure.string :refer [join lower-case]]))
(def lookup
(let [alphabet "abcdefghijklmnopqrstuvwxyz"]
(zipmap alphabet (reverse alphabet))))
(defn encode
[s]
(->> (lower-case s)
@d11wtq
d11wtq / README.md
Last active August 29, 2015 14:20
Writing int->str (Clojure)

int->str

This function computes the English string for any given integer supported by Clojure.

Example

(int->str 110917) ; "one hundred and ten thousand nine hundred and seventeen"
(ns example.factory.aws.cloudformation
(:require [clojure.data.json :as json]))
(defn apply-stack-fn
[create-fn update-fn]
(fn apply-stack
[payload]
(try
(create-fn payload)
(catch AlreadyExistsException e
@d11wtq
d11wtq / Spanish.md
Last active August 29, 2015 14:07
Spanish Study

El estudio del castellano

Las conjugaciones de los verbos

Conjugación
Verbo Sujeto
class ASTNode {
public:
template <class T> virtual T accept(Visitor<T> *visitor);
};
template <class T> class Visitor {
public:
virtual T visit(CallNode *node) = 0;
virtual T visit(BinExprNode *node) = 0;
};
@d11wtq
d11wtq / Dockerfile
Created March 7, 2014 00:42
Suggested syntax to exclude directories from layers in an image.
FROM gentoo
MAINTAINER Bob
EXCLUDE /usr/portage
RUN emerge-webrsync
RUN emerge sys-devel/llvm
RUN emerge sys-devel/clang --autounmask-write
RUN etc-update --automode -5
RUN emerge sys-devel/clang
@d11wtq
d11wtq / spinner.sh
Last active August 29, 2015 13:56
Bash spinner, WIP.
#!/bin/bash
TTY=/dev/tty
spin() {
width=20
delta=1
#fwd_chars=("\\" "|" "/" "-")
#rev_chars=("/" "|" "\\" "-")
fwd_chars=">"
vagrant@local ~ $ docker run -t -i -rm ubuntu bash
Unable to find image 'ubuntu' (tag: latest) locally
Pulling repository ubuntu
5ac751e8d623: Error pulling image (quantal) from ubuntu, Driver devicemapper failed to create image rootfs 511136ea39cc9ea5ea540: Error pulling image (lucid) from ubuntu, Driver devicemapper failed to create image rootfs 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158: Error mounting '/dev/mapper/docker-8:4-547505-511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158' on '/var/lib/docker/devicemapper/mnt/511136ea3c5a64f264b78b5433619f676bd305a4: Error pulling image (saucy) from ubuntu, Driver devicemapper failed to create image rootfs 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158: Error mounting '/dev/mapper/docker-8:4-547505-511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158' on '/var/lib/docker/devicemapper/mnt/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158': invalid argument 03b4d4702f3ba7d4d2698e22c15