Skip to content

Instantly share code, notes, and snippets.

View aeden's full-sized avatar

Anthony Eden aeden

View GitHub Profile
@aeden
aeden / test.rb
Created July 7, 2011 08:53
Temporarily Overriding A Method in Ruby
module Count
def fake_count
words.count + 500
end
end
class Thing
def words
%w(one two three)
end

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

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

Installed RVM HEAD version:
rvm 1.6.18 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
/Users/aeden/.rvm/scripts/get: line 125: syntax error near unexpected token `)'
/Users/aeden/.rvm/scripts/get: line 125: `rvm ; rvm --version )'
~ [ruby-1.9.2-p0]$ rvm list
/Users/aeden/.rvm/scripts/list: line 5: /base: No such file or directory
/Users/aeden/.rvm/scripts/list: line 262: __rvm_environment_identifier: command not found
~/d/aetrion/dnsimple [branch:master] [rbx-head]$ rspec spec
WARNING: using the built-in Timeout class which is known to have issues when used for opening connections. Install the SystemTimer gem if you want to make sure the Redis client will not hang.
An exception occurred at_exit handler
/Users/aeden/Development/aetrion/dnsimple/app/lib/logic/domain/transferable.rb:24: syntax error, unexpected ')' (SyntaxError)
Backtrace:
Rubinius::Melbourne#syntax_error at /Users/aeden/.rvm/rubies/rbx-head/lib
/melbourne.rbc:70
Rubinius::Melbourne#parse_file at /Users/aeden/.rvm/rubies/rbx-head/lib
/melbourne.rbc:83
@aeden
aeden / contact.rb
Created May 7, 2011 16:54
Extraction Blog Post
class Contact < ActiveRecord::Base
belongs_to :user
def name
"#{first_name} #{last_name}"
end
end
# Another approach to turning echo on/off in IRB.
# Place in .irbrc
def q!
p "Quiet mode #{conf.echo ? "on" : "off"}"
conf.echo = !conf.echo
end
# This is madness...or is it genius?!
#
# Use separate modules for separating private and protected methods from the
# public interface.
#
# Don't forget to run rdoc on this source.
class Person
module Protected #:nodoc:
protected
~ [ruby-1.8.7-p249]$ irb
ruby-1.8.7-p249 > Time.parse
NoMethodError: undefined method `parse' for Time:Class
from (irb):1
ruby-1.8.7-p249 >
@aeden
aeden / resolv_naptr.rb
Created January 17, 2011 17:03
Implementation of NAPTR read and write.
class Resolv
class DNS
class Resource
module IN
class NAPTR < Resource
TypeValue = 35 # :nodoc:
ClassValue = IN::ClassValue
ClassHash[[TypeValue, ClassValue]] = self
def initialize(order, preference, flag, service_name, regex, replacement)