Skip to content

Instantly share code, notes, and snippets.

#verifymyonename +arrdem
(ns docs)
(defn var-name
[v]
(symbol
(-> v .ns ns-name str)
(-> v .sym str)))
(defn print-vars
[vars]

Keybase proof

I hereby claim:

  • I am arrdem on github.
  • I am arrdem (https://keybase.io/arrdem) on keybase.
  • I have a public key whose fingerprint is 2E9E B05E 6243 1469 ED24 78C2 F02B FCEE 0A85 EC53

To claim this, I am signing this object:

@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)
Compiling doubletake.java.spec.core
Exception in thread "main" java.lang.ClassNotFoundException: doubletake.java.spec.DependTree (core.clj:1)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2911)
at clojure.lang.Compiler.compile1(Compiler.java:5933)
at clojure.lang.Compiler.compile1(Compiler.java:5923)
at clojure.lang.Compiler.compile(Compiler.java:5992)
at clojure.lang.RT.compile(RT.java:368)
at clojure.lang.RT.load(RT.java:407)
at clojure.lang.RT.load(RT.java:381)
at clojure.core$load$fn__4511.invoke(core.clj:4905)
(ns alice.core)
(defn candy-delta [ivec]
(map first
(reduce (fn [pr c]
(let [[ps pv] (last pr)]
(conj pr
(cond (empty? pr) [1 c]
(= pv c) [ps pv]
(< pv c) [(inc ps) c]
@arrdem
arrdem / 352h-arch.txt
Created September 18, 2012 22:05
CS 352H Final Processor Architecture
#CPU Architecture Specification for CS 352H - Fall 2012
- Special Registers
- Function Calls
- Interrupts
- Virtual Mem.
- Register Windows
- Memory Addressing Modes
- Immediate Values
##Conventions
@arrdem
arrdem / gist:4712024
Last active December 12, 2015 04:08
A simple qsort implementation in Clojure
(defn %remove-first [val seq]
(loop [h seq
t []]
(if (empty? h)
t
(if (= (first h) val)
(concat t (rest h))
(recur (rest h) (conj t (first h)))))))
(defn qsort [seq]