Skip to content

Instantly share code, notes, and snippets.

View crossaidi's full-sized avatar

Dmitry Kovalevsky crossaidi

View GitHub Profile
@crossaidi
crossaidi / gist:5c8dbf91023565f4ca13
Last active August 29, 2015 14:13
Ошибки появляющиеся через раз
В случае появляющийся через раз ошибки, нужно в первую очередь проверить, что во всех случаях выполняется один и тот же код. Если код может выполняться на нескольких машинах, то необходимо проверить, что все они настроены должным образом и в памяти не висят запущенными старые процессы, выполняющие старый код (в случае с менеджером очередей).
"http://www.example.com?" + { language: "ruby", status: "awesome" }.to_query
# => "http://www.example.com?language=ruby&status=awesome"
@crossaidi
crossaidi / improved_benchmarking.rb
Created October 13, 2014 14:28
improved benchmarking
require "benchmark/ips"
Benchmark.ips do |x|
x.report("fast") { fast }
x.report("slow") { slow }
end
@crossaidi
crossaidi / dev_gems
Created October 12, 2014 09:17
Common dev gems set
dev group gems:
spring
rack-mini-profiler
bullet
pry-rails
pry-debugger
pry-rescue
pry-stack_explorer
@crossaidi
crossaidi / rbenv_plugins
Created October 11, 2014 16:19
rbenv plugins
rbenv must have plugins: rbenv-gem-rehash, rbenv-bundle-exec
(1..10).each_slice(3) {|a| p a}
# outputs below
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
[10]
numbers.map {|n| n*n}.reduce(:+)
@crossaidi
crossaidi / values_at.rb
Created May 3, 2014 12:01
values_at method
email, username = data.values_at('email', 'nickname')
@crossaidi
crossaidi / tempfile.rb
Created March 26, 2014 19:06
Tempfile
Tempfile.open('temp') {|file| p file.path }
@crossaidi
crossaidi / inline_rescue.rb
Created March 26, 2014 18:33
Inline rescue
def set_name(params)
@name = params.fetch(:name) rescue 'Anonymous'
end