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 / 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 / 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.

diff --git a/standalone.xml b/standalone.xml
index 9547877..f47202b 100644
--- a/standalone.xml
+++ b/standalone.xml
@@ -77,7 +77,7 @@
<profile>
<subsystem xmlns="urn:jboss:domain:logging:2.0">
<console-handler name="CONSOLE">
- <level name="INFO"/>
+ <level name="DEBUG"/>
@cap10morgan
cap10morgan / gist:c022fda990b870005434
Created July 20, 2015 17:52
lazy-seq connect-to-broker
(defn connect-to-broker
([config] (connect-to-broker config 5))
([config max-tries]
(first (drop-while nil? (connect-to-broker config max-tries 1))))
([config max-tries attempt]
(if (<= attempt max-tries)
(try
[(rmq/connect config)]
(catch Throwable t
(log/warn "RabbitMQ not available:" (.getMessage t) "attempt:" attempt)
@cap10morgan
cap10morgan / gist:556efd2417c39bd9b9fa
Created June 26, 2015 19:04
balias plugin installation error
Plugin 'balias' is not installed. Run 'omf install' to download and install it.
wmorgan@Wes-MacBook-Pro:~/d/ballot-scout|master⚡*?
➤ omf install
Installing balias... ✔
test: Missing argument at index 1
Installing ... fish: Could not expand string '$argv[3]'
/Users/wmorgan/.oh-my-fish/plugins/omf/omf.git.fish (line 5): set -l path $argv[3]
^
in function 'omf.git',
called on line 31 of file '/Users/wmorgan/.oh-my-fish/plugins/omf/omf.packages.install.fish',
@cap10morgan
cap10morgan / coreos-stable-hvm-vpc.template
Created March 23, 2015 21:10
CoreOS in a VPC CloudFormation Template
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/",
"Mappings" : {
"RegionMap" : {
"eu-central-1" : {
"AMI" : "ami-0e300d13"
},
@cap10morgan
cap10morgan / install-datomic-pro.sh
Created March 13, 2015 16:22
A script for installing the Datomic Pro peer lib in docker build
#!/bin/bash
set -e
VERSION=$(grep '\[com.datomic/datomic-pro "' project.clj | awk -F\" '{print $2}')
curl -u $(<.datomic-credentials) -SL https://my.datomic.com/repo/com/datomic/datomic-pro/$VERSION/datomic-pro-$VERSION.zip -o /tmp/datomic.zip
unzip /tmp/datomic.zip -d /tmp/datomic
rm -f /tmp/datomic.zip