Skip to content

Instantly share code, notes, and snippets.

View parameme's full-sized avatar

Lachlan Pitts parameme

  • Bentley Systems
  • Brisbane, Australia
  • 23:37 (UTC +10:00)
View GitHub Profile
@parameme
parameme / serializable_sha1_using_ffi.rb
Created April 2, 2012 04:22
Quick and dirty way to serialize and restore ruby Digest::SHA1 using FFI
require 'ffi'
require 'digest'
# Thanks to all ruby hackers everywhere who have donated their knowledge to the commons!
# With thanks to @judofyr for ffi/"evil.rb" - https://gist.github.com/2238438
class Object
def memory_location
object_id * 2
end
@judofyr
judofyr / evil.rb
Created March 29, 2012 15:21
Experimenting with MRI internals in FFI
require 'ffi'
class Object
def memory_location
object_id * 2
end
def to_pointer
FFI::Pointer.new(memory_location)
end
@masaki
masaki / rubygems-1.8.5-no_proxy.patch
Created July 20, 2011 12:15
RubyGems NO_PROXY auto-detection without http_configuration gem
--- rubygems-1.8.5/lib/rubygems/remote_fetcher.rb.orig 2011-07-20 00:28:13.000000000 +0900
+++ rubygems-1.8.5/lib/rubygems/remote_fetcher.rb 2011-07-20 01:09:59.000000000 +0900
@@ -69,6 +69,7 @@
when URI::HTTP then proxy
else URI.parse(proxy)
end
+ @no_proxy = (ENV['NO_PROXY'] || ENV['no_proxy'] || 'localhost, 127.0.0.1').split(/\s*,\s*/)
@user_agent = user_agent
end
@dkln
dkln / ar_to_hash.rb
Created March 11, 2011 10:45
Convert any Activerecord to a hash with all it's related objects
class Serializer < Struct.new(:object)
def to_hash
@hash ||= hash_object(object)
end
private
def hash_object(object)
hash = {}