Skip to content

Instantly share code, notes, and snippets.

View leehambley's full-sized avatar

Lee Hambley leehambley

View GitHub Profile
@leehambley
leehambley / backbone.js
Created September 6, 2011 13:00
Backbone and Underscore
BestLovedProducts.Controllers.AffiliateProducts = Backbone.Router.extend({
routes: {
"": "index"
},
index: function() {
var affiliate_products = new BestLovedProducts.Collections.AffiliateProducts();
affiliate_products.fetch({
success: function() {
new BestLovedProducts.Views.Index({ collection: affiliate_products});
},
STORED_PROCEDURE = 'find_the_id'
class AddStoredProcedure < ActiveRecord::Migration
def self.up
sql_statement <<-STORED_PROC
DELIMITER $$
CREATE PROCEDURE find_the_id(IN the_id INT)
BEGIN
SELECT name FROM items WHERE id = the_id;
END $$
curl -o /tmp/skaes-rubypatches-ruby-187-24843.patch https://gist.github.com/raw/2d90a8e61044074bbfe5/6d944ebeb0eaa80e64e167df4537a622d11ac5da/svn-diff-skaes-ruby.patch
rvm install 1.8.7-r24843 --patch /tmp/skaes-rubypatches-ruby-187-24843.patch -C --enable-gcdebug
rm /tmp/skaes-rubypatches-ruby-187-24843.patch
#!/bin/sh -e
process=$1
commands=`mktemp -t gdb.XXXXXXXXXX`
cat > $commands << '_EOF_'
if during_gc == 1
x/s "cannot backtrace during gc"
else
set $stack = (VALUE)backtrace(-1)
set $count = (int)rb_fix2int(rb_ary_length($stack))
set $index = 0
#flash
- flash.each do |key, value|
%div{:class => key, :id => "flash_#{key}"}= value
:javascript
Event.observe(window, 'load', function() {
Effect.Fade('flash_#{key}', { duration: 3.0 });
});
class MyMiddleware
def self.call(env)
new({:a => 'b'}).call(env)
end
def initialize(config)
@config = config
end
def call(env)
@leehambley
leehambley / Gemfile
Created February 11, 2010 12:49 — forked from samgranieri/Gemfile
source :gemcutter
gem 'rails', '~> 2.3.5', :require => nil
class MessageMailer < Merb::MailController
include DataMapper::Validate
extend DataMapper::Validate::ClassMethods
def attribute_get(sym); @params[sym] end
def attribute_set(sym, val); @params[sym] = val end
[:from].each { |s|
class_eval "
def #{s}; attribute_get(:#{s}) end
module Rack
class NoIE
def initialize(app, options = {})
@app = app
@options = options
@options[:redirect] ||= 'http://www.microsoft.com/windows/internet-explorer/default.aspx'
@options[:minimum] ||= 7.0
end
def call(env)
# Throw this into your bash init file for automatic
# paging of a few svn commands, a la git.
SVN_PATH=`which svn`
function svn
{
case $1 in
cat | diff | help | list | log )
if test -t 1
then