Skip to content

Instantly share code, notes, and snippets.

View chrismurrph's full-sized avatar

Chris Murphy chrismurrph

View GitHub Profile
@bhb
bhb / repl.txt
Created October 18, 2017 22:49
Error messages at clojure repls
;; clojure 1.8.0 - lein repl
user=> (defn hello "hello world")
IllegalArgumentException Parameter declaration missing clojure.core/assert-valid-fdecl (core.clj:7181)
;; clojure 1.9.0-beta2 - lein repl
user=> (defn hello "hello world")
@arichiardi
arichiardi / email.clj
Created July 15, 2016 18:28
Send an email with attachments using SES, postal and selmer
ns services.email
(:require [clojure.tools.logging :as log]
[clojure.string :as string]
[clojure.java.io :as io]
[schema.core :as s]
[camel-snake-kebab.core :as csk]
[camel-snake-kebab.extras :as cske]
[amazonica.core :as aws]
[amazonica.aws.simpleemail :as ses]
[selmer.parser :as selmer]
@daveliepmann
daveliepmann / localstorage.cljs
Created September 23, 2014 08:23
HTML5 localStorage utility functions for ClojureScript. I find it makes for cleaner code when I wrap the native JS.
(ns localstorage)
(defn set-item!
"Set `key' in browser's localStorage to `val`."
[key val]
(.setItem (.-localStorage js/window) key val))
(defn get-item
"Returns value of `key' from browser's localStorage."
[key]
@stathissideris
stathissideris / multi-acc-reduce.clj
Last active September 13, 2015 04:50
Reduce with multiple accumulators
(reduce
(fn [{:keys [odd even]} datum]
(if (odd? datum)
{:odd (conj odd datum)
:even even}
{:odd odd
:even (conj even datum)}))
{:odd []
:even []}
(range 20))
@cstorey
cstorey / index.html
Created February 24, 2014 22:50
A trivial clojurescript paint program using Reagent and core.async. Greatly inspired by the RxJS paint example.
<html>
<head>
<script src="out/goog/base.js" type="text/javascript"></script>
<script src="hello_world.js" type="text/javascript"></script>
<script type="text/javascript">goog.require("hello_world.core");</script>
</head>
<body>
</body>
<script type="text/javascript">hello_world.core.run()</script>
</html>
@jizhang
jizhang / md5.clj
Created December 18, 2012 07:14
Clojure - Calculate MD5 hash of a given string.
(import 'java.security.MessageDigest
'java.math.BigInteger)
(defn md5 [s]
(let [algorithm (MessageDigest/getInstance "MD5")
size (* 2 (.getDigestLength algorithm))
raw (.digest algorithm (.getBytes s))
sig (.toString (BigInteger. 1 raw) 16)
padding (apply str (repeat (- size (count sig)) "0"))]
(str padding sig)))