Skip to content

Instantly share code, notes, and snippets.

@defunkt
defunkt / alternately, named arguments in mustache.rb
Created March 6, 2010 06:12
named arguments in mustache.rb
require 'rubygems'
require 'mustache'
class HandleBar < Mustache
def respond_to?(methodname)
methodname = methodname.to_s.split(/\s+/).first
super methodname
end
def method_missing(methodname, *args)
@defunkt
defunkt / how to do arguments in mustache.rb
Created March 6, 2010 06:12
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
end
def method_missing(methodname, *args)
@defunkt
defunkt / vipy.sh
Created March 3, 2010 04:11 — forked from mmalone/vipy.sh
Simple shell script that locates a Python module and opens it in vi.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: vipy <python module>"
exit 1
fi
MODULE_LOCATION=`python -c "import $1; print $1.__file__.rstrip('c')"`
if [ -z $MODULE_LOCATION ]; then
@defunkt
defunkt / require_benchmarking.rb
Created January 16, 2010 20:35 — forked from mcmire/require_profiler.md
Override 'require' to record the time it takes to require a Ruby file.
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:
#!/bin/bash
#
# Save in your .bash_profile then: isreg domain.com
function isreg {
dig soa $1 | grep -q ^$1 && echo "Yes" || echo "No"
}
require 'rubygems'
require 'bert'
require 'json'
require 'yajl'
require 'benchmark'
ITER = 1_000
tiny = t[:ok, :awesome]
small = t[:ok, :answers, [42] * 42]
@defunkt
defunkt / gist:212071
Created October 16, 2009 21:01 — forked from pauldix/gist:212062
require 'rubygems'
require 'typhoeus'
require 'yajl/json_gem'
hydra = Typhoeus::Hydra.new
request = Typhoeus::Request.new('http://localhost:8089/?id=timeline', :method => :post, :body => stuff.to_json)
request.on_complete do |response|
response.code # http status
response.body
response.time # time taken in seconds
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;
}
# 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 config.ru you should see "klass is Partial". It seems like it should be PartialDemo::Views::Partial