Skip to content

Instantly share code, notes, and snippets.

@cap10morgan
cap10morgan / index.html
Last active January 10, 2020 17:07 — forked from darwin/index.html
Welcome to comix!
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,350)">
@cap10morgan
cap10morgan / reduce-kv->transducer.clj
Last active April 9, 2018 16:22
Using Clojure transducers with maps
;; Usually when doing a shallow transform on a map in Clojure I reach for `reduce-kv`, but when I have more than one reduce-kv
;; I start thinking I should use transducers instead.
;; So if I start with something like this:
(ns my.ns
(:require [clojure.edn :as edn]))
(defn strip-key-namespaces [m]
(reduce-kv
(fn [a k v]
@cap10morgan
cap10morgan / clojure_dev_candidate_exercise.md
Last active February 16, 2017 19:44
Clojure dev candidate exercise

TODO List

NOTE: This is version 1 of the exercise. We used it for the first 2 rounds of dev hiring in which we had an anonymous coding exercise at all. There is now a version 2 developed in collaboration with staff developers who were subjected to this one as candidates. They had... opinions.

This assignment is designed to gauge how well you know or can pick up Clojure and some common libraries to build a simple web application.

You should spend no more than a week on it. In fact, it is due one week after it is assigned. You should also focus on depth rather than breadth. Do as much good work as you can on each step rather than trying to do a little work on more steps.

@cap10morgan
cap10morgan / rabbitmq_bug_str.md
Last active December 15, 2016 21:18
Steps to reproduce RabbitMQ qos admin UI bug
  1. Run docker run --rm -ti -p 5672:5672 -p 15672:15672 rabbitmq:3.6.5-management
  2. Fire up a Clojure REPL w/ langohr available
  3. (require '[langohr.core :as rmq])
  4. (def rconn (rmq/connect))
  5. (require '[langohr.channel :as lch])
  6. (def rch (lch/open rconn))
  7. (require '[langohr.queue :as lq])
  8. (lq/declare rch "foo.bar" {:exclusive false :auto-delete false :durable true})
  9. (require '[langohr.consumers :as lcons])
  10. (lcons/subscribe rch "foo.bar" (fn [_ _ ^bytes m] (println (String. m "UTF-8"))) {:auto-ack true})
Verifying that "wesmorgan.id" is my Blockstack ID. https://onename.com/wesmorgan
@cap10morgan
cap10morgan / gist:7811378
Created December 5, 2013 19:10
7maples Floobits Emacs log
Now listening on 53541
('got user_input', {u'id': 0, u'initial': u'~/floobits/share/democracyworks/payments-api', u'prompt': u'Give me a directory to sync data to: ', u'name': u'user_input', u'response': u'~/turbovote/payments-api'})
[Thu Dec  5 11:35:23 2013] Connecting to floobits.com:3448
Connecting to floobits.com:3448
SSL handshake completed to floobits.com:3448
Overwrite the following local files?
test/payments_api/service_test.clj
.gitignore
@cap10morgan
cap10morgan / async_geolocation.cljs
Created November 15, 2013 23:10
core.async HTML5 geolocation in ClojureScript
(ns cljs-minimal.core
(:require [cljs.core.async :as async :refer [put! <! >! <!! >!! chan]])
(:require-macros [cljs.core.async.macros :as m :refer [go]]))
(defn get-position []
(let [out (chan)
geo (.-geolocation js/navigator)]
(.getCurrentPosition geo (fn [pos] (put! out pos)))
out))
@cap10morgan
cap10morgan / gist:6284911
Created August 20, 2013 17:59
Datomic entity creation, querying, and retraction
elections-api.peer=> (init-db)
#<promise$settable_future$reify__5429@127cc7ca: {:db-before datomic.db.Db@1ea21c76, :db-after datomic.db.Db@61f108a4, :tx-data [#Datum{:e 13194139534313 :a 50 :v #inst "2013-08-20T17:13:49.111-00:00" :tx 13194139534313 :added true} #Datum{:e 17592186045418 :a 10 :v :election-constructor :tx 13194139534313 :added true} #Datum{:e 17592186045418 :a 52 :v #db/fn{:code "(if (not (nil? district)) (let [txn [(merge district [:db/id #db/id[:db.part/user -2]]) (merge election {:db/id #db/id[:db.part/user -1], :turbovote.election/district #db/id[:db.part/user -2]})]] txn) (let [txn [(merge election {:db/id #db/id[:db.part/user -1]})]] txn))", :params [db election district], :requires [], :imports [], :lang :clojure} :tx 13194139534313 :added true}], :tempids {-9223350046623220306 17592186045418}}>
elections-api.peer=> (def conn (d/connect "datomic:mem://elections-api"))
#'elections-api.peer/conn
elections-api.peer=> (d/transact conn [[:election-constructor {:turbovote.election/name "Foo
(defproject mail-batcher "0.0.1-SNAPSHOT"
:description "Find and generate forms for registrations and elections in date range"
:dependencies [[org.clojure/clojure "1.5.1"]
[turbovote/clj-time "0.5.1-SNAPSHOT"]
[korma "0.3.1-SNAPSHOT"]
[mysql/mysql-connector-java "5.1.24"]
[sonian/carica "1.0.2"]
[cheshire "5.1.1"]
[resque-clojure "0.2.2"]
[org.clojure/tools.cli "0.2.2"]
@cap10morgan
cap10morgan / gist:6224916
Created August 13, 2013 19:43
Output of `lein with-profile production uberjar` under 2.3.1; this produces a non-working jar file
ᐅ lein with-profile production uberjar
Performing task 'uberjar' with profile(s): 'production'
Retrieving lein-midje/lein-midje/3.0.1/lein-midje-3.0.1.pom from clojars
Retrieving lein-midje/lein-midje/3.0.1/lein-midje-3.0.1.jar from clojars
Created /Users/wmorgan/dev/mail-batcher/target/production+uberjar/mail-batcher-0.0.1-SNAPSHOT.jar
Created /Users/wmorgan/dev/mail-batcher/target/production/mail-batcher-0.0.1-SNAPSHOT-standalone.jar
ᐅ java -jar target/production/mail-batcher-0.0.1-SNAPSHOT-standalone.jar
Error: Could not find or load main class mail_batcher.core