This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
require 'terminal-table/import' | |
# Convert an array of instances to an ascii table using the "terminal-table" gem on gemcutter.org | |
def to_ascii_table(attributes_set = []) | |
begin | |
raise "All items must be of the same class, found #{self.collect(&:class).uniq.to_sentence}" if self.collect(&:class).uniq.size != 1 | |
# Get a list of all existing attributes from the list. | |
if attributes_set.blank? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'cgi' | |
zipfile = ARGV[0] | |
`mkdir /tmp/keycutter` | |
`cp #{zipfile} /tmp/keycutter/keycutter.zip` | |
`cd /tmp/keycutter && unzip -o keycutter.zip` | |
doc = Nokogiri::XML(open('/tmp/keycutter/index.apxl')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install | |
# | |
# Move this file into config/preinitializer.rb | |
# | |
# Usage | |
# | |
# This line: | |
# config.github_gem "mislav-will_paginate" | |
# is equivalent to this line: | |
# config.gem "mislav-will_paginate", :lib => "will_paginate", :source => "http://gem.github.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddAttachmentsDataToWrapper < ActiveRecord::Migration | |
def self.up | |
add_column :wrappers, :data_file_name, :string | |
add_column :wrappers, :data_content_type, :string | |
add_column :wrappers, :data_file_size, :integer | |
add_column :wrappers, :data_updated_at, :datetime | |
end | |
def self.down | |
remove_column :wrappers, :data_file_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddAttachmentsDataToWrapper < ActiveRecord::Migration | |
def self.up | |
add_column :wrappers, :data_file_name, :string | |
add_column :wrappers, :data_content_type, :string | |
add_column :wrappers, :data_file_size, :integer | |
add_column :wrappers, :data_updated_at, :datetime | |
end | |
def self.down | |
remove_column :wrappers, :data_file_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddAttachmentsDataToWrapper < ActiveRecord::Migration | |
def self.up | |
add_column :wrappers, :data_file_name, :string | |
add_column :wrappers, :data_content_type, :string | |
add_column :wrappers, :data_file_size, :integer | |
add_column :wrappers, :data_updated_at, :datetime | |
end | |
def self.down | |
remove_column :wrappers, :data_file_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/util/cache.rb | |
class Util::Cache | |
def self.increment(key, amount = 1) | |
if (value = Rails.cache.read(key)).nil? | |
Rails.cache.write(key, (value = amount)) | |
else | |
Rails.cache.write(key, (value = value + amount)) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RAILSLOVE.com template | |
# | |
# with help and ideas from: | |
# http://gist.github.com/33337 By Peter Cooper | |
# http://github.com/jeremymcanally/rails-templates/tree/master/suspenders.rb Suspenders by Thoughtbot Nathan Esquenazi | |
if yes?("symlink local rails copy to vendor?") | |
path = ask("what's the directory of your local rails copy?") | |
inside('vendor') { run "ln -s #{path} rails" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# environment variables | |
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:$PATH" | |
export EDITOR='mate -w' | |
# aliases | |
alias l="ls -la" | |
alias gemi='sudo gem install --no-rdoc --no-ri' | |
alias gemu='sudo gem update --no-rdoc --no-ri' | |
alias ss='ruby script/server' | |
alias sc='ruby script/console' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddAttachmentsDataToWrapper < ActiveRecord::Migration | |
def self.up | |
add_column :wrappers, :data_file_name, :string | |
add_column :wrappers, :data_content_type, :string | |
add_column :wrappers, :data_file_size, :integer | |
add_column :wrappers, :data_updated_at, :datetime | |
end | |
def self.down | |
remove_column :wrappers, :data_file_name |