Skip to content

Instantly share code, notes, and snippets.

[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)
(definterface IModifier
(op [])
(value []))
(deftype ABuff [^long n]
IModifier
(op [_] (fn [m] (long (+ n m))))
(value [_] n)
Object
#!/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
; "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)
@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 ]] )
@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.

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:

(ns docs)
(defn var-name
[v]
(symbol
(-> v .ns ns-name str)
(-> v .sym str)))
(defn print-vars
[vars]
#verifymyonename +arrdem
@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)))