Skip to content

Instantly share code, notes, and snippets.

View bonkydog's full-sized avatar

Brian Jenkins bonkydog

  • Nubank
  • SF Bay Area
View GitHub Profile
@bonkydog
bonkydog / user.clj
Last active August 29, 2015 14:14
Make stdout & stderr from all threads show up in cider repl
(alter-var-root #'*out* (constantly *out*))
(alter-var-root #'*err* (constantly *err*))
@bonkydog
bonkydog / ec2-ssh-tag.bash
Last active August 29, 2015 14:08
User data bash script to tag newly launched EC2 instance with its ssh host key fingerprint.
if curl -s http://169.254.169.254; then # looks like we're running on Amazon.
# Install Java
apt-get install -y openjdk-7-jre-headless
# Install EC2 command-line tools
wget https://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-api-tools.zip -d /usr/local/ec2
# Set up EC2 environment variables
@bonkydog
bonkydog / gist:c5d2a8bc598992577993
Created June 17, 2014 21:44
profile something with ruby_prof
require 'ruby-prof'
result = RubyProf.profile do
# do something
end
printer = RubyProf::MultiPrinter.new(result)
printer.print(path: ".", profile: "profile")
@bonkydog
bonkydog / gist:9980624
Created April 4, 2014 18:35
Clojure declare example.
(declare the-map)
(defn the-function
[whatever]
(whatever the-map))
(def the-map {:foo the-function})
(ns datomizer.datomize.encode
"Encode entities by datomizing their data-structures."
(:require [datomic.api :as d :refer [q]]
[datomizer.datoms :refer :all]
[datomizer.utility.byte-array :refer [byte-array-class]]
[datomizer.utility.debug :refer :all]
[datomizer.utility.misc :refer [ref-type]]))
(ns datomizer.datoms
"Datom wrangling."
(:require [datomic.api :as d]
[datomizer.utility.debug :refer [dbg]]))
@bonkydog
bonkydog / gist:9379401
Created March 6, 2014 00:03
Gibbon barf
(@color -> case-eq-default 5 [ 'Green' : 10 ])
initial crumbs [["/"]]
locking /
-> <@color> = !12[@color]
-> <@color> = %a2
-> <@color -> case-eq-default 5 [ 'Green' : 10 ]> = %b3
-> <5> = %b3
-> <5> = (numeric)
-> <[ 'Green' : 10 ]> = (list (pair %a2 %b3))
-> <[ 'Green' : 10 ]> = (list %el4)
@bonkydog
bonkydog / show-methods.clj
Created January 25, 2014 20:08
Show methods on an object
(defn show-methods [x] (filter #(not (re-find #"^(__|const)" (str %))) (map :name (:members (clojure.reflect/reflect x)))))
@bonkydog
bonkydog / toggle-comment.el
Created January 24, 2014 18:01
Make Emacs Alt-/ behave more like RubyMine: toggle comment on region or toggle comment on line (and then move down to next line).
(defun toggle-comment-for-line-or-region (arg)
"Make Emacs Alt-/ behave more like RubyMine: toggle comment on region or
toggle comment on line (and then move down to next line)."
(interactive "*P")
(let ((initial-mark-state (and mark-active transient-mark-mode)))
(unless initial-mark-state
(mark-line))
(comment-or-uncomment-region (region-beginning) (region-end) arg)
(unless initial-mark-state
(next-line))
@bonkydog
bonkydog / read-datomic-edn.clj
Created January 18, 2014 18:28
Configure clojure reader to understand datomic tagged literals.
(use '[datomic.api :as d :only (db q)])
(clojure.edn/read-string {:readers *data-readers*} "[#db/id[:db.part/db] #db/id[:db.part/db]]")