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
"Clojure stuff | |
let g:paredit_electric_return = 0 | |
let g:clojure_highlight_local_vars = 0 | |
let g:clojure_highlight_references = 0 " Toggle with :ToggleClojureHighlightReferences | |
let g:clojure_srepl_port = 5555 | |
let g:clojure_srepl_host = "127.0.0.1" | |
let g:clojure_require_preamble = "(set! *warn-on-reflection* true)" " These forms will be sent over srepl before a `require` is sent | |
let g:clojure_reload = ":reload" " This option is sent as an arg to `require` | |
let g:clojure_use_jobs = 0 | |
let g:clojure_repl_job = {} |
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
;; Let's start with a simple conditional interceptor that works with functions... | |
(defn conditional-context | |
"Given a keyword name and any variable predicate and terminator function pairs, | |
return an interceptor that will apply the terminator function paired to the first | |
truthy predicate. Predicates and terminators are both given the context as | |
the only argument. | |
If all predicates fail, the original context is returned." | |
[name-kw & pred-terms] |
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
package one.one.one.one | |
/* All declarations/statements are one-per-line; No semi-colon needed; | |
Comments are only multi-line; | |
Follow Java naming conventions */ | |
/* If no package is found you'll be in the "user" package */ | |
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 bash | |
## Given a Clojure source file, 'example.clj' | |
## Where the contents are captured by START and END comments like: | |
## | |
## ;;START SomeTagName | |
## (println (inc 2)) | |
## ;;END | |
## | |
## Run this script: colorblock.sh example.clj SomeTagName |
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
;; Simpler debug-repl based on https://github.com/stuarthalloway/circumspec/blob/master/src/clojure/contrib/debug.clj | |
;; This `debug-repl` also tries to capture line metadata from forms/files, as well as exceptions | |
;; Some people may want to rename `debug-repl` to `break`, and `quit-dr` to `continue` | |
(defmacro local-bindings | |
"Produces a map of the names of local bindings to their values." | |
[] | |
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)] | |
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols))) |
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
;; In Pedestal 0.3.1, you won't have to use an atom. | |
;; You'll pass the channel into the SSE creation function (instead of it passing one back to you) | |
(def event-ch (atom nil)) | |
(defn home-page | |
[request] | |
(ring-resp/response "Hello World!")) | |
(defroutes routes | |
[[["/" {:get home-page} |
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 com.ndensity.clclj.example | |
(:require [com.ndensity.clclj :as clclj :refer [clfn]])) | |
(defn cube [n] ; if you don't type hint, it assumes int32 for all args & return types | |
(* n n n)) | |
(def cube_cl (clfn* cube)) | |
(def square-cl | |
(clfn [n] | |
(let [a (inc n) |
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 sample | |
(:require [clojure-leap.core :as leap] | |
[clojure-leap.hand :as l-hand] | |
[clojure-leap.pointable :as l-pointable :refer [tip-position]])) | |
(defn process-frame [frame] | |
(let [_ (println "Frame id:" (.id frame) "timestamp:" (.timestamp frame) | |
"hands:" (leap/hands frame) "fingers:" (leap/fingers frame) "tools:" (leap/tools frame))] | |
(when-let [hand (and (leap/hands? frame) (leap/hand frame 0))] | |
(let [fingers (leap/fingers hand) |
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.specs-example | |
(:require [clojure.core.specs :as spec])) | |
(comment | |
;; A preview of some Specifications. | |
;; Out of the box, a single spec can be used with: | |
;; test.generative, core.contracts, Typed Clojure, and Sterling (an interface to Alloy) | |
;; You're also free to extend the system however you need. |
NewerOlder