Skip to content

Instantly share code, notes, and snippets.

View aeden's full-sized avatar

Anthony Eden aeden

View GitHub Profile
@aeden
aeden / gem-index-with-dns.md
Created January 16, 2011 13:31
Using DNS for Rubygems index

Currently the RubyGems index is stored as a Gzip file that is a marshalled array. Whenever Bundler needs to install a gem that is not yet installed it downloads the index, gunzips it and unmarshals it. It then looks for dependencies that are described in another file that is also a gzipped and marshalled file. There are several issues that arise from this setup:

  • The full index must be downloaded and parsed, but does not contain dependency data, which must then be downloaded and parsed. This is a relatively time consuming process.
  • The index must be centralized.

Additionally the gems themselves are currently centralized since there is nothing in the meta data that indicates where the gem should be downloaded from. However in order to allow this it is important to find ways of keeping the index from being poisoned (is this an issue in the centralized system?)

Dependency Resolution

@aeden
aeden / retryable_test.rb
Created December 21, 2010 15:30
Example of using Retryable
require 'retryable'
class Test
def self.run
Retryable.retry_on(RuntimeError, 2, Proc.new { fix }) do
puts "trying something broken"
raise RuntimeError
end
end
def self.fix
@aeden
aeden / retryable.rb
Created December 21, 2010 15:30
A simple class for retrying a block on an exception.
class Retryable
def self.retry_on(exception, times=2, handler=nil)
retry_times = times || 2
begin
yield
rescue exception => e
handler.call if handler
retry if (retry_times -= 1) > 0
end
end
@aeden
aeden / gist:732981
Created December 8, 2010 06:45
Why are you doing this to me, Cucumber, why?
loading autotest/cucumber
/Users/aeden/.rvm/gems/ruby-1.9.2-p0@dnsimple/gems/cucumber-0.10.0/lib/cucumber/ast/feature.rb:15: warning: method redefined; discarding old gherkin_statement
/Users/aeden/.rvm/gems/ruby-1.9.2-p0@dnsimple/gems/cucumber-0.10.0/lib/cucumber/ast/feature_element.rb:10: warning: method redefined; discarding old gherkin_statement
/Users/aeden/.rvm/gems/ruby-1.9.2-p0@dnsimple/gems/cucumber-0.10.0/lib/cucumber/ast/table.rb:384: warning: shadowing outer local variable - hash
/Users/aeden/.rvm/gems/ruby-1.9.2-p0@dnsimple/gems/cucumber-0.10.0/lib/cucumber/ast/step.rb:18: warning: method redefined; discarding old gherkin_statement
/Users/aeden/.rvm/gems/ruby-1.9.2-p0@dnsimple/gems/cucumber-0.10.0/lib/cucumber/ast/examples.rb:11: warning: method redefined; discarding old gherkin_statement
<internal:lib/rubygems/custom_require>:29: warning: loading in progress, circular require considered harmful - /Users/aeden/.rvm/gems/ruby-1.9.2-p0@dnsimple/gems/cucumber-0.10.0/lib/cucumber.rb
from /Users/aede
jruby
jruby-1.5.6
is
not
installed.
To
install
do:
'rvm
install
/Users/aeden/.rvm/gems/jruby-1.5.5@sifaka/bin/rake: line 9: require: command not found
/Users/aeden/.rvm/gems/jruby-1.5.5@sifaka/bin/rake: line 11: version: command not found
/Users/aeden/.rvm/gems/jruby-1.5.5@sifaka/bin/rake: line 13: syntax error near unexpected token `('
/Users/aeden/.rvm/gems/jruby-1.5.5@sifaka/bin/rake: line 13: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then'
[
{
"user": {
"single_access_token": "5OAxG2t__J5DO_K7W3_7",
"last_request_at": "2010-12-01T16:58:14Z",
"created_at": "2010-12-01T15:52:18Z",
"crypted_password": "",
"updated_at": "2010-12-01T16:58:14Z",
"perishable_token": "3jtBKxNcQ3DBtAN9sqpu",
"id": 1,
User.all({
success: function(users){
$.each(users, function(index, user) {
console.log("all: here I am, user " + user.email + " (id:" + user.id + ")");
});
}
});
User.find(1, {
success: function(user) {
@aeden
aeden / api_steps.rb
Created November 30, 2010 12:47
Steps for testing API endpoints with Cucumber
# Requires nokogiri and jsonpath
# Only works with rack test
World(Rack::Test::Methods)
# Feel free to customize this for whatever API auth scheme you use
Given /^I am a valid API user$/ do
user = Factory(:user)
authorize(user.email, user.password)
end
@api
Feature: List domains
As an API client
In order to do things with domains
I want to retrieve a list of domains
Scenario: retreive all domains as XML
Given I am a valid API user
And I send and accept XML
And I have 1 domain with 5 "A" records