Skip to content

Instantly share code, notes, and snippets.

(let [translations {"issue_1" "Issue One"
"issue_2" "Issue Two"
"issue_3" "Issue Three"
"issue_4" "Issue Four"}
items [{:priority "high",:issues ["issue_1" "issue_2"]}
{:priority "low", :issues ["issue_3" "issue_4"]}]]
(map (fn [m] (apply merge m))
(map (fn [{:keys [priority issues]}]
(map (fn [issue]
{(get translations issue), {:priority priority,
(defprotocol Coercable
"Coerce Ruby objects to Clojure types"
(clj [this] "Coerce a Ruby object to its Clojure representation"))
(extend-protocol Coercable
org.jruby.RubyString
(clj [this] (str this)))
(extend-protocol Coercable
java.lang.Long
(def mappings
{:sexp
{:properties
{:id {:type "integer" :store "yes"}
:input {:type "string" :store "yes" :analyzer "clojure_code"}
:output {:type "string" :store "yes" :analyzer "clojure_code"}
:value {:type "string" :store "yes" :analyzer "clojure_code"}}}})
(defn create-getclojure-index []
(when-not (esi/exists? "getclojure")
(defn remove-first [pred coll]
(let [[xs ys] (split-with (complement pred) coll)]
(concat xs (rest ys))))
(remove-first (partial = 3) [1 2 3 1 2 3])
;;; (1 2 1 2 3)
(remove-first even? [1 2 3 1 2 3])
;;; (1 3 1 2 3)
@devn
devn / init.el
Created April 13, 2013 20:28
Simple Clojure Config
;; Make sure we can execute things in our ~/bin DIR
;; This may not be necessary if you're running emacs from the terminal.
(add-to-list 'exec-path (expand-file-name "~/bin"))
(setenv "PATH" (concat (expand-file-name "~/bin") ":" (getenv "PATH")))
;; Packages
(require 'package)
(require 'hippie-exp)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
@devn
devn / getclojure-index-settings.clj
Last active December 15, 2015 07:29
getclojure index settings
getclojure.search> (pprint-code (esi/get-settings "getclojure"))
{:getclojure
{:settings
{:index.analysis.tokenizer.clojure_tokenizer.lowercase "true",
:index.analysis.tokenizer.clojure_tokenizer.pattern
"\\s+|\\(|\\)|\\{|\\}|\\[|\\]",
:index.analysis.analyzer.clojure_code.pattern
"\\s+|\\(|\\)|\\{|\\}|\\[|\\]",
:index.version.created "200499",
:index.number_of_shards "5",
@devn
devn / pedestal-chat-errors
Created March 22, 2013 16:44
Some errors I'm getting when running the sample Pedestal chat application
chat-server.server=> (dev/start)
nil
chat-server.server=> io.pedestal.service.http.sse - {:line 76, :msg "exception sending heartbeat", :throwable #<EofException org.eclipse.jetty.io.EofException>, :stacktrace "org.eclipse.jetty.io.EofException: null\n at org.eclipse.jetty.http.HttpGenerator.flushBuffer (HttpGenerator.java:914)\n org.eclipse.jetty.server.AbstractHttpConnection.flushResponse (AbstractHttpConnection.java:654)\n org.eclipse.jetty.server.Response.flushBuffer (Response.java:1056)\n io.pedestal.service.http.sse$flush_response.invoke (sse.clj:45)\n io.pedestal.service.http.sse$do_heartbeat$fn__3729.invoke (sse.clj:74)\n io.pedestal.service.http.sse$do_heartbeat.invoke (sse.clj:71)\n io.pedestal.service.http.sse$schedule_heartbeart$f__3744.invoke (sse.clj:82)\n clojure.lang.AFn.run (AFn.java:24)\n java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:439)\n java.util.concurrent.FutureTask$Sync.innerRunAndReset (FutureTask.java:317)\n java.util.concurrent.Fu
@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="
(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)) ")" )))))))"+++
+++++[>++++++++<-]>+.[>+<-]+++++[>-----<-]>--------.[>+<-]++++++++[>++++++++<-]>
++++++++++++.+++.+++++.[>+<-]+++++++++[>---------<-]>---.[>+<-]++++++++[>+++++++
+<-]>+++++++++++++++.---------.[>+<-]++++++++[>--------<-]>------.[>+<-]++++++++
[>++++++++<-]>++++++++.-------.++.++++++++.--.+++++.-------.[>+<-]++++++++[>----
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() {