Skip to content

Instantly share code, notes, and snippets.

Avatar

Lachlan Pitts parameme

  • Bentley Systems
  • Brisbane, Australia
View GitHub Profile
@parameme
parameme / serializable_sha1_using_ffi.rb
Created Apr 2, 2012
Quick and dirty way to serialize and restore ruby Digest::SHA1 using FFI
View serializable_sha1_using_ffi.rb
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 Mar 29, 2012
Experimenting with MRI internals in FFI
View evil.rb
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 Jul 20, 2011
RubyGems NO_PROXY auto-detection without http_configuration gem
View rubygems-1.8.5-no_proxy.patch
--- 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 Mar 11, 2011
Convert any Activerecord to a hash with all it's related objects
View ar_to_hash.rb
class Serializer < Struct.new(:object)
def to_hash
@hash ||= hash_object(object)
end
private
def hash_object(object)
hash = {}