[~]$ mkdir temp && cd temp
[temp]$ rvm use 1.9.3@temp --create
Using /Users/dwhalen/.rvm/gems/ruby-1.9.3-p327 with gemset temp
[temp]$ gem list
*** LOCAL GEMS ***
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
# Assign an unsolved sudoku to the string my_puzz. Blanks must be represented by 0's. | |
my_puzz = '046000000050001000203590040000000900700000300000804710020068100500000072000902000' | |
# cURL the sudokuwiki.org solver with the given sudoku | |
system 'curl -o solved.txt --url http://www.sudokuwiki.org/S/WebSudoku.dll?solutions\&0,' + my_puzz + ' >/dev/null 2>&1' | |
# The solved puzzle is pulled from the 6th line of the returned file. | |
puts File.open("solved.txt").readlines[6] |
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
<%= f.buttons :class => 'medium-green-button' do %> | |
<%= f.commit_button "Save", :button_html => {:class => 'medium-green-button'} %> | |
<% 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 destutter list | |
if list.length < 2 | |
list | |
else | |
a = list.shift | |
a == list[0] ? | |
destutter(list) : | |
destutter(list).unshift(a) | |
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
# A possible implementation of | |
# Scheme's cons, car, and cdr in Ruby | |
def cons x, y | |
lambda do |pick| | |
case pick | |
when 1; x | |
when 2; y | |
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 "uri" | |
require "json" | |
class Story | |
@@stories = [] | |
@@endpoint = URI.parse("http://api.ihackernews.com/page") | |
@@fetched_at = nil | |
attr_accessor :title, :url, :id, :commentCount, :points, :postedAgo, :postedBy |
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
Stripe.createToken({ | |
number: $('.card-number').val(), | |
cvc: $('.card-cvc').val(), | |
exp_month: $('.card-expiry-month').val(), | |
exp_year: $('.card-expiry-year').val() | |
}, responseHandler); |
This document is a basic comparison of the performance of the stripe_event
gem given different Rails Controller setups. StripeEvent::WebhookController
only needs the head
method provided by the ActionController::Head
module. This means the controller can inherit from ActionController::Metal
rather than ActionController::Base
if ActionController::Head
is included. I'd like to have some data to support this decision.
Performance will be measured with the Apache HTTP server benchmarking tool using the unix utility ab
. The ab
that ships with OS X Lion seems to be broken, so I installed the version with Homebrew: brew install ab
.
The benchmarks will be run on a MacBook Air with the following specs:
- OS X Lion 10.7.5 (11G63b)
- 1.7 GHz Intel Core i5
class Card
@ranks = ['2','3','4','5','6','7','8','9','10','J','Q','K','A']
@suits = ['C', 'D', 'H', 'S']
constructor: (@rank, @suit) ->
toString: -> "#{@rank}#{@suit}"
$ rails _3.2.12_ new test_app --skip-bundle --quiet && cd test_app
$ curl -o Gemfile https://gist.github.com/marcamillion/b34999069f88190017d3/raw/d2dea64f72ac1b09a11b70295e970aeaea5e8f74/Gemfile.rb
$ bundle --quiet
$ ruby -r./config/environment.rb -e "puts method(:singleton_class).source_location"
/Users/dwhalen/.rvm/gems/ruby-1.9.3-p392/gems/serel-1.1.1/lib/serel/exts.rb
17
$ cat >> Gemfile
gem 'sextant', :group => :development
OlderNewer