Skip to content

Instantly share code, notes, and snippets.

@arrdem
arrdem / gist:4712032
Last active December 12, 2015 04:08
A simple msort implementation in Clojure
(defmacro recurse [v]
(if (= v :left)
`(recur ~'l (rest ~'r) (conj ~'res (first ~'r)))
`(recur (rest ~'l) ~'r (conj ~'res (first ~'l)))))
(defn %merge [l r]
(loop [l l
r r
res []]
(if (every? empty? [l r])
#!/usr/bin/env python3
# Authored by Reid "arrdem" McKenzie, 10/22/2013
# Licenced under the terms of the EPL 1.0
import cortex.stats as stats
def attack_perm_generator(weapons, src_model, tgt_model,
focus=0, can_boost_hit=True):
"""Recursively compute attack options over two models, focus and weapons!
@arrdem
arrdem / typed_graph.clj
Created October 2, 2013 16:47
A toy directed graph imp'l with nonworking core.typed annotations.
(ns name.arrdem.bored.typed-graph
(:require [clojure.core.typed :as type])
(:refer-clojure :exclude [hash]))
;;------------------------------------------------------------------------------
;; Simple graph API
(def Node clojure.lang.Keyword)
(def Graph (type/Map Node (type/Seq Node)))
#!/bin/bash
if [ ! -f `which lein` ];
then
echo "Install leiningen from https://github.com/technomancy/leiningen"
exit
else
ROOT=`mktemp -d`
cd $ROOT
cat <<EOF > $ROOT/project.clj
(definterface IModifier
(op [])
(value []))
(deftype ABuff [^long n]
IModifier
(op [_] (fn [m] (long (+ n m))))
(value [_] n)
Object
[1] Handed out (0, 0, 0) * STEP
[2] Handed out (0, 0, 1) * STEP
[3] Handed out (0, 1, 0) * STEP
[4] Handed out (0, 1, 1) * STEP
[5] Handed out (0, 1, 2) * STEP
[6] Handed out (1, 0, 0) * STEP
[7] Handed out (1, 0, 1) * STEP
[8] Handed out (1, 1, 0) * STEP
[7] [ANSWER] Got one! (1008, 960, 1100)
[8] [ANSWER] Got one! (1008, 1100, 960)
War Room Army
Cygnar - Sloan and six hunters
Theme: No Theme Selected
73 / 75 Army
Captain Kara Sloan - WJ: +28
- Reinholdt, Gobber Speculator - PC: 4
@arrdem
arrdem / -
Created December 20, 2016 01:44
#!/bin/bash
function install_package() {
if [ -e "$1/build.sh" ]; then
( cd "$1";
bash "build.sh")
fi
stow --ignore="build.sh" --ignore="README.md" -t ~ "$f"
}
@arrdem
arrdem / rendering.clj
Last active January 1, 2017 00:59
Textual programs as views of ASTs.
;; I write
(ns foo)
(defn adds-one [x]
(+ x 1))
(def another-adds-one
(partial + 1))
;; SYMBOL TABLE (name -> UUID)
@arrdem
arrdem / 20-markdown.el
Created January 20, 2017 02:40
My markdown support
;; 20-markdown.el
(require 'markdown-mode)
;; One space per line implementation
(defun arrdem:markdown-nobreak-p ()
"Return nil if it is acceptable to break the current line at the point.
Supports Markdown links, liquid tags."
;; inside in square brackets (e.g., link anchor text)