Skip to content

Instantly share code, notes, and snippets.

@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 / 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]
(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}))
(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]])
(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}
@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
@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 / 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:3339422
Created August 13, 2012 10:57 — forked from lynaghk/gist:3335154
content-based pubsub via core.match. Faster than I expected!
(ns crossfilter.busses
(:use-macros [c2.util :only [p pp]]
[clojure.core.match.js :only [match]]
[crossfilter.macros :only [subscribe!]])
(:require [clojure.string :as str]
[goog.pubsub.PubSub :as goog.pubsub.PubSub]
[goog.object :as gobj]))
(set! *print-fn* #(.log js/console %))
@abp
abp / accounts.clj
Created August 29, 2012 13:11 — forked from terjesb/accounts.clj
Using database functions in Datomic transactions and annotating transaction history
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://accounts")
;; create database
(d/create-database uri)
;; connect to database
(def conn (d/connect uri))