Skip to content

Instantly share code, notes, and snippets.

View weavejester's full-sized avatar

James Reeves weavejester

View GitHub Profile
(defun indent-or-complete ()
(interactive)
(if (looking-at "\\_>")
(company-complete-common)
(indent-according-to-mode)))
(context "/" {{:keys [username]} :session}
(GET "/foo" [link description]
(do-something username link description)))
(require '[clojure.string :as str])
(defn parse-ints [line]
(for [s (str/split line #" ")] (Integer/parseInt s)))
(defn read-service-data []
(let [[n t] (parse-ints (read-line))]
{:widths (parse-ints (read-line))
:tests (->> (repeatedly read-line) (take n) (map parse-ints))}))

Keybase proof

I hereby claim:

  • I am weavejester on github.
  • I am weavejester (https://keybase.io/weavejester) on keybase.
  • I have a public key whose fingerprint is BADE B0BC BB50 10BB 9F4F F46A 87FC FC78 1A1B 513D

To claim this, I am signing this object:

@weavejester
weavejester / gist:9879795
Created March 30, 2014 21:07
Datomic Sample
[[{:db/id #db/id[:db.part/tx]
:db/txInstant #inst "2013-01-01T00:00:01Z"}
{:db/id #db/id [:db.part/user]
:db/ident :person/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}]]
(ns reagi.core)
(defn hello [] "Hello world")
user=> (austin-exec :src "src-cljs/")
Browser-REPL ready @ http://localhost:54203/7624/repl/start
WARNING: Symbol IDeref is not a protocol at line 3 /Users/jim/Development/reagi/src-cljs/reagi/core.cljs
Type `:cljs/quit` to stop the ClojureScript REPL
nil
cljs.user=> (ns cljs.user (:require [reagi.core :as r]))
nil
;; No headers
(resource :exists? get-data :handle-ok :data)
;; With a header
(resource :exists? get-data
:handle-ok (fn [context]
(-> (rep/as-response (:data context) context)
(header "Link" "<...>;rel=next"))))
@weavejester
weavejester / gist:7205567
Created October 28, 2013 21:59
Idomatic asset pipelines in Ring

Let's assume we have a LESS resource we want to compile into a CSS resource before the end user sees it.

The response for the LESS resource might look something like this:

{:status 200
 :headers
 {"Content-Type"  "text/less"
  "Last-Modified" "Mon, 28 Oct 2013 21:23:08 GMT"}
 :body
private float calculateFloat(int i, float x, float y) {
return (x + i) / (y + i);
}
private double calculateDouble(int i, double x, double y) {
return (x + i) / (y + i);
}
public void timeFloat(int runs) {
for (int run=0; run<runs; run++) {