Skip to content

Instantly share code, notes, and snippets.

@arrdem
arrdem / gist:437ad66f2d81f877790c
Created December 5, 2014 07:01
Grimoire 0.4 API proposal

HTTP API

While Grimoire 0.3.X lacked a API for searching the backing datastore, Grimoire 0.4.0 resolves that limitation adding a HTTP API with JSON or EDN responses.

As of the writing of this document, the HTTP API is at version v0.

All routes return an object, representing either success or failure.

@arrdem
arrdem / git-get
Created February 6, 2015 05:04
Git bits
#!/bin/bash
# This is a quick little git extension designed to allow me to manage
# all the git repos that I keep around better. The idea is that a
# "root" directory, $GIT_DAT/$OWNER/$REPO, and then
# symlink that directory to wherever you are now.
if ( [[ "--help" = $1 ]] ||
[[ "help" = $1 ]] ||
[[ -z $1 ]] )
; "Reverse haversine" to derive lat/long from start point, bearing (degrees clockwise from north), & distance (km)
; φ2 = asin( (sin φ1 ⋅ cos δ) + (cos φ1 ⋅ sin δ ⋅ cos θ) )
; λ2 = λ1 + atan2( sin θ ⋅ sin δ ⋅ cos φ1, cos δ − sin φ1 ⋅ sin φ2 )
; where φ is latitude, λ is longitude, θ is the bearing (clockwise from north), δ is the angular distance d/R; d being the distance travelled, R the earth’s radius
(defn reverse-haversine
"Implementation of the reverse of Haversine formula. Takes one set of latitude/longitude as a start point, a bearing, and a distance, and returns the resultant lat/long pair."
[{lon :lng lat :lat bearing :bearing distance :distance}]
(let [R 6378.137 ; Radius of Earth in km
lat1 (Math/toRadians lat)
#!/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)
@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)
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 / install.sh
Last active April 5, 2017 07:48
A bootleg puppet
# -*- mode: bash; indent-tabs-mode: nil; sh-basic-offset: 2; fill-column: 100; -*-
# About
# ==============================
# A bootleg dotfiles installer.
#
# Usage
# ==============================
#
# $FORCE - if non-empty then install.sh will happily clobber existing files/dirs