Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am alex-dixon on github.
* I am alexdixon (https://keybase.io/alexdixon) on keybase.
* I have a public key ASBAkk6q6ylqzdp0aCp94qhC_sfaKyUHifuzJBR0GvTaAQo
To claim this, I am signing this object:
This file has been truncated, but you can view the full file.
(def input "+12\n-13\n+17\n+17\n-10\n+6\n+13\n+13\n-9\n+13\n-15\n+16\n+12\n-19\n-15\n-11\n+16\n-4\n+9\n+9\n+4\n+8\n+19\n-15\n-10\n+4\n-2\n+17\n-4\n+7\n+15\n+8\n+10\n-13\n+11\n+12\n-4\n-7\n+3\n-6\n-8\n+19\n+10\n+14\n+7\n-3\n-19\n+16\n+17\n+15\n-18\n+19\n+11\n-7\n+10\n-17\n+11\n-20\n+4\n+9\n-11\n-12\n+9\n-13\n+2\n-12\n-1\n+17\n+15\n+10\n+14\n-7\n-5\n-13\n-19\n-6\n+13\n-14\n-18\n+4\n+6\n-4\n+5\n+18\n+23\n-6\n+13\n+17\n+4\n+16\n-18\n-6\n-9\n+11\n+7\n+12\n+10\n-16\n-10\n+12\n+10\n-2\n+16\n+10\n-7\n-11\n+3\n+9\n-16\n-9\n+10\n+2\n+15\n-4\n-6\n+12\n+5\n+5\n+19\n-18\n-4\n+14\n-2\n-4\n+18\n-15\n-10\n+5\n+17\n+15\n-9\n-5\n+9\n+1\n+9\n+14\n+15\n+11\n-16\n+15\n+8\n+15\n+4\n+10\n+1\n+18\n+12\n-5\n-1\n+16\n-11\n-19\n-5\n+15\n-17\n+19\n-5\n+14\n+6\n+12\n+10\n+16\n+6\n+8\n-12\n-1\n+4\n-17\n-13\n+2\n+12\n-3\n-16\n+17\n-6\n+14\n+3\n+5\n+4\n+10\n+8\n-17\n+7\n+19\n+13\n+18\n+17\n-9\n+14\n-4\n-3\n-11\n-13\n+6\n-2\n+16\n-15\n-15\n-13\n-7\n-7\n-7\n+16\n+17\n-15\n-10\n-2\n-7\n+2\n+16\n+6\n+20\n-6\n-13\n-5\n+1\n+12\n+6\n+20\n-22\n-10\
@alex-dixon
alex-dixon / README.md
Last active July 28, 2018 14:53 — forked from bhb/README.md
Clojure cool mode

Stay cool Clojurists 😎

Usage:

clj -Sdeps '{:deps {cool {:git/url "https://gist.github.com/alex-dixon/bf2218ed3d3c633ed0602e23ae76c420" :sha "a9859300b5af48a18c88bdec2feb28bc91bd9d80"}}}' -m cool

Stupid Spec Tricks

Problem: I want to spec a coll of maps. I know I can use s/coll-of and specify :kind vector? or :kind list?, but either is fine, so I've omitted it. When I call s/explain for this spec with a map it fails properly, but I get explain data for each map entry that says "x" isn't a map. I'd prefer it say it's not a collection and stop there.

Solution:

(s/def ::example (s/coll-of (s/keys :req-un [::foo]) 
(defmacro deflet [bindings & body]
`(do ~@(for [[sym expr] (partition 2 (destructure bindings))]
(list 'def sym expr))
~@body))
(defmacro defbindings [bindings]
`(do ~@(for [[sym expr] (partition 2 (destructure bindings))]
(list 'def sym expr))))
(defmacro deflast [sym]
(ns myapp.typeahead
(:require [reagent.core :as r]
[goog.functions :as gf]
[myapp.api :as api]))
(defn input-control [props]
(let [value (r/atom (:default-value props ""))
local-change #(reset! value (.. % -target -value))]
(fn [{:keys [on-change] :as props}]
@alex-dixon
alex-dixon / ns-interns.cljs
Created July 11, 2017 16:00
Confusion about symbols, quoting
(def my-ns 'precept.app-ns)
my-ns ;; => precept.app-ns
(ns-interns my-ns) ;; nth not supported on Symbol
(ns-interns 'precept.app-ns) ;; works
(ns-interns (quote precept.app-ns)) ;; works
'precept.app-ns ;; => precept.app-ns
(quote precept.app-ns) ;; => precept.app-ns
@alex-dixon
alex-dixon / 0_reuse_code.js
Created October 11, 2015 03:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
onDrop: function(e) {
e.preventDefault();
this.setState({
isDragActive: false
});
var files;
if (e.dataTransfer) {
files = e.dataTransfer.files;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
// Chapter 3 Exercises