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 | |
orig = Security.create!(symbol:'NFLX', name:'Overvalued Content Provider') | |
puts Security.all | |
puts orig.symbol | |
s = Security.find_by_symbol(orig.symbol) | |
puts s.nil? ? "not found" : "found" | |
s = Security.find(orig.id) |
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
<h2>New Portfolio</h2> | |
<%= form_for @portfolio do |f| %> | |
<%= render 'shared/error_messages', :object => @portfolio %> | |
<div class="field" style="padding-top: 20px;"> | |
<%= f.label :name %><br /> | |
<%= f.text_field :name %> | |
</div> | |
<div class="field" style="padding-top: 20px;"> | |
<%= f.label :beginning_cash_balance %><br /> |
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 Post | |
delegate :errors, :valid?, :save, :to => @record | |
@@persistance = Class.new(ActiveRecord::Base) do | |
set_table_name 'posts' | |
def self.name | |
'PostRecord' | |
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
# This is the code from my 'There is No Such Thing as Metaprogramming' talk, | |
# which premiered at the Arlington, VA Ruby Users Group on Feb 22nd. | |
# Without the deliver and walk-through to the solution below this example | |
# will be missing quite an important bit of content (mainly the tracking of | |
# 'self' while developing the solution, but it still a useful read. | |
# Here is the Toddler with no metajuju. Note that the developer, as well as | |
# the code, is completely unuaware of the interpreter. A developer with a | |
# background in compiled languages would be comfortable looking at this. |
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
#dependencies | |
require "csv" | |
def import | |
filename = "pricing_sample.csv" | |
@file = CSV.open(filename, {:headers => true, :header_converters => :symbol}) | |
end | |
def discrepancies | |
underscans = 0 |
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
# Configs | |
config defaultToCurrentScreen true | |
config checkDefaultsOnLoad true | |
config keyboardLayout colemak | |
config windowHintsShowIcons true | |
config windowHintsIgnoreHiddenWindows true | |
config windowHintsSpread true | |
# Monitor Aliases |
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
// To start scrolling, type this in the javascript console | |
var theTimeout=setInterval(function(){window.scrollTo(0, document.body.scrollHeight);},500); | |
// To stop scrolling, type this in the javascript console | |
clearInterval(theTimeout); |
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
{:mutable => false}.tap {|h| h[:mutable] = true} | |
# => {:mutable=>true} | |
"Can I mutate?".tap {|str| str = "No!"} | |
# => "Can I mutate?" |
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 NilClass | |
def [](index) end | |
end | |
class Array | |
def [](index) | |
(index < 0) ? nil : at(index) | |
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
[5:08pm] allie_p: is an instance variable and an instance method the same thing? | |
[5:09pm] saturnflyer: no | |
[5:09pm] saturnflyer: an instance variable is some internal value | |
[5:09pm] saturnflyer: an instance method is some function that object can perform | |
[5:10pm] allie_p: ok, so they're related but different | |
[5:10pm] saturnflyer: typically, you might keep the names the same to set and retrieve the instance variable values | |
[5:10pm] saturnflyer: attr_accessor creates 2 methods that set and retrieve the instance variable | |
[5:10pm] saturnflyer: but you could have a method called full_name, that returns something other than @full_name | |
[5:11pm] saturnflyer: it could be @__full_person_name, or whatever you want | |
[5:15pm] allie_p: thanks! |
OlderNewer