This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle exec ruby per_thread_registry_benchmark.rb | |
Calculating ------------------------------------- | |
thread-safe 25.176k i/100ms | |
thread-unsafe 30.069k i/100ms | |
------------------------------------------------- | |
thread-safe 1.480M (± 6.5%) i/s - 7.377M | |
thread-unsafe 2.480M (± 7.2%) i/s - 12.328M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module IdempotentCounterCache | |
module BuilderExtension | |
def add_counter_cache_callbacks(reflection) | |
super | |
cache_column = reflection.counter_cache_column | |
foreign_key = reflection.foreign_key | |
# This skip_callback do not work... may be related to https://github.com/rails/rails/issues/12571 | |
# model.skip_callback(:destroy, :before, "belongs_to_counter_cache_before_destroy_for_#{name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails::VERSION::MAJOR >= 4 | |
if Rails::VERSION::MINOR > 0 | |
ActiveSupport::Deprecation.warn("This patch is probably not useful anymore. Check if https://github.com/rails/rails/pull/12425 have been released.") | |
end | |
class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter | |
def type_cast(value, column) | |
case value | |
when TrueClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def bar(*args) | |
attribute(:bar, *args) | |
end | |
def attribute(name) | |
puts name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "convert a latin1 database with utf8 data into proper utf8" | |
task :convert_to_utf8 => :environment do | |
puts Time.now | |
dryrun = ENV['DOIT'] != '1' | |
conn = ActiveRecord::Base.connection | |
if dryrun | |
def conn.run_sql(sql) | |
puts(sql) | |
end | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Raven | |
class Report < Tilt::Template | |
def prepare | |
end | |
def evaluate(context, locals, &block) | |
if context.logical_path.include?('raven') || context.logical_path.include?('github-integration') | |
data | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SomeObserver | |
extend ActiveSupport::Concern | |
included do | |
after_create :do_something | |
end | |
def do_something | |
# | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Select2 2.1</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta name="description" content="Select2 JQuery Plugin"> | |
<meta name="author" content="Igor Vaynberg"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from pysrt import SubRipFile, SubRipItem, SubRipTime | |
parser = argparse.ArgumentParser(description='Merge 2 srt files.') | |
parser.add_argument('fin', type=str, nargs=2, | |
help='input file') | |
parser.add_argument(dest='fout', type=str, nargs=1, | |
help='the output file') |