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
rails 3.1.1: | |
http://dl.dropbox.com/u/12274059/rails_issue311 | |
rails 4.0.0beta: | |
http://dl.dropbox.com/u/12274059/rails_issue400beta |
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
# rails/actionpack/lib/action_view/cache_helper.rb | |
private | |
# TODO: Create an object that has caching read/write on it | |
def fragment_for(name = {}, options = nil, &block) #:nodoc: | |
if fragment = controller.find_fragment(name, options) | |
fragment.read | |
else | |
# VIEW TODO: Make #capture usable outside of ERB | |
# This dance is needed because Builder can't use capture |
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
#!/usr/bin/env ruby | |
require 'epath' | |
bom = "\xEF\xBB\xBF".force_encoding('binary') | |
Path.glob('**/*.rb') do |file| | |
next if file.binread(3) == bom | |
previous = file.binread | |
file.write bom + previous | |
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
# Sort by memsize from first 50 lines of dump (can be just with `cat` command) | |
head -50 input.json | jq --slurp '[.[] | {address: .address, type: .type, file: .file, line: .line, method: .method, memsize: .memsize }] | sort_by(.memsize) | map([.address, .type, .file, "\(.line)", .method, "\(.memsize)"] | join(" ")) | reverse' | head -20 | |
# Group objects by type-class-struct-name, count them, count sum of their memsize and sort them by count | |
# Useful when you didn't trace allocations | |
cat input_file | jq --slurp '[.[] | {type: "\(.type) \(.class) \(.struct) \(.name)", memsize: .memsize}] | group_by(.type) | map(reduce .[] as $item ({type: .[0].type, memsize: .[0].memsize, count: 0}; {type: .type, memsize: (.memsize + $item.memsize), count: (.count + 1)})) | sort_by(.count) | map(["\(.count)", "\(.memsize)", .type] | join(" : ")) | reverse' > output_file | |
# Group objects by allocation file-line, count them and their sum of memsize and sort by memsize | |
cat input_file | jq --slurp '[.[] | {address: .address, type: |
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
# implementation of Range#=== in 1.8.7 - it was the same method as Range#include?: | |
<<-EOS | |
static VALUE | |
range_include(range, val) | |
VALUE range, val; | |
{ | |
VALUE beg, end; | |
beg = rb_ivar_get(range, id_beg); | |
end = rb_ivar_get(range, id_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
require 'sidekiq/cli' | |
require 'sidekiq/api' | |
require 'celluloid' | |
puts Sidekiq::Stats.new.queues | |
Sidekiq::Queue.new('default').clear | |
Sidekiq::RetrySet.new.clear | |
module Count |
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
# Based on https://gist.github.com/74107 by # Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com> | |
# | |
# Rewrited by gazay | |
require 'socket' | |
require 'uri' | |
class Proxy | |
attr_accessor :socket |
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
#!/usr/bin/env ruby | |
client_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'proxy')) | |
$LOAD_PATH.unshift(client_dir) unless $LOAD_PATH.include?(client_dir) | |
require 'client' | |
# Get parameters and start the server | |
if ARGV.size == 2 | |
port, proxy = ARGV | |
port = port.to_i |
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
require 'fileutils' | |
class Helper | |
attr_accessor :dir, :temp_dir | |
attr_reader :template_path, :original_dir | |
def initialize(dir = nil) | |
@template_path = File.expand_path('../../app_template', __FILE__) | |
@original_dir = FileUtils.pwd |
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
"require 'spec_helper'\n\ndescribe 't34' do\n let(:target) {\n\"class X\n def test_method(arg1)\n end\nend # X\"\n }\n\n let(:target2) {\n\"class X\n def test_method(xxx, arg2)\n end\nend # X\"\n }\n\n let(:source) {\n\"class X\n def test_method(arg1, arg2)\n end\nend\"\n }\n\n let(:rewriter) {\n T34::Rewriter.new source\n }\n\n it 'finds methods' do\n expect(rewriter.methods(:test_method)).to be_kind_of Array\n end\n\n it 'finds method nodes' do\n expect(rewriter.methods(:test_method).map(&:class).compact).to eq [T34::Rewriter::API::MethodNode]\n end\n\n it 'manipulates methods' do\n res = rewriter.methods(:test_method) do |method_node|\n method_node.args = method_node.args[0...-1]\n end\n expect(res[0].args.size).to eq 1\n end\n\n it 'manipulates arguments by name' do\n res = rewriter.methods(:test_method) do |method_node|\n method_node.args = method_node.args.select { |it| it.name != 'arg2' }\n end\n expect(res[0].args.size).to eq 1\n expect(rewr |