Skip to content

Instantly share code, notes, and snippets.

View jeremyheiler's full-sized avatar

Jeremy Heiler jeremyheiler

View GitHub Profile
mvn archetype:generate -DgroupId=io.github.jeremyheiler -DartifactId=irc -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
user> (def m {:a {:b 2 :c 3} :b {:d 4 :e 5} :c {:f 6}})
#'user/m
user> (reduce (fn [m k] (update-in m [k] (comp vec keys))) m (keys m))
{:c [:f], :b [:e :d], :a [:c :b]}
@jeremyheiler
jeremyheiler / WaitNotify1.java
Last active August 29, 2015 14:04
Basic example of using wait() and notify().
public class Main {
public static final Object LOCK = new Object();
public static void main(String[] args) throws InterruptedException {
new Thread(new A()).start();
new Thread(new B()).start();
}
}

Notes from "Shut Up and Take My Money" by Josh Kaufman

Link: http://vimeo.com/71250239

Every business has five parts:

  1. Value creation
  2. Marketing - "here i am, this is what i do, here is why you should be interested"
  3. Sales - doing transactions
  4. Value delivery - what does it take to give what i've sold to the customer?
public class B {
public Object lock = new Object();
public String foo() {
return "foo";
}
public synchronized String bar() {
return "bar";
(defn decode-key
"Converts a train case string into a snake case keyword."
[s]
(keyword (str/replace s "_" "-")))
(defn encode-key
"Converts a snake case keyword into a train case string."
[k]
(str/replace (name k) "-" "_"))
package bencode
import (
"fmt"
"io"
"reflect"
)
func Encode(w io.Writer, x interface{}) {
v := reflect.ValueOf(x)
@jeremyheiler
jeremyheiler / with-system-out-str.clj
Last active March 13, 2019 16:50
Hijacking System.out with Clojure
(defmacro with-system-out-str
[& body]
`(let [out# System/out
buf# (java.io.ByteArrayOutputStream.)
prs# (java.io.PrintStream. buf#)
wtr# (java.io.OutputStreamWriter. prs#)]
(try
(System/setOut prs#)
(binding [*out* wtr#]
(do ~@body))
vagrant@vagrant-ubuntu-precise-64:/opt/proj$ LEIN_HOST=0.0.0.0 lein repl :headless
Retrieving cider/cider-nrepl/0.8.1/cider-nrepl-0.8.1.pom from clojars
Retrieving compliment/compliment/0.2.0/compliment-0.2.0.pom from clojars
Retrieving cider/cider-nrepl/0.8.1/cider-nrepl-0.8.1.jar from clojars
Retrieving compliment/compliment/0.2.0/compliment-0.2.0.jar from clojars
/opt/proj/.git/HEAD
/opt/proj/.git/refs/heads/content
nREPL server started on port 49301 on host 127.0.0.1 - nrepl://127.0.0.1:49301
user> (debugger.core/describe-connectors)
name: com.sun.jdi.CommandLineLaunch
class: com.sun.tools.jdi.SunCommandLineLauncher
description: Launches target using Sun Java VM command line and attaches to it
type: launching
transport: dt_socket
default: true
arguments: home=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
options=
main=