Skip to content

Instantly share code, notes, and snippets.

@stuartsierra
stuartsierra / fresh-chrome.sh
Last active May 10, 2025 11:01
Launch new instances of Google Chrome on OS X with isolated cache, cookies, and user config
#!/usr/bin/env bash
# fresh-chrome
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
@stuartsierra
stuartsierra / lein2-issue.md
Created July 6, 2012 21:04
'file:' repositories in Leiningen 2.0.0-preview5 and later

Sample Project

Starting from:

lein new foo
cd foo

Say I have a random JAR file that is not available in any repository:

touch README.md

@stuartsierra
stuartsierra / Sum.java
Created June 18, 2013 17:15
Brief demonstration of dead-code elimination in the JVM
/* Demonstration of dead-code elimination in the JVM.
*
* This class demonstrates some of the difficulties of benchmarking
* code which may be subject to dead-code elimination by the JVM.
* There are two loops, both calling the same function. But only the
* second loop actually uses the result of the function.
*
* When I run this code, I get results like this:
*
* Dead code:
@stuartsierra
stuartsierra / errors.clj
Created April 20, 2012 14:27
Example error messages from common mistakes with Datomic
;; Some example error messages resulting from common mistakes
;; using Datomic 0.8.4138
(ns errors
(:use [datomic.api :as d :only (db q)]))
(def uri "datomic:mem://database")
(d/create-database uri)
@stuartsierra
stuartsierra / one.clj
Last active April 2, 2020 13:12
Example Clojure Gist with multiple files
(ns one)
(defn example-function []
(println "Hello from example.one"))
@stuartsierra
stuartsierra / pair_indent.clj
Last active November 12, 2019 10:46
Demonstration of pair-wise indentation for Clojure syntax
;; Demonstration of pair-wise indentation for Clojure syntax
(let [local-symbol-one
(expression-to-compute-symbol-one)
local-symbol-two
(expression-to-compute-symbol-two)]
(body-expressions))
(def a-map
{:com.example.application/one
@stuartsierra
stuartsierra / testcomponentclojureversion.sh
Created September 9, 2019 16:54
Script to test behavior of transitive Clojure dependencies from Component
#!/bin/bash
BASEDIR=testcomponentclojureversion
rm -rf "$BASEDIR"
mkdir -p "$BASEDIR"
pushd "$BASEDIR" > /dev/null
echo ""
echo "Testing Clojure 1.8.0 and Component 0.4.0"
@stuartsierra
stuartsierra / gist:5788531
Last active August 14, 2018 16:45
Cannot convey data from an exception within a Datomic transaction
;; Example showing that I cannot convey data from an exception within
;; a transaction.
(ns example
(:require [datomic.api :as d])) ; Datomic Free 0.8.4007
(def uri "datomic:mem:example")
(d/create-database uri)
@stuartsierra
stuartsierra / spellcheck.clj
Created July 9, 2013 01:47
Example implementation of Norvig's Spellchecker in Clojure, using core.async
;; Example implementation of Norvig's Spellchecker in Clojure,
;; using core.async
;;
;; There are probably some bugs in this.
;;
;; Original problem: https://github.com/ericnormand/spelling-jam
;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/
;;
;; Clojure core.async introduction:
;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
@stuartsierra
stuartsierra / trymacrospec.sh
Created July 4, 2017 15:37
Test script for macro spec in clojure.test
#!/usr/bin/env bash
# Test script attempting to reproduce issue described at
# https://groups.google.com/d/topic/clojure/jASgZpaZkTc/discussion
# $ lein version
# Leiningen 2.7.1 on Java 1.8.0_92 Java HotSpot(TM) 64-Bit Server VM
lein new trymacrospec
cd trymacrospec