Skip to content

Instantly share code, notes, and snippets.

View nakajima's full-sized avatar
💭
you can have statuses now?

Pat Nakajima nakajima

💭
you can have statuses now?
View GitHub Profile
@nakajima
nakajima / not working
Created May 23, 2011 21:12
bizarre syntax error in staging but not in develompent
- 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
$ ruby -e 'exit'
$ echo $?
0
$ ruby -e 'exit 1'
$ echo $?
1
$ ruby -e 'abort "oh no"'
oh no
$ echo $?
1
ftw = {
:a => 42,
:b => 43
}
@nakajima
nakajima / A.rb
Created June 19, 2009 08:34 — forked from bmizerany/A.rb
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"
# 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
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.
@nakajima
nakajima / quiz.rb
Created May 15, 2009 20:23 — forked from ryanb/quiz.rb
could be better, could be worser
# 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.)
@nakajima
nakajima / likewise.rb
Created May 14, 2009 09:41 — forked from jbarnette/adjacent.rb
Ruby's fun, right?
# 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
Go through each of the commits here and see the process
of writing an object-oriented beginner Ruby program.
Good luck!
Pat
@nakajima
nakajima / gist:108480
Created May 7, 2009 23:50 — forked from pauldix/gist:108444
aesthetics
# 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