Skip to content

Instantly share code, notes, and snippets.

View benlangfeld's full-sized avatar

Ben Langfeld benlangfeld

View GitHub Profile
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :jquery => ['jquery', 'jquery-ui', 'rails']
ActiveSupport.on_load(:action_view) do
ActiveSupport.on_load(:after_initialize) do
ActionView::Helpers::AssetTagHelper::register_javascript_expansion :defaults => ['jquery', 'jquery-ui', 'rails']
end
end
{22:21}[ruby-1.9.2@testapp]~/Desktop/testapp@master✗✗✗ ben% autotest
loading autotest/rspec2
^CInterrupt a second time to quit
^C%
@benlangfeld
benlangfeld / gist:791272
Created January 22, 2011 17:25
##rubyonrails-offtopic channel rules
0) Be nice, but not too nice.
1) Do no serious harm
2) No serious Rails or Ruby questions
3) Leave the gun. Take the cannoli.
{16:24}[ruby-1.9.2]~/Desktop ben% rails new testapp -m https://github.com/benlangfeld/rails-templates/raw/master/base.rb
....normal rails new output.....
The template [/Users/ben/Desktop/https:/github.com/benlangfeld/rails-templates/raw/master/base.rb] could not be loaded. Error: Could not find "/Users/ben/Desktop/https:/github.com/benlangfeld/rails-templates/raw/master/base.rb" in any of your source paths. Your current source paths are:
/Users/ben/Developer/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/generators/rails/app/templates
var rosterPushParams = [CPDictionary dictionaryWithObjectsAndKeys:@"iq", @"name", Strophe.NS.ROSTER, @"namespace", @"type", @"set"];
[_connection registerSelector:@selector(_didReceiveRosterPush:) ofObject:self withDict:rosterPushParams];
class IntervalArray < Array
attr_reader :range, :step_size
def initialize(range, step_size = 1)
super()
@range = range
@step_size = step_size
regenerate
end
def range=(range)
puts :hi
var countyOptionsTemplate = new EJS({text: "<option value=''></option><% for(var i=0; i<data.length; i++) { %><option value='<%= i %>'><%= data[i]['name'] %> County</option><% } %>"});
var locationData = new Object();
function GetScopedCounties(e) {
var selectedState = $('#LocationState').val();
if (!selectedState) {
return;
}
countyOptionsTemplate.update('LocationCounty', locationData[selectedState].counties);
}
def self.get_breaking_news(min)
doc = Hpricot.XML open("http://bensbargains.net/rss.xml/")
cutoff_time = Time.now - 60 * min
(doc/"item").map do |item|
profit_margin = (temp_deal.cost_retail.nil? || temp_deal.cost.nil?) ? nil : temp_deal.cost_retail - temp_deal.cost
Deal.new :name => (item/"title").inner_html, :description => (item/"description").inner_text + (item/"link").inner_html, :guid => (item/"guid").inner_html, :cost => get_price(temp_deal.name), :cost_retail => get_price_retail(temp_deal.description), :profit_margin => profit_margin, :source => "bensbargains"
end
end
class ActiveRecord::Base
def skip_stamp
self.record_timestamps = false
yield
self.record_timestamps = true
end
end