Skip to content

Instantly share code, notes, and snippets.

View texel's full-sized avatar

Leigh Caplan texel

View GitHub Profile
#!/usr/bin/env ruby
branch_name = `git rev-parse --abbrev-ref HEAD`
branch_number_regex = /^(\d+)/
matcher = branch_name.match(branch_number_regex)
branch_number = matcher[1]
if branch_number
path = ARGV[0]
require 'test_helper'
require 'minitest/autorun'
describe VenuesController do
describe "#index" do
it "must succeed" do
get :index
response.status.must =~ /200/
end
end
@texel
texel / fiddle.response.html
Created April 13, 2011 00:53
fiddle.response.html
<div>Hello there!</div>
class SuperClass
def foo
puts "I'm in super!"
end
alias :bar foo
end
class SubClass < SuperClass
def foo
puts "I'm in sub!"
@texel
texel / animations.js
Created January 6, 2011 04:44
I want div to slide down *and* fade in, AT THE SAME TIME (ZOMG)
$(div).fadeIn().show('slide', {direction: 'up'}); // BZZZT... they both get queued
// BZZZZT... they both get added to the object's fx queue... same deal!
$(div).fadeIn();
$(div).show('slide', {direction: 'up'});
$(div).fadeIn().show('slide', {direction: 'up'}).dequeue(); // DINGDINGDING! This works but is incredibly stupid!
setStatus : function ( status ) {
var triggerChange = this.get("status") == status;
this.set({status: status});
if (triggerChange)
this.trigger("change:status", this, status);
}
HotCocoa::URLConnection.get('http://google.com') do |c|
c.success { success_callback }
c.failure { failure_callback }
c.error { |e| error_handler.call_something e }
end
require 'active_support'
class Geckobyte
include HTTParty
base_uri 'http://webservices.geckobyte.com'
remote_methods = %w[bodies brands makes models options tire tires tires_by_brand_name tires_by_size
tires_test tires_with_wheel vehicle wheel wheels_by_brand_name wheels_with_tire years]
remote_methods.each do |m|
NSURLConnection.connectionWithRequest(url_request, delegate: ConnectionDelegate.new do |d|
d.success { |data| some_object.do_something_with_data(data) }
d.failure do |data, error|
# we can do something more complex here... and we don't have to look in the delegate class!
some_other_object.do_something_with_error(error)
end
end)
@texel
texel / gist:485147
Created July 21, 2010 21:15 — forked from loe/gist:485146
ree-1.8.7-2009.10 > fuckery = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(nil, "fuckery!")
=> nil
ree-1.8.7-2009.10 > fuckery
=> nil
ree-1.8.7-2009.10 > fuckery.object_id
=> 4
ree-1.8.7-2009.10 > !!fuckery
=> true
ree-1.8.7-2009.10 >