Skip to content

Instantly share code, notes, and snippets.

$ cd path_to_datomic
$ ./bin/rest 8080 free datomic:free://localhost:4334/
$ cd path_to_datomic
$ bin/transactor config/samples/free-transactor-template.properties
$ git clone codeq
$ cd codeq
$ lein uberjar
$ java -server -Xmx1g -jar ~/dev/codeq/target/codeq-0.1.0-SNAPSHOT-standalone.jar datomic:free://localhost:4334/codeq
@devn
devn / gist:4047927
Created November 9, 2012 20:11
Clojail changes
(ns getclojure.jail
(:require [clojail.core :as jail]
[clojail.testers :as tester]
[clojure.stacktrace :as trace])
(:import [java.io StringWriter PushbackReader FileReader]
java.util.concurrent.TimeoutException))
(defn truncate [x]
(if string?
(let [out (apply str (take 400 x))]
@devn
devn / gist:4366197
Created December 23, 2012 21:15 — forked from timmc/fact.swear.clj
;; It all started here: http://clojure-log.n01se.net/date/2011-04-06.html#19:04
(#((% (+(*))) %) ;; call arg 1 with all args
[;; data
(+ (*)(*)(*)(*)(*)(*)(*))
;; main fn -- simulate 'if' with map lookup and closures
#(({(+) (% (+(*)(*)))} ;; if zero return 'then' clause
(% (+)) ;; dispatch on first arg
(% (+(*)(*)(*)))) ;; call 'else' clause (n not found in map)
%)
@devn
devn / datomic-simple.clj
Created December 27, 2012 03:50
Example of using datomic-simple in the REPL
(ns datomic-playground.core
(:require [datomic-simple.core :as ds]))
(def model-namespace :user)
(def schema
(ds/build-schema model-namespace
[[:username :string]
[:password :string]]))
(ds/create-model-fns model-namespace)
{:user {:plugins [[lein-swank "1.4.5"]
;; [lein-pedantic "0.0.5"]
;; [lein-ritz "0.6.0"]
[lein-checkout-deps "1.0.0"]
;; [lein-haml-sass "0.2.4"]
[lein-midje "2.0.1"]
[lein-kibit "0.0.7"]]}
{:dependencies [[slamhound "1.3.0"]]}
{:aliases {"slamhound" ["run" "-m" "slam.hound"]}}}
;; Datomic example code
;;
;; The extent of entity ?x is all datoms that are about ?x.
;; Drop this into your rules.
;;
;; Demonstrates
;;
;; 1. recursive query (extent calls itself)
;; 2. disjunction (different extent bodies are ORed)
;; 3. component attributes (e.g. your arm is a component, your brother isn't)
# My take on Mike's source_for method.
# (see http://pragmaticstudio.com/blog/2013/2/13/view-source-ruby-methods)
#
# (1) I named it 'src' rather than source_for (ok, I'm a lazy typer).
# (2) The edit function was broken out as a separate function.
# (3) The edit function is for emacs
# (4) If the method is not defined on the object, and the object
# is a class, then see if it is an instance method on the class.
#
# The fourth point allows my to say:
javascript: (function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
(eval((fn[program](let [n (zipmap '(+ - > < . ?)(repeatedly gensym))](letfn[(f*[
s] (if (vector? s) `(while (not (~(n '?))) ~@(map f* s)) `(~(n s))))]`(let [t# (
int-array 100 0)pt# (atom 0)a#(fn[c#]#(aset t# @pt#(c# (aget t# @pt#))))b#(fn[d#
]#(swap! pt# d#)) ~(vec (map n '(+ - > <)))(map #(%1 %2)[a# a# b# b#](cycle [inc
dec]))~(n '.)#(print(char(aget t# @pt#)))~(n '?)#(zero?(aget t# @pt#))]~@(map f*
(read-string(str "("(->> program (interpose \space) (apply str)) ")" )))))))"+++
+++++[>++++++++<-]>+.[>+<-]+++++[>-----<-]>--------.[>+<-]++++++++[>++++++++<-]>
++++++++++++.+++.+++++.[>+<-]+++++++++[>---------<-]>---.[>+<-]++++++++[>+++++++
+<-]>+++++++++++++++.---------.[>+<-]++++++++[>--------<-]>------.[>+<-]++++++++
[>++++++++<-]>++++++++.-------.++.++++++++.--.+++++.-------.[>+<-]++++++++[>----
@devn
devn / anna.clj
Created March 21, 2013 03:56
Cheat at LetterPress because you're a classless jerk .
(ns anna.core
(:require [yokogiri.core :as y]))
(def client (y/make-client))
(def base-uri "http://www.wordsmith.org")
(defn query-string [character-string]
(str base-uri
"/anagram/anagram.cgi?anagram="