Skip to content

Instantly share code, notes, and snippets.

View komagata's full-sized avatar

Masaki Komagata komagata

View GitHub Profile
module ActiveRecord::ConnectionAdapters::SchemaStatements
def add_foreign_key(from_table, from_column, to_table)
constraint_name = "fk_#{from_table}_#{to_table}"
execute "alter table #{from_table} add constraint \
#{constraint_name} foreign key (#{from_column}) references #{to_table}(id)"
end
def set_auto_increment(table_name, number)
execute "ALTER TABLE #{quote_table_name(table_name)} AUTO_INCREMENT=#{number}"
end
@komagata
komagata / tag.js
Created December 13, 2008 12:51
DOM building like MochiKit
function append(elem, value) {
if (typeof value == 'string') {
elem.innerHTML = value.replace(/\r\n/g, "\n").replace(/\n/g, '<br />')
} else if (typeof value == 'undefined') {
} else if (value.constructor == Array) {
for (var v in value) {arguments.callee(elem, value[v])}
} else {
elem.appendChild(value)
}
return elem
# Copy database.yml
run "cp config/database.yml config/database.example.yml"
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
# Install plugins
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git', :submodule => true
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git', :submodule => true
# Copy database.yml
run "cp config/database.yml config/database.example.yml"
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
# Install plugins
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git', :submodule => true
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git', :submodule => true
run 'rm public/index.html'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'cucumber', :git => 'git://github.com/aslakhellesoy/cucumber.git'
plugin 'webrat', :git => 'git://github.com/brynary/webrat.git'
plugin 'i18n_generators', :git => 'git://github.com/amatsuda/i18n_generators.git'
plugin 'ssl_requirement', :git => 'git://github.com/rails/ssl_requirement.git'
plugin 'exception_notification', :git => 'git://github.com/rails/exception_notification.git'
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
run 'rm public/index.html'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'cucumber', :git => 'git://github.com/aslakhellesoy/cucumber.git'
plugin 'webrat', :git => 'git://github.com/brynary/webrat.git'
plugin 'i18n_generators', :git => 'git://github.com/amatsuda/i18n_generators.git'
plugin 'ssl_requirement', :git => 'git://github.com/rails/ssl_requirement.git'
plugin 'exception_notification', :git => 'git://github.com/rails/exception_notification.git'
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
run 'rm public/index.html'
run 'README'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'cucumber', :git => 'git://github.com/aslakhellesoy/cucumber.git'
plugin 'webrat', :git => 'git://github.com/brynary/webrat.git'
plugin 'i18n_generators', :git => 'git://github.com/amatsuda/i18n_generators.git'
plugin 'ssl_requirement', :git => 'git://github.com/rails/ssl_requirement.git'
plugin 'exception_notification', :git => 'git://github.com/rails/exception_notification.git'
run 'rm public/index.html'
run 'README'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'cucumber', :git => 'git://github.com/aslakhellesoy/cucumber.git'
plugin 'webrat', :git => 'git://github.com/brynary/webrat.git'
plugin 'i18n_generators', :git => 'git://github.com/amatsuda/i18n_generators.git'
plugin 'ssl_requirement', :git => 'git://github.com/rails/ssl_requirement.git'
plugin 'exception_notification', :git => 'git://github.com/rails/exception_notification.git'
run 'rm public/index.html'
run 'README'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'cucumber', :git => 'git://github.com/aslakhellesoy/cucumber.git'
plugin 'webrat', :git => 'git://github.com/brynary/webrat.git'
plugin 'i18n_generators', :git => 'git://github.com/amatsuda/i18n_generators.git'
plugin 'ssl_requirement', :git => 'git://github.com/rails/ssl_requirement.git'
plugin 'exception_notification', :git => 'git://github.com/rails/exception_notification.git'
run 'rm public/index.html'
run 'README'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'cucumber', :git => 'git://github.com/aslakhellesoy/cucumber.git'
plugin 'webrat', :git => 'git://github.com/brynary/webrat.git'
plugin 'i18n_generators', :git => 'git://github.com/amatsuda/i18n_generators.git'
plugin 'ssl_requirement', :git => 'git://github.com/rails/ssl_requirement.git'
plugin 'exception_notification', :git => 'git://github.com/rails/exception_notification.git'