Skip to content

Instantly share code, notes, and snippets.

View fxposter's full-sized avatar

Pavlo fxposter

View GitHub Profile
if Rails.env.development?
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, QueryTracer::MysqlAdapterExtensions)
Object.send(:include, QueryTracer::ObjectExtensions)
end
@fxposter
fxposter / gist:1391475
Created November 24, 2011 14:34
Haml to ERB converter
require 'haml'
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
@fxposter
fxposter / Gemfile
Created April 19, 2012 11:40
Test environment for rails apps
group :development, :test do
gem 'rspec-rails', '~> 2.9' # rails generate rspec:install
gem 'factory_girl_rails'
end
group :test do
gem 'spork-rails' # spork rspec --bootstrap
gem 'capybara'
gem 'launchy'
gem 'timecop'
@octplane
octplane / .gdbinit
Created July 3, 2012 13:29
Dump Stacktrace in ruby 1.9.3 in gdb
define ruby_stack_trace
set $VM_FRAME_MAGIC_METHOD = 0x11
set $VM_FRAME_MAGIC_BLOCK = 0x21
set $VM_FRAME_MAGIC_CLASS = 0x31
set $VM_FRAME_MAGIC_TOP = 0x41
set $VM_FRAME_MAGIC_FINISH = 0x51
set $VM_FRAME_MAGIC_CFUNC = 0x61
set $VM_FRAME_MAGIC_PROC = 0x71
set $VM_FRAME_MAGIC_IFUNC = 0x81
set $VM_FRAME_MAGIC_EVAL = 0x91
#!/bin/bash
## Short introduction ##
# It is supposed that you have MySQL and lot of files to backup. Done via mk-parallel-dump (maatkit).
# Files (as well as DB dumps) are keept versioned, so you can revert to any state during last 20 days. Done via rdiff-backup.
# Afterwards, files (with versioning metainfo) are transfered to FTP server. Done via duplicity.
# Required software:
# 1. maatkit (mk-parallel-dump)
# 2. rdiff-backup
@headius
headius / 1. results
Last active April 27, 2016 19:43
mandelbrot performance across JRuby 9k modes
# interpreted AST
system ~/projects/jruby $ jruby.bash -X-C mandelbrot.rb 20
warming up
running mandelbrot(500) for 20 iterations
4.862
4.822
4.822
4.846
5.057
@mperham
mperham / after.rb
Created July 4, 2012 19:30
Thread-friendly shared connection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
Ruby 2.1.0 in Production: known bugs and patches
Last week, we upgraded the github.com rails app to ruby 2.1.0 in production.
While testing the new build for rollout, we ran into a number of bugs. Most of
these have been fixed on trunk already, but I've documented them below to help
anyone else who might be testing ruby 2.1 in production.
@naruse I think we should backport these patches to the ruby_2_1 branch and
release 2.1.1 sooner rather than later, as some of the bugs are quite critical.
I'm happy to offer any assistance I can to expedite this process.
@essen
essen / http_specs.md
Last active January 10, 2022 02:01
HTTP and related specifications
@coffeemug
coffeemug / gist:6168031
Last active February 3, 2022 23:16
The fun of implementing date support
After spending the better part of the month implementing date support
in RethinkDB, Mike Lucy sent the team the following e-mail. It would
have been funny, if it didn't cause thousands of programmers so much
pain. Read it, laugh, and weep!
-----
So, it turns out that we're only going to support dates between the
year 1400 and the year 10000 (inclusive), because that's what boost
supports.