http://guides.rubyonrails.org/migrations.html
- add_column
- add_index
- change_column
- change_table
- create_table
- drop_table
http://guides.rubyonrails.org/migrations.html
DiUS is starting a bowling club. To help with the club, we have engaged you to program a scoring system.
The features on the system are:
E.g, if a bowler rolls, 4,4
| module Paperclip | |
| #converts a string into a file for paperclip to save | |
| # useage | |
| # self.avatar = Paperclip::string_to_file('bob.png', 'image/png', 'BASE64 here') | |
| def self.string_to_file(name, type, data) | |
| image = StringIO.new(data) | |
| image.class.class_eval { attr_accessor :original_filename, :content_type } | |
| image.original_filename = name | |
| image.content_type = type |
| # In Ruby everything is an object, including classes. | |
| # That means class methods are instance methods of some object. | |
| # But what object? | |
| class Object | |
| def eigenclass | |
| class << self | |
| self | |
| end | |
| end |
This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)
Sister Document - Restore MySQL from Amazon S3 - read that next
this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc
As configured in my dotfiles.
start new:
tmux
start new with session name:
| # This script is greatly inspired by Pry Everywhere by Luca Pette | |
| # http://lucapette.com/pry/pry-everywhere/ | |
| # Use TextMate as default editor | |
| Pry.config.editor = "mate -w" | |
| # My pry is polite | |
| Pry.hooks = { | |
| :after_session => proc { | |
| puts "\nGoodbye." if Pry.active_sessions == 1 |
| # | |
| # Wide-open CORS config for nginx | |
| # | |
| location / { | |
| if ($request_method = 'OPTIONS') { | |
| add_header 'Access-Control-Allow-Origin' '*'; | |
| # |
| def tip(msg); puts; puts msg; puts "-"*100; end | |
| # | |
| # 30 Ruby 1.9 Tips, Tricks & Features: | |
| # http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
| # | |
| tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
| tip "Ruby 1.9 supports named captures in regular expressions!" |