Skip to content

Instantly share code, notes, and snippets.

View toch's full-sized avatar

Christophe Philemotte toch

View GitHub Profile
toch / ensure_teardown.rb
Created July 12, 2016 14:40
Test how we can release resources or processes when an exception is raised during test
require "minitest/autorun"
def raise_an_exception
raise "Raised!"
module Minitest
module Ensure
def ensure_to_call_after(name)
old_test_method = instance_method("test_#{name}")
toch / pg_jsonb.rb
Created May 26, 2016 16:06
A Hanami Coercer for PG JSONB Datatype
require "hanami/model/coercer"
require "sequel"
require "sequel/extensions/pg_json"
class PGJsonB < Hanami::Model::Coercer
def self.dump(hash_map)
def self.load(jsonb)
toch /
Created April 26, 2016 15:42
a Bash script to generate docset for Zeal from a group of gems
# rubygem is required
# yard is required: gem install yard
# doc_to_dash is required: gem install doc_to_dash
TMP_DIR=$(mktemp -d)
toch / Rakefile
Created January 19, 2016 19:52
mruby minimum Rakefile
# avoid redefining constants in mruby Rakefile
mruby_root=File.expand_path(ENV["MRUBY_ROOT"] || "#{APP_ROOT}/mruby")
mruby_config=File.expand_path(ENV["MRUBY_CONFIG"] || "build_config.rb")
ENV['MRUBY_ROOT'] = mruby_root
ENV['MRUBY_CONFIG'] = mruby_config
Rake::Task[:mruby].invoke unless Dir.exist?(mruby_root)
load "#{mruby_root}/Rakefile"
toch / define_method_vs_module_eval.rb
Last active December 12, 2015 07:14
Example of usage of benchmark-lab on JuanitoFatas/fast-ruby
require 'benchmark/lab'
def method_names(number) do
10.times.inject("") { |e| e << ('a'..'z').to_a.sample}
class DefineMethod
def self.def_methods(_methods)
toch /
Last active November 25, 2015 22:19
A message to mruby contributors

Hi all,

It's the second year that me and Tyler are organizing the Ruby devroom at fosdem 2016. It focuses on Ruby internals and implementations. It's more about how Ruby is implemented than how it can be used. Last year we had great devs for MRI, Jruby, Rubinius, or Rubymotion. It would be wonderful to have a talk about mruby.

The CFP is open and ends on the 1st December.

Thanks for sharing it with other mruby contributors.