Skip to content

Instantly share code, notes, and snippets.

defunkt / how to do arguments in mustache.rb
Created Mar 6, 2010
how to do arguments in mustache.rb
View how to do arguments in mustache.rb
require 'rubygems'
require 'mustache'
class HandleBar < Mustache
def respond_to?(methodname)
methodname = methodname.to_s.split(':').first
super methodname
def method_missing(methodname, *args)
defunkt /
Created Mar 3, 2010 — forked from mmalone/
Simple shell script that locates a Python module and opens it in vi.
if [ $# -ne 1 ]; then
echo "Usage: vipy <python module>"
exit 1
MODULE_LOCATION=`python -c "import $1; print $1.__file__.rstrip('c')"`
if [ -z $MODULE_LOCATION ]; then
defunkt / require_benchmarking.rb
Created Jan 16, 2010 — forked from mcmire/
Override 'require' to record the time it takes to require a Ruby file.
View require_benchmarking.rb
require 'benchmark'
require 'yaml'
require 'set'
# This overrides 'require' to records the time it takes to require a file, and
# then generate a report. It's intelligent enough to figure out where files were
# required from and construct a hierarchy of the required files.
# To use, copy this file to lib/require_benchmarking.rb, then add this to the
# top of the Rails::Initializer block in environment.rb:
View gist:217660
# Save in your .bash_profile then: isreg
function isreg {
dig soa $1 | grep -q ^$1 && echo "Yes" || echo "No"
View bertmark.rb
require 'rubygems'
require 'bert'
require 'json'
require 'yajl'
require 'benchmark'
ITER = 1_000
tiny = t[:ok, :awesome]
small = t[:ok, :answers, [42] * 42]
View gist:212071
require 'rubygems'
require 'typhoeus'
require 'yajl/json_gem'
hydra =
request ='http://localhost:8089/?id=timeline', :method => :post, :body => stuff.to_json)
request.on_complete do |response|
response.code # http status
response.time # time taken in seconds
View Dictionary lookup with default
public static V GetValueOrDefault<K, V>(this Dictionary<K, V> dic, K key, V defaultVal)
V ret;
return dic.TryGetValue (key, out ret) ? ret : defaultVal;
View autobench_grapher.rb
# Used to graph results from autobench
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'

Sinatra+Mustache Partial Madness

2 problems

  1. It is looking for ./partial.html and not partial.mustache
  2. Using the method chain in you should see "klass is Partial". It seems like it should be PartialDemo::Views::Partial
View gist:206371
fork {
handle_connection (with select())