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
require "rubygems" | |
require "builder" | |
class Roster | |
def initialize | |
@members = [] | |
@members_cache = [] | |
@content = nil | |
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
# Pattern: Replace exception with test | |
class PreRefactoringRoster | |
def initialize | |
@members = [] | |
end | |
attr_reader :members | |
def add_user(name) |
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
require 'bundler' | |
Bundler.setup | |
Bundler.require(:default) | |
require_relative '../lib/munin-graph' # This is in ../lib | |
require 'munin_graph_server' | |
run Sinatra::Application |
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
Contributing to Open Source | |
=========================== | |
First Rule: You can find the time | |
- It doesn't take much | |
- Weekends are good | |
- Find what other time you're wasting | |
- Try something that's _not_ your day job | |
Second Rule: What to contribute to? |
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
# Try this (minispec): | |
describe "not logged in" do | |
[:index, :new].each do |method| | |
it "should redirect to login on #{method}" do | |
get method | |
assert_redirect_to login_url | |
end | |
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
require 'net/http' | |
require 'open-uri' | |
require 'hpricot' | |
# A simple get request should not require this much boilerplate. | |
def fetch_data(uri) | |
uri = URI(uri) | |
req = Net::HTTP::Get.new(uri.request_uri) | |
req['Accept'] = "application/xhtml+xml" |
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
require 'net/http' | |
require 'open-uri' | |
require 'hpricot' | |
# A simple get request should not require this much boilerplate. | |
def fetch_data(uri) | |
uri = URI(uri) | |
req = Net::HTTP::Get.new(uri.request_uri) | |
req['Accept'] = "application/xhtml+xml" |
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
- line_item.ordered_values.each do |val| | |
"blah" |
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
$ irb | |
1.9.3p327 :001 > logfile = File.new('some_file.txt', 'w') | |
=> #<File:some_file.txt> | |
1.9.3p327 :002 > logfile.write("my content") | |
=> 10 | |
1.9.3p327 :003 > quit | |
$ cat some_file.txt | |
my content | |
$ irb | |
1.9.3p327 :001 > logfile = File.new('some_file.txt', 'w') |
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
fn main() { | |
// I don't want this to have to be mut. | |
let v = vec![1, 2, 3]; | |
// Not this either. | |
let w = vec![3, 4, 5]; | |
// I want a newly allocated vec that is v + w. | |
let x = vec_concat(&v, &w); | |
println!("{:?}", x); |
OlderNewer