Skip to content

Instantly share code, notes, and snippets.

View bhenderson's full-sized avatar

Brian Henderson bhenderson

View GitHub Profile
@bhenderson
bhenderson / json-viewer.js
Last active January 27, 2017 19:35
json pretty printer
javascript:(
function (){
var json = JSON.parse(document.body.innerText);
var create = function(el, props) {
var e = document.createElement(el);
if (props) {
Object.keys(props).forEach(function(key) {
e[key] = props[key];
});
# MultiRuby Switcher: see multiruby for installs
mrs() {
local path="$HOME/.multiruby/install/$1/bin:"
if test "$1" = "system" -o "$1" = ""; then
echo >&2 "using system"
path=
elif ! test -d "${path%:}"; then
echo >&2 "$1 not available"
return 1
fi
$ ruby /tmp/ruby.rb -v
Run options: -v --seed 24668
# Running:
sleeping
TestReporting#test_slow = 1.00 s = .
sleeping
TestReporting#test_really_slow = 2.00 s = .
diff --git a/lib/minitest/spec.rb b/lib/minitest/spec.rb
index 5c27a99..64265f0 100644
--- a/lib/minitest/spec.rb
+++ b/lib/minitest/spec.rb
@@ -8,10 +8,10 @@ def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
self.class_eval <<-EOM
def #{new_name} *args
case
- when Proc === self then
- Minitest::Spec.current.#{meth}(*args, &self)
@bhenderson
bhenderson / tcd
Created July 24, 2013 15:45
tmux session management by directory
#!/bin/bash
attach() {
tmux attach-session -t ${1:-$name}
}
list() {
if [[ "$1" == 'short' ]]; then
local args='-F #{session_name}'
shift
@bhenderson
bhenderson / ncpipe
Last active December 18, 2015 22:08
NetCat (nc) pipe. Using coproc available in bash 4.
#!/bin/bash
server=$1
port=$2
lport=${3:=$port}
# stdout will be server
# stderr will be client
exec 3>&1
@bhenderson
bhenderson / server.rb
Created May 14, 2013 15:15
testing rdoc sinatra methods.
class Foo
##
# Public: This is my foo route
#
# See #/bar for examples (but it doesn't link)
# But this[#baz] does
get '/foo' do
end
gem install image_science -v 1.2.3
gem install image_science -v 1.2.4
export INLINEDIR=/tmp/.ruby_inline
ruby -e "gem 'image_science', '1.2.3'; require './test_inline.rb'"
ruby -e "gem 'image_science', '1.2.4'; require './test_inline.rb'"
rm -rf /tmp/.ruby_inline
@bhenderson
bhenderson / a.rb
Created February 26, 2013 04:40 — forked from tenderlove/a.rb
module A
def test_whatever
flunk 'sucks'
end
end
##
# This method gets doc'd
#
# :method: foo
add_my_method :cool, :method
##
# This method does not get doc'd
#