Skip to content

Instantly share code, notes, and snippets.

@abp
abp / family-trees.txt
Created August 2, 2012 07:48 — forked from zerokarmaleft/family-trees.txt
Game of Thrones Challenge #65
AA = Rickard Stark (M) AB = Eddard Stark (M) AC = Catelyn Tully (F)
AD = Brandon Stark (M) AE = Benjen Stark (M) AF = Jon Snow (M)
AG = Robb Stark (M) AH = Sansa Stark (F) AI = Arya Stark (F)
AJ = Bran Stark (M) AK = Rickon Stark (M) AL = Hoster Tully (M)
AM = Minisa Whent (F) AN = Edmure Tully (M) AO = Lysa Tully (F)
AP = Jon Arryn (M) AQ = Robert Arryn (M) AR = Tytos Lannister (M)
AS = Tywin Lannister (M) AT = Joanna Lannister (F) AU = Kevan Lannister (M)
AV = Cersei Lannister (F) AW = Jamie Lannister (M) AX = Tyrion Lannister (M)
AY = Robert Baratheon (M) AZ = Joffrey Baratheon (M) BA = Myrcella Baratheon (F)
BB = Tommen Baratheon (M) BC = Lancel Lannister (M) BD = Steffon Baratheon (M)
@abp
abp / gist:3219885
Created July 31, 2012 19:43 — forked from swannodette/gist:3217582
sudoku_compact.clj
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [grid x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in grid [x y])))
(defn init [grid [pos value]]
@abp
abp / gist:3213464
Created July 31, 2012 04:01 — forked from swannodette/gist:3213107
sudoku.clj
(defn distincto [s]
(if (seq s)
(all
(distinctfd (first s))
(distincto (next s)))
s#))
(defn all-infd [xs d]
(if (seq xs)
(all
(use '[datomic.api :only [db q] :as d])
(def schema
[{:db/doc "A persons name"
:db/id #db/id[:db.part/db]
:db/ident :name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}
(ns barker.client.main
(:require [barker.client.render :as render]
[barker.client.search :as search]
[shoreleave.client.common :as common]
[shoreleave.client.history :as history]
[shoreleave.client.pubsubs.simple :as pbus]
[shoreleave.client.pubsubs.protocols :as pubsub]
[shoreleave.client.worker :as swk]
)
(:use [jayq.core :only [$ attr]])
(ns barker.client.search
(:require [clojure.string :as cstr]
[shoreleave.client.services.geo :as geo]
[shoreleave.client.remote :as remote])
(:use [jayq.core :only [$ inner]]))
(defn query->map [search-query]
(let [[topic location] (map cstr/trim (cstr/split search-query #" near "))
zip (when (re-find #"\d" location) location)] ;if we see an digit, we assume it's some kind of zip
{:raw-query search-query :topic topic :location location :zip zip}))
@abp
abp / two-useful-macros.clj
Created June 30, 2012 05:38 — forked from rplevy/two-useful-macros.clj
with and within
(defmacro with
"do things with the first expression passed,
and produce the result"
[expr & body]
`(let [~'% ~expr] ~@body))
(defmacro within
"do things with the first expression passed (for side effects),
but produce the value of the first expression"
[expr & body]
@abp
abp / automath.clj
Created June 29, 2012 06:18 — forked from fogus/automath.clj
Namespace of functions that are proxies for methods on java.lang.Math for maximum developer convenience.
(ns automath
"Namespace of functions that are proxies for methods on
java.lang.Math for maximum developer convenience."
(:use [clojure.string :only (lower-case)]))
(def ^{:private true
:doc "Set of method names not to generate a proxy function for."}
exclusions #{"min" "max"})
(defn- methods-in
@abp
abp / twip.c
Created June 27, 2012 21:32 — forked from fogus/twip.c
/* The whole point of the twIP stack is to respond to pings. This is
done by reading one IP packet at a time, hoping that it is an IP
ping packet (no check is made!), changing the packet type to a ping
reply packet, updating the ICMP checksum, swapping the IP source
and destination addresses, and sending the packet back. That's
it.
*/
/* This is the packet buffer. I chose the size of the array so that
the maximum packet size that twIP would support would be the same
@abp
abp / clojure-match.clj
Created June 16, 2012 21:37 — forked from ckirkendall/clojure-match.clj
Language Compare F#, Ocaml, Scala, Clojure and Haskell
(use '[clojure.core.match :only [match]])
(defn evaluate [env exp]
(match [exp]
[(['Number a] :seq)] a
[(['Add x y] :seq)] (+ (evaluate env x) (evaluate env y))
[(['Multiply x y] :seq)] (* (evaluate env x) (evaluate env y))
[(['Variable i] :seq)] (env i)))
(def environment {"a" 3, "b" 4, "c" 5})