Skip to content

Instantly share code, notes, and snippets.

@halostatue
halostatue / jruby-1.9 failure
Created July 15, 2011 12:49
JRuby failure (in 1.9 mode) on text-hyphen test/test_bugs.rb
3335 text-hyphen ‣ jruby -v --1.9 -Ilib test/test_bugs.rb
jruby 1.6.3 (ruby-1.9.2-p136) (2011-07-07 965162f) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [darwin-x86_64-java]
Loaded suite test/test_bugs
Started
.F
Finished in 2.454000 seconds.
1) Failure:
test_rubyforge_9807_28498(TestTextHyphen) [test/test_bugs.rb:14]:
<[5, 11, 17, 19, 21, 25, 28, 31, 34, 37, 40, 44]> expected but was
@halostatue
halostatue / gist:1199060
Created September 6, 2011 21:41
Running an external command with popen4
def run_external_command(command)
puts command
output, error = IO.popen4(command) { |_, _, stdout, stderr|
[ stdout.read, stderr.read ]
}
status = $?
[ status, output, error ]
end
### Keybase proof
I hereby claim:
* I am halostatue on github.
* I am halostatue (https://keybase.io/halostatue) on keybase.
* I have a public key whose fingerprint is 7FA3 4E98 E2C5 B938 BDD1 2689 3E59 7C16 D0EA F204
To claim this, I am signing this object:
@halostatue
halostatue / json_body_matcher.rb
Created October 29, 2014 01:08
expect(response).to be_json_for Object
module ContentTypeMatchers
extend RSpec::Matchers::DSL
matcher :be_content_type do |expected|
match do |actual|
expect(actual.content_type).to eq(expected)
end
failure_message_for_should do |actual|
%Q(expected that response content type "#{actual.header['Content-Type']}" would be "#{expected}")
@halostatue
halostatue / config-initializer-redis.rb
Last active August 29, 2015 14:14
Demonstrate stockpile#2
require 'test_application'
# Turn off the default namespacing
TestApplication.cache(namespace: nil).connect
@halostatue
halostatue / README.md
Created March 15, 2016 12:45
Stopdoc bug in Rdoc

The presence of #:stopdoc: around a class that should be documented is having an outsized impact as shown with this gist, a minimal reproduction of an issue I found during the development of cartage 2.0.

buggy.rb documents Buggy and Buggy::Documented. When buggy-submodule.rb is parsed, Rdoc does not include Buggy in the generated documentation.

This can be worked around by changing buggy-submodule.rb to look like this:

@halostatue
halostatue / mock_concern_class.rb
Last active September 18, 2018 03:11
Concern: Sample
# -*- ruby encoding: utf-8 -*-
module MockConcernClass
def mock_concern_class(mod)
klass = Class.new
klass.__send__(:include, mod)
klass
end
def toggle_private_instance_methods_on(klass)
@halostatue
halostatue / manyjoin.rb
Created April 26, 2016 19:38
A many_to_many issue I’m experiencing with Sequel
require 'sqlite3'
require 'sequel'
require 'ostruct'
require_relative 'schema'
require_relative 'models'
require 'byebug'
$cat = OpenStruct.new
@halostatue
halostatue / manyjoin.rb
Created April 26, 2016 20:05
A small issue with many_to_one in nested models
require 'sqlite3'
require 'sequel'
require 'ostruct'
require_relative 'schema'
require_relative 'models'
require 'byebug'
$prime = Catalog.create(name: 'prime')
@halostatue
halostatue / service-checklist.md
Created September 20, 2016 18:19 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?