This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns lucenalog.core | |
"Lucenalog = Datalog interface to Lucene in 10 lines. | |
Simple but powerful. | |
Use | |
(db/add (index) {:a \"foo\" :b \"bar\"}) | |
to index a map with Lucene. Then you can use the relation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sterling.example.filesystem.fs | |
(:require [clojure.walk :as cwalk])) | |
;; Overview | |
;; ========== | |
;; | |
;; A common example is to illustrate Alloy's abilities is a simpel filesystem. | |
;; | |
;; Below is a pure Clojure implementation of the same system, with the same | |
;; checks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>Example of import/export for localstorage</title></head> | |
<body> | |
<h3 id="example-text">LS:...</h3> | |
</body> | |
<script> | |
var text = document.getElementById("example-text"), | |
storage_key = "hidden_ids", | |
json_str; | |
localStorage[storage_key] = [1, 2, 3, 4, 5]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn blocking-deref | |
"Given an atom and a Result object, attempt to cycle the process tick on derefing until `pred-fn` isn't true | |
By default, `pred-fn` is nil? | |
Once the condition doesn't hold, the Result will be set to @a, and @a is returned" | |
([a r] | |
(blocking-deref a r nil?)) | |
([a r pred-fn] | |
(if (pred-fn @a) | |
(node/process.nextTick #(blocking-deref a r pred-fn)) | |
(do (.setValue r @a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro test-> | |
"Takes an expression and a set of test/form pairs. Threads expr (via ->) | |
through each form for which the corresponding test is true." | |
[expr | |
& clauses] | |
(assert (even? (count clauses))) | |
(let [g (gensym) | |
pstep (fn [[test step]] `(if ~test (-> ~g ~step) ~g))] | |
`(let [~g ~expr | |
~@(interleave (repeat g) (map pstep (partition 2 clauses)))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns leiningen.fork | |
(:require [leiningen.core.main :as main] | |
[leiningen.do :as do])) | |
(defn fork | |
[project task-name & args] | |
(apply println "Forking" task-name args) | |
(future | |
(main/apply-task (main/lookup-alias task-name project) project args))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cl-graph | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
;; Directed Acyclic Graphs | |
(defrel edge a b) | |
;; a | |
;; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import collections | |
# DO NOT USE GENSHI'S FLATTEN - it is not a generator and will chew up CPU and RAM | |
def flatten(l): | |
""" | |
Flatten all iterables (lists, tuples, dicts, etc), into one lazy generator-stream | |
""" | |
if isinstance(l, dict): | |
l = l.items() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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]]) |