Skip to content

Instantly share code, notes, and snippets.

@defunkt
defunkt / hooks.rb
Created August 17, 2009 15:55 — forked from lazyatom/hooks.rb
module Rip
module Commands
# Runs ~/.rip/active/hooks/used after `rip use`
# and ~/.rip/active/hooks/will-leave when moving to another env
alias_method :rip_use, :use
def use(*args)
run_hook_if_exists('before-leave', Rip::Env.active)
rip_use(*args)
run_hook_if_exists('after-use', Rip::Env.active)
end
RAILS_ROOT ||= ENV["RAILS_ROOT"]
namespace :bundle do
js_bundle = Rails.root + "/public/javascripts/bundle.js"
js_files = Dir[Rails.root + "/public/javascripts/{github,jquery}.*.js"].sort
task :all => [ js_bundle, :gist_js, :css ]
file js_bundle => js_files do |task|
require 'lib/js_minimizer'
@defunkt
defunkt / gist:186983
Created September 14, 2009 23:00 — forked from rcarver/gist:185656
class SomeFastJob
@queue = :high
def self.perform
fast_stuff
end
end
class SomeSlowJob
@queue = :low
diff --git a/haystack/models.py b/haystack/models.py
index ab5f401..7777bf8 100644
--- a/haystack/models.py
+++ b/haystack/models.py
@@ -3,6 +3,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.utils.encoding import force_unicode
from django.utils.text import capfirst
+from django.utils.translation import ugettext_lazy as _
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
# 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 / 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
require 'rubygems'
require 'bert'
require 'json'
require 'yajl'
require 'benchmark'
ITER = 1_000
tiny = t[:ok, :awesome]
small = t[:ok, :answers, [42] * 42]