Skip to content

Instantly share code, notes, and snippets.

View floere's full-sized avatar
😁
Open Sourcing

Florian R. Hanke floere

😁
Open Sourcing
View GitHub Profile
@floere
floere / gist:8704885
Created January 30, 2014 08:57
Heroku installing ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
/app/tmp/buildpacks/ruby/lib/language_pack/ruby.rb:760:in `block in purge_bundler_cache': undefined local variable or method `install_language_pack_gems' for #<LanguagePack::Rack:0x000000014692f8> (NameError)
from /app/tmp/buildpacks/ruby/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
from /app/tmp/buildpacks/ruby/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
from /app/tmp/buildpacks/ruby/lib/language_pack/instrument.rb:17:in `block in instrument'
from /usr/local/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
from /app/tmp/buildpacks/ruby/lib/language_pack/instrument.rb:16:in `instrument'
from /app/tmp/buildpacks/ruby/lib/language_pack/base.rb:43:in `instrument'
from /app/tmp/buildpacks/ruby/lib/language_pack/base.rb:39:in `instrument'
from /app/tmp/buildpacks/ruby/lib/language_pack/ruby.rb:756:in `purge_bundler_cache'
from /app/tmp/buildpacks/ruby/lib/language_pack/ruby.rb:722:in `block in load_bundler_cache'
@floere
floere / objects_after_1_reindexing.txt
Created January 30, 2014 09:40
search.cocoapods.org Object Allocations
3534 /Users/hanke/temp/cocoapods/search.cocoapods.org/lib/pods.rb:55:OBJECT
3534 /Users/hanke/temp/cocoapods/search.cocoapods.org/lib/pods.rb:56:STRING
3534 /Users/hanke/temp/cocoapods/search.cocoapods.org/lib/pods.rb:57:HASH
3535 /Users/hanke/temp/cocoapods/search.cocoapods.org/lib/pods.rb:58:STRING
4358 /Users/hanke/.gem/ruby/2.1.0/gems/cocoapods-core-0.29.0/lib/cocoapods-core/specification.rb:280:OBJECT
4500 /Users/hanke/.gem/ruby/2.1.0/gems/cocoapods-core-0.29.0/lib/cocoapods-core/specification.rb:34:HASH
4500 /Users/hanke/.gem/ruby/2.1.0/gems/cocoapods-core-0.29.0/lib/cocoapods-core/specification.rb:35:ARRAY
4500 /Users/hanke/.gem/ruby/2.1.0/gems/cocoapods-core-0.29.0/lib/cocoapods-core/specification.rb:36:HASH
4500 /Users/hanke/.gem/ruby/2.1.0/gems/cocoapods-core-0.29.0/lib/cocoapods-core/specification.rb:38:STRING
5192 /Users/hanke/.gem/ruby/2.1.0/gems/cocoapods-core-0.29.0/lib/cocoapods-core/specification/dsl.rb:443:STRING
@floere
floere / hashmemtest1.rb
Last active August 29, 2015 13:56
Quick hash memory test to understand high memory usage when using hashes in Ruby 1.9.3 and 2.1.0 (regarding newly created strings and old hashes).
# We repeatedly fill a hash.
# We use the same keyspace each time after the first time.
#
# My expectation was that the total memory used would not increase significantly after the first iteration.
#
h = {}
10.times do |i|
100000.times do |i|
h[i.to_s] = [1,2,3]
end
@floere
floere / hashmemtest.sh
Last active August 29, 2015 13:56
Assigning nil values to 1'000'000 string keys: Memory usage comparison between MRI Ruby 1.9.3 and 2.1.0
chruby 1.9.3
ruby hashmemtest1.rb
ruby hashmemtest2.rb
ruby hashmemtest3.rb
chruby 2.1.0
ruby hashmemtest1.rb
ruby hashmemtest2.rb
ruby hashmemtest3.rb

Keybase proof

I hereby claim:

  • I am floere on github.
  • I am hanke (https://keybase.io/hanke) on keybase.
  • I have a public key whose fingerprint is 275C 528B 9AF2 B800 1A03 B7A0 4FA6 A8F9 CF1C 1307

To claim this, I am signing this object:

require 'rubygems'
require 'activesupport'
class Object
# As popularized by Why:
# http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
#
def metaclass
class << self; return self; end
@floere
floere / ministubs.rb
Created January 28, 2010 13:29
ministubs, based on nikos ministubs
require 'rubygems'
require 'minitest/unit'
require 'minitest/spec'
MiniTest::Unit.autorun
# This walks the given stub strings and sets up partial stub responder chains.
#
class StubBuilder
@floere
floere / floppy.rb
Created February 8, 2010 23:18 — forked from pjb3/floppy.rb
class Floppy
def method_missing(method, *args)
super unless args.length > 0 && method.to_s[-1..-1] == "="
if args.first.is_a?(Proc)
(class << self; self; end).class_eval do
define_method(method.to_s[0..-2].to_sym, args.first)
end
else
(class << self; self; end).send(:attr_accessor, method.to_s[0...-1])
class LazyProxy
instance_methods.each do |method|
undef_method(method) if method !~ /^__/
end
def initialize &lazy_proxy_block
@lazy_proxy_block = lazy_proxy_block
end
#; named lambda klass
#; in an environment with counter set to 0
#; define an anonymous lambda which increases the counter by one
#
# (defun klass ()
# (let ((counter 0))
# (lambda () (incf counter))))
;klass = lambda {
; counter = 0