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
# They are different! | |
class A | |
def self.me=(value) | |
@me = value | |
end | |
def self.me | |
@me | |
end | |
def double_me=(value) |
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
h = Hash.new([]) | |
h[:a] << 1 | |
h[:a] << 2 | |
h | |
#=> {} # WTF | |
h.keys | |
#=> [] # WTF |
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
h = Hash.new([]) | |
h[:a] << 1 | |
h[:a] << 2 | |
h | |
#=> {} # WTF | |
h.keys | |
#=> [] # WTF |
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
Here are the steps I took to time the slowdown I'm seeing using bundler. I timed "rake spec" because it was easier to time but the slowness is more pronounced when I just run "rake". | |
1. Create a simple app with `motion create bundler` | |
2. Add 2 lines to Rakefile | |
require 'bubble-wrap' | |
require 'motion-cocoapods' | |
3. Force a compile with `rake spec` | |
4. Time it without bundler about 1.7sec |
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.Alex = Ember.Object.Extend({ | |
dotColor: function() { | |
switch (this.get('customer').get('state') { | |
when 1 | |
'sprite big' | |
when 2 | |
'sprite small' | |
} | |
}.property('customer.state') | |
}) |
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
it "should be able able to overwrite defaults" do | |
subject.log = "/test" | |
subject.log.should eql('/test') | |
end | |
describe 'overriding log' do | |
before { subject.log = '/test' } | |
its(:log) { should == '/test' } | |
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
def parse file_name | |
lines = File.readlines(file_name) | |
# puts "#{file_name} has #{lines.size} lines" | |
lines[4] =~ /.*: (\d+)/ | |
data_id = $1.to_i | |
monthly_data(data_id, lines) | |
rescue => e | |
puts "Error with file #{file_name}: #{e}" | |
[data_id] | |
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
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
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 AddHomeTeamIdAndAwayTeamId < ActiveRecord::Migration | |
def self.up | |
add_column :games, :home_team_id, :integer | |
add_column :games, :away_team_id, :integer | |
Game.all.each do |game| | |
home_team = Team.find_or_create_by_name(game.home_team) | |
away_team = Team.find_or_create_by_name(game.away_team) | |
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
# db/seeds.rb | |
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) | |
# Major.create(:name => 'Daley', :city => cities.first) |