Skip to content

Instantly share code, notes, and snippets.

View nicklewis's full-sized avatar

Nick Lewis nicklewis

View GitHub Profile
# Requires the redmine_client gem
#!/usr/bin/env ruby
require 'rubygems'
require 'redmine_client'
NORMAL = "\e[00;00m"
NORMAL_BOLD = "\e[00;01m"
YELLOW = "\e[00;33m"
BORING_CYAN = "\e[00;36m"
nicklewis / gist:804871
Created January 31, 2011 21:38
An example of aliasing in a singleton class copying a method definition
class MyClass
def my_instance_method
instance =
singleton_class = class << instance; self; end
nicklewis / brew_completion.rb
Created February 3, 2011 07:15
A bash completion file for Homebrew
#!/usr/bin/env ruby
args = ENV["COMP_LINE"].split /\s+/
# "brew"
subcommand = args.shift || ''
arg = args.last || ''
nicklewis / gist:943824
Created April 27, 2011 06:55
class Proc
def *(g)
raise ArgumentError, "arity count mismatch" unless arity == g.arity
proc { |*a| self[*g[*a] ] }
class Array
def to_proc
nicklewis / puppet_report_schema.js
Created May 19, 2011 02:42
Puppet Report json_shape schema
[ "object",
{ "members":
"host": "string",
"time": "string",
"logs": ["array", {"contents": "log_entry"}],
"metrics": ["dictionary", {"contents": "metric"}],
"resource_statuses": ["dictionary", {"keys": "^[A-Z]\\w*\\[.+\\]$", "contents": "resource_status"}],
nicklewis / jenkins.rb
Created May 25, 2011 20:46
Jenkins lava lamp
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'rubygems'
require 'atom'
# Light lava lamps based on Jenkins build status RSS feed
# Green lamp lights if all builds are good;
# Red lamp lights if any build fails.
nicklewis / if-puppet-was-more-like-lisp.pp
Created June 14, 2011 05:01
If Puppet was more like Lisp
((file /etc/apache2/apache2.conf
(ensure file)
(source puppet:///modules/apache/apache2.conf)
(service apache
(ensure running)
(enable true)
(package apache
(ensure latest)))))))
nicklewis / shuffle_spec.rb
Created September 14, 2011 19:00
Run specs in random order
#!/usr/bin/env ruby
if size_opt = ARGV.index('-s')
seed = ARGV[size_opt+1]
seed ||=
if clip_opt = ARGV.index('-c')
nicklewis / binary_search_specs.rb
Created September 14, 2011 20:09
Binary search for order-dependent test failures
#!/usr/bin/env ruby
specs_in_order ='spec_order').split
failing_spec = ARGV.first
specs = specs_in_order[0...specs_in_order.index(failing_spec)]
suspects = specs `cmp': java.lang.ClassCastException: org.jruby.RubySymbol cannot be cast to org.jruby.RubyFileStat
from RubyFileStat$i$1$0$cmp.gen:65535:in `call'
from `invokedynamic'
from `callCmpMethod'
from `op_equal'
from RubyComparable$s$1$0$op_equal.gen:65535:in `call'
from `cacheAndCall'
from `call'
from `call'
from `interpret'