Skip to content

Instantly share code, notes, and snippets.

def add_css_class(original, add)
if original.nil?
return add
else
return [original, add].join(' ')
end
end
### Use Case
11:20 < phinze> is there a quick way to clean up all ~1~ back ups in a working tree?
11:21 < jelmer> phinze, bzr clean-tree --detritus
11:21 < Peng_> (which is provided by bzrtools)
11:21 < phinze> beautiful
11:21 < jelmer> Peng_, See my last post to the mailing list :-)
11:22 < phinze> --detritus ...? what strange voodoo is this? :)
11:22 < LarstiQ> phinze: it's a beautiful English word akin to 'cruft'
11:22 < Peng_> jelmer: Well, it hasn't been merged yet. :P
11:22 < phinze> "debris: the remains of something that has been destroyed or broken up "
11:22 < phinze> nice
$ bzr branch bzr+ssh://dev/uiris3/trunk
Branched from revision 123
$ cd trunk
# ... hack hack hack (meanwhile Bob commits 124 and Alice commits 125 to shared trunk branch)
$ bzr commit -m "First local checkpoint"
Committed revision 124
# ... hack hack hack (meanwhile Bob commits 126 and 127 to shared trunk branch)
$ bzr commit -m "Second local checkpoint"
Committed revision 125
# ... hack hack finish (meanwhile Alice commits 128 to shared trunk branch)
$ bzr init-repo --rich-root-pack uiris3
$ cd uiris3
$ bzr checkout bzr+ssh://dev/uiris3/trunk trunk.bound
$ bzr branch trunk.bound mycoolfeature
$ cd mycoolfeature
# ... hack hack hack (meanwhile Bob commits 124 and Alice commits 125 to shared trunk branch)
$ bzr commit -m "First local checkpoint"
Committed revision 124
# ... hack hack hack (meanwhile Bob commits 126 and 127 to shared trunk branch)
$ bzr commit -m "Second local checkpoint"
########################
# Development Directory
########################
$ cd dev/uiris
$ tree -d -L 3 # truncated manually as well
.
|-- aris.bound
|-- features
| |-- difference_viewer.bound
# CODE ------------------
# app/helpers/really_long_helper.rb
class ReallyLongHelper
def fooA
'hello america'
end
# ...
def fooZZ
'hello zanzabar'
$ irb
>> puts :foo.hash.abs
192898
=> nil
>> puts :bar.hash.abs
207218
=> nil
>>
$ ruby -e 'puts :foo.hash.abs'
# What is worse?
<%= f.table "Bill Dates", @bill_dates do |t|
t.date
t.billed?
end %>
# Or
<% f.table "Bill Dates", @bill_dates do |t| %>
# ----------------------------------------------------------------
# Injecting reloadable code into a rails core class from a plugin
# ----------------------------------------------------------------
# lib/action_view_extensions/foo_form_helper.rb
module ActionViewExtensions::FooFormHelper
def foo
"foo!"
end
# vendor/plugins/has_associated_data
def ModelFoo < ActiveRecord::Base
has_associated_data do |a|
a.building :through => [:animal_location]
a.method_i_want_exposed :through => [:association, :chain, :to, :get, :there], :attr => :if_different_than_exposed_method
end
def building
end