Skip to content

Instantly share code, notes, and snippets.

setup_socket
fork {
accept_connection
handle_connection (with select())
}
waitall

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
@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
# 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'
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;
}
@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"
}
@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
Namespace = ( ->
merge = (target, source) ->
for key, val of source
target[key] = val
target
_assertValidFQN = (fqn) ->
unless ///^[a-z0-9_.]+///.test fqn then throw 'invalid namespace'
class Procedure