Skip to content

Instantly share code, notes, and snippets.

1926 David Heinemeier Hansson
1615 Jeremy Kemper
436 Rick Olson
377 Josh Peek
354 Jamis Buck
339 Nicholas Seckar
295 Michael Koziarski
244 Pratik Naik
156 Marcel Molina Jr.
142 Geoff Buesing
# version 2.0 of http://ozmm.org/posts/easy_rails_asset_ids_with_git.html
repo = Grit::Repo.new('/path/to/your/app/shared/cached-copy')
js = repo.log('deploy', 'public/javascripts', :max_count => 1).first
css = repo.log('deploy', 'public/stylesheets', :max_count => 1).first
ENV['RAILS_ASSET_ID'] = js.committed_date > css.committed_date ? js.id : css.id
@wmoxam
wmoxam / url_dsl.rb
Created December 14, 2009 20:01 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
a=[10,20,30,40,50]
i = 0
a.each_index {|i|
break if a[i] > 20
}
## app/models/legacy/article.rb [ruby_on_rails]
class Legacy::Node < Legacy::Base
set_table_name 'node'
set_inheritance_column :node_type
set_primary_key :nid
default_scope select("*, concat('Legacy::', IF(type = 'ic_article', 'Article', IF(type = 'ic_video', 'Video', concat(UPPER(SUBSTRING(type, 1, 1)), LOWER(SUBSTRING(type, 2)))))) as node_type")
end
Purging db...
Include Seeds? (N|y): y
== Including Seeds
== Migrating to latest...
== AddPlatforms: migrating ===================================================
== AddPlatforms: migrated (0.0060s) ==========================================
== AddDevices: migrating =====================================================
== AddDevices: migrated (0.0057s) ============================================