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
skip_filter *_process_action_callbacks.map(&:filter), :only => [:action_goes_here] |
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
sudo mkdir /usr/local | |
sudo chown -R $USER /usr/local | |
curl -Lsf \ | |
http://github.com/mxcl/homebrew/tarball/master | \ | |
tar xvz -C /usr/local --strip 1 | |
mkdir -p ~/.rvm/src && cd ~/.rvm/src && rm -rf ./rvm && \ | |
git clone --depth 1 git://github.com/wayneeseguin/rvm.git && \ | |
cd rvm && ./install |
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
#import | |
gunzip < backupfile.sql.gz | mysql -uroot -ppassw database | |
#dump | |
mysqldump -h -u -p database | gzip > backupfile.sql.gz | |
#dump without schema(data only) | |
mysqldump --no-create-info --skip-triggers -h -u -p database | gzip > backupfile.sql.gz | |
#dump with columns |
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
function be () { | |
bundle exec $@ | |
} | |
function ber () { | |
bundle exec rake $@ | |
} | |
function bes () { | |
bundle exec rake spec $@ | |
} | |
function bess () { |
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
#!/bin/sh | |
_ver='2.1.6' | |
if [ -z "$V" ]; then | |
_ver='2.1.6' | |
else | |
_ver=$V | |
fi | |
ruby-install --rubies-dir /usr/local/rubies ruby $_ver |
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
# Function to print strftime results | |
def print_strftime_formats(a,cur_date) | |
a.each do |format| | |
b = "%#{format}" | |
output = cur_date.strftime(b) | |
puts "t.strftime('#{b}'), => #{output}" | |
end | |
end | |
a = ('a'..'z').to_a |
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
find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} | |
find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} |
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
sql = File.read(sql_file) | |
statements = sql.split(/;$/) | |
statements.pop if statements.last.blank? | |
ActiveRecord::Base.transaction do | |
statements.uniq.each { |statement| execute(statement.gsub(/\n/, '')) } | |
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
module ActiveRecord | |
class Base | |
def self.cache_key | |
Digest::MD5.hexdigest "#{scoped.maximum(:updated_at).try(:to_i)}-#{scoped.count}" | |
end | |
end | |
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
module ActiveRecord::Persistence::ClassMethods | |
def create!(attributes = nil, &block) | |
if attributes.is_a?(Array) | |
attributes.collect { |attr| create!(attr, &block) } | |
else | |
object = new(attributes, &block) | |
[:save,:create].each { |cb| object.class.reset_callbacks cb } | |
object.save(validate: false) | |
object |