Record responses and play them from local cache.
Installation:
git clone https://gist.github.com/4368cae5de3f7384fd08.git recordplayer
mkdir ~/.recordplayer
Usage:
# encoding: utf-8 | |
# https://gist.github.com/kml/ce164e1e0c1bde2ab96d | |
require "mongoid" | |
module Mongoid | |
module Extensions | |
module DefaultScopeOnlyId | |
def self.included(base) |
require "active_attr" | |
require "memoist" | |
class Model | |
include ActiveAttr::Model | |
extend Memoist | |
# by default ActiveAttr calls typecaster every time attribute reader is called | |
# this patch adds memoization | |
# https://github.com/cgriego/active_attr/blob/v0.8.5/lib/active_attr/attributes.rb#L199 |
class ClosedStruct < OpenStruct | |
# https://github.com/ruby/ruby/blob/trunk/lib/ostruct.rb#L176 | |
def method_missing(mid, *args) | |
return super if @table.has_key?(mid.to_sym) | |
raise NoMethodError, "undefined method `#{mid}' for #{self}" | |
end | |
end |
gem "puma", require: false, platform: :jruby | |
# Issue: https://github.com/puma/puma/issues/785 | |
begin | |
require "puma/single" | |
class ::Puma::Single | |
alias unpatched_run run |
Record responses and play them from local cache.
Installation:
git clone https://gist.github.com/4368cae5de3f7384fd08.git recordplayer
mkdir ~/.recordplayer
Usage:
# encoding: utf-8 | |
# Source: https://gist.github.com/kml/79bd8cedf64caadd18ca | |
require "active_support/i18n_railtie" | |
# Eager load translations. | |
# https://github.com/svenfuchs/i18n/blob/master/lib/i18n/backend/simple.rb | |
# rails c | |
# I18n.backend.initialized? |
# encoding: utf-8 | |
phrase = "sterownik".force_encoding("utf-8") | |
regexp = /(?i-mx:^bram[ay])|(?i-mx:(prz[e??]s[l??][ao]|element)[a-z??????]* ogrodz[a-z??????]*)|(?i-mx:(sterowniki?|automatyka).*\bbramy?)|(?i-mx:^tralk[ai])|(?i-mx:bojlery?|pojemno.ciow[ey])|(?i-mx:[a-z]+grzewacze? wody)/ | |
puts phrase.match(regexp).inspect | |
=begin | |
UTF8Encoding.java:35:in `length': java.lang.ArrayIndexOutOfBoundsException: 9 | |
from BaseUTF8Encoding.java:91:in `mbcToCode' |
# encoding: utf-8 | |
# Source: https://gist.github.com/kml/3395d73d874b0c302224 | |
# https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/json/encoding.rb | |
require "active_support/json/encoding" | |
unless defined?(ActiveSupport::JSON::Encoding::CircularReferenceError) | |
abort "#{__FILE__}: CircularReferenceError is not defined. Remove this patch!" | |
end |
# encoding: utf-8 | |
# Usage: | |
# jruby coercible_coercer_object_method_missing_patch_bench.rb | |
# jruby coercible_coercer_object_method_missing_patch_bench.rb patch | |
# Issue: https://github.com/solnic/coercible/pull/22 | |
if $0 == __FILE__ | |
require "bundler/inline" |
# encoding: utf-8 | |
# Source: https://gist.github.com/kml/349d3ae1716e6500cbee | |
# Benchmark: https://gist.github.com/kml/0fb1588fc1b6ba4c60fa | |
# Issue: https://github.com/solnic/coercible/pull/22 | |
# https://github.com/solnic/coercible/blob/master/lib/coercible/coercer/object.rb#L163 | |
require "coercible" | |
if Coercible::VERSION != "1.0.0" |