This file contains hidden or 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
| def v1(value) | |
| value || "-" | |
| end | |
| def v2(object, method) | |
| object && value = object.send(method) ? value : "-" | |
| end |
This file contains hidden or 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
| # assuming the following columns in `things` | |
| # | |
| # children_counter_cache :integer | |
| # parent_id :integer | |
| # | |
| class Thing < ActiveRecord::Base | |
| has_many :children, :class_name => "Thing", :foreign_key => "parent_id", :dependent => :nullify | |
| belongs_to :parent, :class_name => "Thing", :foreign_key => "parent_id", :counter_cache => 'children_counter_cache' | |
| end |
This file contains hidden or 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
| namespace :db do | |
| desc "Generates ownership queries" | |
| task :chown => :environment do | |
| ActiveRecord::Base.connection.tables.sort.each do |t| | |
| puts "ALTER TABLE #{t} OWNER TO radius;" | |
| end | |
| end | |
| desc "Migrate database from MySQL to PostgreSQL" |
This file contains hidden or 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
| # named_scope :between, lambda {|start_date, end_date, field| | |
| # { :conditions => ["\"#{field}\" >= ? AND \"#{field}\" <= ?", start_date, end_date] } | |
| # } | |
| From the docs... | |
| A range may be used in the hash to use the SQL BETWEEN operator | |
| Student.find(:all, :conditions => { :grade => 9..12 }) |
This file contains hidden or 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
| // the DOM is wacky | |
| targetTabHeight: function() { | |
| this.targetTab().style.visibility = "hidden"; | |
| this.targetTab().style.display = "block"; | |
| _height = this.targetTab().offsetHeight; | |
| this.targetTab().style.display = "none"; | |
| this.targetTab().style.visibility = "visible"; | |
| return _height; |
This file contains hidden or 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 Report | |
| # ENGINEERING MACHINATIONS | |
| machine(:status, :field_name => "status") do | |
| # we are waiting for someone to upload a file | |
| state :file_pending do | |
| event :upload_file, :to => :file_uploaded | |
| end | |
| # we've got a file, but it's not approved by a hu-man |
This file contains hidden or 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
| [Parabox] dan:~$ cat ~/.gemrc | |
| --- | |
| :verbose: true | |
| gem: --no-ri --no-rdoc | |
| :benchmark: false | |
| :sources: | |
| - http://gems.github.com | |
| - http://gems.rubyforge.org | |
| :update_sources: true | |
| :backtrace: false |
This file contains hidden or 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 ruby | |
| require 'rubygems' | |
| require 'zip/zip' | |
| require 'zip/zipfilesystem' | |
| require 'digest/md5' | |
| Dir.glob("/Users/dan/Desktop/SAMPLE_DATA/**/*.zip").each do |f| | |
| begin | |
| puts "hash: " + Digest::MD5.hexdigest(Zip::ZipFile.open(f).read("fx.txt")) |
This file contains hidden or 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
| What did you do to get good at Rails? | |
| Who taught you what you know? | |
| Do you have any fond (or not so fond) memories of your learning experiences? | |
| What was your first production app and what did you learn from it? | |
| What tools do you use to make your life easier? | |
| What did you find particularly hard to grok when learning Rails? | |
| When did you start on Rails? | |
| Did you learn Ruby first or try to jump straight into Rails? | |
| Did you read any books to get good at Rails? | |
| What system do you use? |
This file contains hidden or 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
| =rounded_corners(!radius) | |
| :border-radius = !radius | |
| :-moz-border-radius = !radius | |
| :-webkit-border-radius = !radius |