Skip to content

Instantly share code, notes, and snippets.

View phillipoertel's full-sized avatar

Phillip Oertel phillipoertel

View GitHub Profile
module ActiveSupport
module Cache
class MemoryStoreWithExpiry < MemoryStore
def initialize
super
@times = {}
end
def write(name, value, options = nil)
@phillipoertel
phillipoertel / gist:194964
Created September 27, 2009 19:45
A bunch of files to migrate translation data from Globalize 1 (yuck) to use it with Globalize 2 (looks promising, much cleaner and simpler)
#
# A bunch of files to migrate translation data from Globalize 1 (yuck)
# to use it with Globalize 2 (looks promising, much cleaner and simpler)
#
# I'll generalize, convert this into a plugin and document this
# if there's enough interest.
#
========== lib/tasks/globalize_migrator.rake
require File.join(File.dirname(__FILE__), '../../config/environment')
Scenario: Full text search
Given there are 10 projects for API client "Payback"
When I call the API "project search" with data:
| search-term | page | per-page |
| afrika | 2 | 2 |
Then I should get status "200 OK"
And I should see a XML list of 2 projects
#
# a smoke test to check basic programming skills
#
# Task:
# - print out the numbers 1 to 100
# - output "foo" for every number divisible by 3
# - output "bar" for every number divisible by 5
# - output "foobar" for every number divisible by 3 and 5
#
@phillipoertel
phillipoertel / funkyness.rb
Created October 31, 2009 00:52
just to clarify.
funkyness = lambda { |number| puts "FUNKY! " * number }
(1..10).each(&funkyness)
FUNKY!
FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY! FUNKY! FUNKY! FUNKY!
funkyness = ->(number){ puts "FUNKY! " * number }
(1..10).each(&funkyness)
FUNKY!
FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY! FUNKY! FUNKY!
FUNKY! FUNKY! FUNKY! FUNKY! FUNKY! FUNKY! FUNKY!
10:20 Intro
10:30 Patterns in Architecture Joseph Yoder Stanford Architecture http://qconsf.com/sf2009/presentation/Patterns+in+Architecture
11:45 Kanban vs Scrum - a practical guide Henrik Kniberg Metro Ballroom Lean/Kanban http://qconsf.com/sf2009/presentation/Kanban+vs+Scrum+-+a+practical+guide
13:45 adventures of an agile architect Dan North Stanford Architecture http://qconsf.com/sf2009/presentation/Adventures+of+an+Agile+Architect
15:00 Roadmap to Continuous Deployment Nathan Dye Stanford Architecture http://qconsf.com/sf2009/presentation/Roadmap+to+Continuous+Deployment
16:30 Rails in the Large ... Neil Ford Cornell Facets of Ruby http://qconsf.com/sf2009/presentation/Rails+in+the+Large%3A+How+Agility+Allows+Us+to+Build+One+of+the+World%27s++Biggest+Rails+Apps
18:00 The State and future of JavaScript Douglas Crockford http://qconsf.com/sf2009/
#
# CONTROLLER
#
# POST /admin/voucher_set
class Admin::VoucherSetController < ...
def create
VoucherSet.create!(params)
end
end
require 'test/unit'
def factorial(max)
(1..max).inject(1) { |sum, current| sum *= current; sum }
end
class FactorialTest < Test::Unit::TestCase
def test_factorial_0_is_1
assert_equal 1, factorial(0)
require 'test/unit'
def f(x); x != 0 && x * f(x - 1) || 1; end
class FactorialTest < Test::Unit::TestCase
def test_factorial_0_is_1
assert_equal 1, f(0)
end