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
patch_url=https://raw.github.com/gist/1658360/afd06eec533ad0140011bdaf652e6cd82eedf7ec/cumulative_performance.patch | |
yaml_url=http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz | |
ruby_url=http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz | |
build_package_falcon_patch() { | |
echo 'applying falcon patch' | |
curl $patch_url | patch -p1 | |
build_package_standard $1 | |
} |
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
ruby-1.9.3-p0 | |
3.27 real 2.45 user 0.40 sys | |
51400704 maximum resident set size | |
2.84 real 2.44 user 0.33 sys | |
55898112 maximum resident set size | |
2.77 real 2.42 user 0.32 sys | |
55369728 maximum resident set size | |
2.77 real 2.40 user 0.32 sys | |
57630720 maximum resident set size | |
3.22 real 2.46 user 0.33 sys |
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
ruby-1.9.3-p0 | |
2.72 real 2.37 user 0.31 sys | |
54624256 maximum resident set size | |
2.69 real 2.36 user 0.31 sys | |
56795136 maximum resident set size | |
2.66 real 2.34 user 0.30 sys | |
47902720 maximum resident set size | |
2.67 real 2.34 user 0.31 sys | |
53112832 maximum resident set size | |
2.68 real 2.36 user 0.31 sys |
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 'celluloid' | |
class Foo | |
include Celluloid | |
def waiting | |
puts 'before wait' | |
wait :bar | |
puts 'after wait' # is never called, why? | |
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 'benchmark' | |
module Capistrano::Benchmark | |
def self.included(base) | |
base.class_eval do | |
alias execute_task_without_benchmark execute_task | |
alias execute_task execute_task_with_benchmark | |
end | |
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
# позволяет получить процентное соотношение для чисел в массиве | |
# percents [1,2,3] => [0.16666666666666666, 0.3333333333333333, 0.5] | |
def percents(numbers) | |
total = numbers.inject(:+).to_f | |
numbers.map {|it| it / total } | |
end | |
# позволяет получить процентное распределение для чисел в массиве | |
# требуется чтобы генерировать рендомное число с заданными вероятностями | |
# distribution [1,2,3] => [0.16666666666666666, 0.5, 1.0] |
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 Lock | |
extend self | |
delegate :connection, :to => ActiveRecord::Base | |
def sync(*args) | |
lock = Zlib.crc32 args.join | |
obtain lock | |
yield | |
ensure | |
release lock |
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
def bash_escape(argument) | |
"$'" + argument.gsub("\\'", '\\\\\&').gsub("'", "\\\\'") + "'" | |
end | |
ruby_code = "puts 'something'" | |
command = "ruby -e #{bash_escape ruby_code}" | |
puts "ssh server #{bash_escape command}" # => ssh server $'ruby -e $\'puts \\\'something\\\'\'' |
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 Developer | |
extend self | |
delegate :establish_connection, :clear_all_connections!, :to => ActiveRecord::Base | |
def delayed_debug(scope) | |
detach_process do | |
close_io_objects | |
establish_connection | |
setup_process_name | |
notify_developers |
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
def method(variable=((default=true);nil)) | |
puts "Value: #{variable.inspect}, default argument - #{!!default}" | |
end | |
method nil # => Value: nil, default argument - false | |
method # => Value: nil, default argument - true |