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
ack-grep | |
# drivers and kernel | |
build-essential | |
linux-headers-`uname -r` |
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
rvm --create ruby-1.9.2-p290@my_gemset_name | |
if ! command -v bundle ; then | |
gem install bundler | |
# Optional: | |
#bundle install | |
fi |
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
# This will set your Page Title to a sane default | |
# | |
# Usage: | |
# Put this in your ApplicationHelper. | |
# Call `title` in your view or layout to display a default title. | |
# You can set `@title` in your controller action to change the default title. | |
def title | |
if @title then | |
@title |
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
# in your migration | |
t.integer :price_in_cents | |
# in your view to display your price | |
= number_to_currency object.price | |
# in your model | |
def price | |
price_in_cents.to_f / 100 | |
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
# Give precedence to user/local/bin because that's where Homebrew installs their stuff | |
export PATH=/usr/local/bin:$PATH |
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
# In your Model | |
def self.search(search) | |
search_condition = "%" + search + "%" | |
self.where 'title LIKE ? OR description LIKE ?', search_condition, search_condition | |
end | |
# reference https://we.riseup.net/rails/simple-search-tutorial |
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/env/bash | |
# run this like: `curl https://gist.github.com/acook/1444793/raw/ruby_dev_machine_setup.sh | bash` | |
echo "Enter password to install packages..." | |
sudo apt-get update | |
sudo apt-get install -y build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libtool ack-grep vim-nox ctags | |
\curl -#L https://get.rvm.io | bash -s stable --ruby | |
source ~/.bashrc |
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 Which | |
def which symbol | |
klass = self.is_a?(Class) ? self : self.class | |
reciever = klass.ancestors.select do |dad| | |
dad.instance_methods.include?(symbol) || dad.methods.include?(symbol) | |
end.last | |
end | |
end | |
Object.send :extend, Which |
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 | |
def deletify! &block | |
self.each do |element| | |
return self.delete(element) if yield(element) | |
end | |
nil | |
end | |
end |