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 'rbconfig' | |
require 'find' | |
require 'ftools' | |
include Config | |
# this was adapted from rdoc's install.rb by ways of Log4r | |
$sitedir = CONFIG["sitelibdir"] | |
unless $sitedir |
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
# Returns just the numbers from the phase attribute | |
def display_phase | |
case phase | |
when /(\d).*(\d)/ | |
$1 + ' / ' + $2 | |
when /(\d)/ | |
$1 | |
when nil | |
'' | |
else |
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 File.dirname(__FILE__) + '/../test_helper' | |
class ApplicationLevelTest < ActionController::TestCase | |
# This class holds tests for application-level components: layouts, application_controller elements, etc | |
class GoogleAnalyticsController < ApplicationController | |
def any_action | |
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
def authenticate | |
return true if Rails.env.test? | |
success = authenticate_or_request_with_http_digest do |user| | |
ADMIN_CREDENTIALS[user] | |
end | |
# We have to explicitly check if success is true here because | |
# auth_or_req_w_http_digest returns a string on authorization | |
# failure (?!) | |
session[:admin] ||= success | |
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
# Show SQL in console | |
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
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
[user] | |
name = Ben Orenstein | |
email = [email protected] | |
[alias] | |
co = checkout | |
[color] | |
diff = auto | |
status = auto |
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
NoMethodError in DecksController#update | |
undefined method `original_filename' for "07 Sweet Pea.m4a":String | |
RAILS_ROOT: /home/rob/code/flashcards | |
Application Trace | Framework Trace | Full Trace | |
app/models/card_sound.rb:5:in `file=' | |
app/models/card.rb:13:in `sound_file=' | |
app/models/deck.rb:10:in `card_attributes=' |
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
ben@town ~/code $ time git clone git://github.com/rails/rails.git | |
(...) | |
real 0m27.800s | |
user 0m21.590s | |
sys 0m2.590s | |
-------------------- |
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 squish(str) | |
str = str.split('') | |
str.inject(str[0]) do |acc, char| | |
acc << char unless acc.split('').last.downcase == char.downcase | |
acc | |
end | |
end | |
puts squish("AQAaaBbbbbccCcc") | |
puts squish("ZzzzzXxxxyYY") |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'open-uri' | |
FILE_NAME = '/home/beno/projects/training_checker/seats_left.txt' | |
previous_seats_left = File.open(FILE_NAME).read | |
doc = open('https://training.thoughtbot.com/courses/12-vim-for-rubyists/registrations/new').read |