Skip to content

Instantly share code, notes, and snippets.

Avatar

Amiel Martin amiel

View GitHub Profile
View show.html.erb
<%= Group.timespan_filter(@range).count :conditions => :etc %>
View gist:174323
require 'httparty'
require 'rack'
class Rack::Validate
attr_reader :app, :options
def initialize(app, options={})
@app = app
@options = options
View gist:174854
[["201", "hurl", "http://hurl.r09.railsrumble.com"], ["734m", "LAZEROIDS!", "http://lazeroids.r09.railsrumble.com"], ["a-coders-diarrhea", "idealist", "http://idealist.r09.railsrumble.com"], ["aaron-longwell", "The Line Diet", "http://linediet.r09.railsrumble.com"], ["acts_as_ninjas", "Bartender Cocktail Recipies", "http://bartender.r09.railsrumble.com"], ["agile-bastards", "Everybody Loves Beer", "http://lovesbeer.r09.railsrumble.com"], ["agile-nomads", "PeepNote", "http://peepnote.r09.railsrumble.com"], ["agilitic-featuring-meboo", "PingMyRide", "http://agilitic.r09.railsrumble.com"], ["allcaps", "Decaf Sucks", "http://allcaps.r09.railsrumble.com"], ["andrew", "Rostered", "http://rostered.r09.railsrumble.com"], ["antga-me", "antga.me", "http://antgame.r09.railsrumble.com"], ["awesome", "Twt App", "http://valuable.r09.railsrumble.com"], ["bendyworks", "Yield the Floor", "http://yieldthefloor.r09.railsrumble.com"], ["big-bad-machine", "Twitter Competition Manager", "http://roundem.r09.railsrumble.com"], ["big
View migrate_to_is_paranoid.rb
class MoveToParanoid < ActiveRecord::Migration
def self.up
classes_with_active = Dir['app/models/*'].collect do |f,o|
n = File.basename(f,'.rb')
m = n.classify.constantize
if m.respond_to?('column_names')
m.reset_column_information
m.column_names.include?('active') and m
end or nil
end.compact
View base.js
var Base = {};
// register a variable for use within the Base namespace
// there is an optional scope
// You may want to use the +js_var+ helper found in javascript_helper.rb
Base.register_variable = function(key, value, scope) {
if (scope) {
if (typeof Base[scope] === "undefined") Base[scope] = {};
Base[scope][key] = value;
} else {
View _unobtrusive_hack.html.erb
<style type="text/css">
.js .jshide{ display: none; }
</style>
<script type="text/javascript">
document.getElementsByTagName('html')[0].className += 'js';
</script>
View incrementify_string.rb
module IncrementifyString
# Helps create a user friendly unique string
# For example, calling incrementify_string! repeatedly starting with
# 'string' would yield:
# 'string' => 'string1' => 'string2' => 'string3' ... 'string9' => 'string10' => 'string11' ... etc
def incrementify_string!(bar)
if bar.match(/[0-8]$/)
bar.succ! # this is faster than regex parse and to_i + 1 to_s
elsif bar.ends_with?('9')
m = bar.match(/(\d+)$/)
@amiel
amiel / base.js
Created Oct 21, 2009
re-initialize
View base.js
Base.initializers = {};
Base.init = function() {
if (arguments.length == 1) {
var to_init = arguments[0],
scope = $(to_init).not('.initialized').addClass('initialized');
$.each(Base.initializers[to_init], function(i, f) { f.apply(scope); });
} else {
@amiel
amiel / i18n_step.rb
Created Oct 27, 2009
allow cucumber steps to refernce i18n
View i18n_step.rb
Then /^I should see :"([^\"]*)"$/ do |text|
assert_contain I18n.t(text)
end
You can’t perform that action at this time.