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
- if user_signed_in? | |
Welcome, #{link_to current_user.first_name, user_path(current_user)} | |
= link_to "Sign out", logout_path | |
- else | |
= form_for :user, :url => login_path do |f| | |
= f.label :email | |
= f.text_field :email | |
%br | |
= f.label :password | |
= f.password_field :password |
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
$ ruby -e 'exit' | |
$ echo $? | |
0 | |
$ ruby -e 'exit 1' | |
$ echo $? | |
1 | |
$ ruby -e 'abort "oh no"' | |
oh no | |
$ echo $? | |
1 |
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
ftw = { | |
:a => 42, | |
:b => 43 | |
} |
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
Rails::Initializer.run do |config| | |
# Require the latest version of haml | |
config.gem "haml" | |
# Require a specific version of chronic | |
config.gem "chronic", :version => '0.2.3' | |
# Require a gem from a non-standard repo | |
config.gem "hpricot", :source => "http://code.whytheluckystiff.net" |
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
# Not exactly sure what I'm doing here... | |
class RestKlass | |
%W[get post put delete].each { |verb| | |
define_method(verb) { |res| res } | |
} | |
def get; :gotten end | |
end | |
class SQLKlass |
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
A simple, test-driven, object-oriented approach to converting Celsius to | |
Fahrenheit and vice-versa, hopefully it's simple enough to be useful for a | |
newcomer to programming. |
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
# COMMUNITY CHALLENGE | |
# | |
# How would you test this Quiz#problem method? Only two rules: | |
# | |
# 1. The tests should fail if any part of the application breaks. | |
# For example: If "gets" is moved before "puts" then the tests should | |
# fail since that breaks the application. | |
# | |
# 2. You cannot change the Quiz class. But you can use whatever framework | |
# and tools you want for the tests. (RSpec, Cucumber, etc.) |
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
# likewise require | |
# by Pat Nakajima | |
# because I've been drinking more than Jack Barnette | |
# and | |
# to annoy John Susser and Aaron Peterson | |
# | |
# use to require files relative to the current file: | |
# | |
# likewise do | |
# require "foo" # require current-dir/lib |
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
Go through each of the commits here and see the process | |
of writing an object-oriented beginner Ruby program. | |
Good luck! | |
Pat |
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
# Currently it looks like this: | |
class Twitter | |
include Typhoeus | |
remote_defaults :on_success => lambda {|response| JSON.parse(response.body)}, | |
:on_failure => lambda {|response| puts "error code: #{response.code}"}, | |
:base_uri => "http://search.twitter.com" | |
define_remote_method :search, :path => '/search.json' | |
define_remote_method :trends, :path => '/trends/:time_frame.json' | |
end |
NewerOlder