Skip to content

Instantly share code, notes, and snippets.

# TODO - add dependent option support
def delete_records(records)
klass = @reflection.through_reflection.klass
records.each do |associate|
klass.delete_all(construct_join_attributes(associate))
end
end
" ============================================================================
" Netrw Directory Listing (netrw v135)
" /Users/reinh/.vim/bundle
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec
" ============================================================================
../
gist-vim/
vim-fugitive/
"=============================================================================
" File: gist.vim
" Author: Yasuhiro Matsumoto <[email protected]>
" Last Change: 26-Oct-2009.
" Version: 3.0
" WebPage: http://github.com/mattn/gist-vim/tree/master
" Usage:
"
" :Gist
" post whole text to gist.
"=============================================================================
" File: gist.vim
" Author: Yasuhiro Matsumoto <[email protected]>
" Last Change: 26-Oct-2009.
" Version: 3.0
" WebPage: http://github.com/mattn/gist-vim/tree/master
" Usage:
"
" :Gist
" post whole text to gist.
# TODO - add dependent option support
def delete_records(records)
klass = @reflection.through_reflection.klass
records.each do |associate|
klass.delete_all(construct_join_attributes(associate))
end
end
class ActiveRecord::Associations::HasManyThroughAssociation
private
def delete_records(records)
klass = @reflection.through_reflection.klass
method_map = {:destroy => :destroy_all}
method_name = method_map.fetch(@reflection.options[:dependent], :delete_all)
delete_method = klass.method(method_name)
records.each do |associate|
delete_method.call(construct_join_attributes(associate))
@reinh
reinh / run_tags.rb
Created November 3, 2009 22:32 — forked from tobias/run_tags.rb
#!/usr/bin/ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/usr/bin/env ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'
uudec(Text) -> << <<(X-32):6>> || <<X:8>> <= Text >>.
ydec (<<$=, X, Rest/binary>>) -> <<(X-106 rem 256):8, (ydec(Rest))/binary>>;
ydec (<<X, Rest/binary>>) -> <<(X-42 rem 256):8, (ydec(Rest))/binary>>;
ydec (<<>>) -> <<>>.
FileElement = lists:last(xmerl_xpath:string("//file", Xml)),
{file, Attributes, _} = xmerl_lib:simplify_element(FileElement),
FileElement = lists:last(xmerl_xpath:string("//file", Xml)),
{file, Attributes, _} = xmerl_lib:simplify_element(FileElement),
Subject = proplists:get_value(subject, Attributes),