Skip to content

Instantly share code, notes, and snippets.

View ILoGM's full-sized avatar

Alexey Mikka ILoGM

  • FunBox
  • Ulyanovsk, Russia
View GitHub Profile
@ILoGM
ILoGM / active_record_patch.rb
Created August 4, 2016 10:23
AR 4.1.6 monkey patch for pg 9.5.3
# HACK:
# There is a deprecation of '-i' flag for pg_dump command, appeared in Postgres 9.5
# The following rake task overrides the default `rake db:structure:dump` to be able to dump db structure without upgrading ActiveRecord.
# @ref: https://github.com/rails/rails/issues/23030#issuecomment-171084067
require 'shellwords'
module ActiveRecord
module Tasks # :nodoc:
class PostgreSQLDatabaseTasks # :nodoc:
@ILoGM
ILoGM / migrator_monkey_patch.rb
Created April 15, 2014 12:06
This patch allows disable ddl transactions in Rails 3.2
class ActiveRecord::Migrator
def migrate(&block)
current = migrations.detect { |m| m.version == current_version }
target = migrations.detect { |m| m.version == @target_version }
if target.nil? && @target_version && @target_version > 0
raise UnknownMigrationVersionError.new(@target_version)
end
start = up? ? 0 : (migrations.index(current) || 0)
@ILoGM
ILoGM / cleaning_up.c
Created February 14, 2013 02:11
Пример программного снятия GVL. Оригинал статьи http://www.spacevatican.org/2012/7/5/whos-afraid-of-the-big-bad-lock/
static void *rb_rdiscount_to_html_no_gvl(void * param_block){
rb_discount_to_html_param_block *block = (rb_discount_to_html_param_block*)param_block;
block->doc = mkd_string(block->input, block->input_length, block->flags);
if(mkd_compile(block->doc, block->flags)){
block->szres = mkd_document(block->doc, &block->res);
}
return NULL;
}
/*wrapper function. only exists because we need to pass a function pointer to rb_ensure*/