Skip to content

Instantly share code, notes, and snippets.

View loan-payment-data.json
bhb / init.cljs
Last active Nov 7, 2018 — forked from borkdude/init.cljs
Speculative + Expound in Klipse
View init.cljs
(require '[cljs.spec.alpha :as s])
(require '[cljs.spec.test.alpha :as stest])
(require '[expound.alpha :as expound])
(require '[speculative.core])
(set! s/*explain-out* (expound/custom-printer {:show-valid-values? true}))
(stest/instrument `map)
(map 'lol 'lol)
(catch :default e
(println (.-message e))))
bhb / multimethod_selector.clj
Last active Nov 13, 2019 — forked from mtnygard/multimethod_selector.clj
A clojure.spec.gen.alpha generator that picks a multimethod implementation from the known set.
View multimethod_selector.clj
(require '[clojure.spec.gen.alpha :as sgen])
;; original
(defn multimethod-selector
"Returns a generator that picks one dispatch value from the known
dispatch values of a multimethod. Defers the lookup of dispatch
values until sampling time, so any defmethods evaluated after the
generator is created may still be selected."
bhb / reagent-state-bidi-input.cljs
Last active Jun 13, 2017 — forked from pesterhazy/
Reagent input field experiments in bidirectional binding
View reagent-state-bidi-input.cljs
(ns klipse-like.core
(:require [reagent.core :as r])
(:import [goog.async Delay]))
(defonce !state (r/atom nil))
(defn input*
"Like :input, but support on-change-text prop. Avoids mutability pitfalls of
View gist:6116481
# -*- coding: utf-8 -*-
require "addressable/uri"
require "uri"
def uri_valid?(uri)
uri = Addressable::URI.parse(uri)
# If it could not be parsed, it won't have a valid scheme
%w{http https}.include?(uri.scheme)
rescue Addressable::URI::InvalidURIError
View scary-pg-mongoid-sequel-ar-benchmark.rb
# following is a little benchmark looking a real world example of inserting a
# bunch of records into pg and mongo using a few methods available in ruby.
# this is not meant to be an apples to apples benchmark, rather it's trying to
# see how the various dbs might perform in a real world situation. i know
# mongo does not fsync to disk. i know it's not fair using a transaction with
# the rdbms, but these conditions will exist in real world usage and it's that
# which i'm interested in.
# here is a few runs
View sl_gems_update.rb
#!/usr/bin/env ruby
puts "looking for the gems to upgrade..."
gem_info =, :version)
to_reinstall = []
Dir.glob('/opt/local/lib/ruby/gems/**/*.bundle').map do |path|
path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/
name, version = $1, $2
bundle_info = `file #{path}`
to_reinstall <<, version) unless bundle_info =~ /bundle x86_64/