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
#!/usr/bin/env ruby | |
# Alex's changes: | |
# * erector and erector_mixin | |
# * each template now includes a loop and a variable (this affects HAML quite a lot) | |
# * automated comparison and benchmarking | |
# * make sure variable is truly being interpolated | |
# # of iterations = 10000 | |
# user system total real |
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
# from: http://pivotallabs.com/users/alex/blog/articles/865-monkey-patch-du-jour | |
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractAdapter | |
def log_info(sql, name, ms) | |
if @logger && @logger.debug? | |
@logger.debug("#{sql}, #{name}, #{ms}") | |
c = caller.detect{|line| line !~ /(activerecord|active_support|__DELEGATION__|\/lib\/|\/vendor\/plugins|\/vendor\/gems)/i} | |
c.gsub!("#{File.expand_path(File.dirname(RAILS_ROOT))}/", '') if defined?(RAILS_ROOT) | |
name = '%s (%.1fms) %s' % [name || 'SQL', ms, c] |
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 group of actions and related helper methods dealing with login/logout. | |
# These are loaded from my main Sinatra app via "register Actions::Login". | |
# I put this file in a subdirectory called "actions". | |
module Actions | |
module Login | |
module Helpers | |
def logged_in? | |
if session[:user_id] | |
true |
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 Temperature | |
def ftoc(f) | |
(f-32) * (5.0/9.0) | |
end | |
def ctof(c) | |
c * (9.0/5.0) + 32 | |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Scaling preso</title> | |
<style> | |
html { | |
font-size: 7.68px | |
} |
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
# encoding: utf-8 | |
module Kernel | |
alias :λ :lambda | |
end | |
class Hash | |
alias :+ :merge | |
alias :<< :merge! | |
end |