Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Merk bibendi

View GitHub Profile
View gist:9f51c6bbe9ce19f975fa
language: ruby
rvm:
- '1.9.3'
env:
- DEPLOY=shippable PROJECT=ci VERBOSE=1 JOBS=8 RUBY_GC_MALLOC_LIMIT=990000000
services:
- memcached
View bundler-backtrace.md
$ time bundler --version
^C/home/merkushin/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb:237:in `shallow_eql?': Interrupt
	from /home/merkushin/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb:193:in `block in outgoing_edges'
	from /home/merkushin/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb:193:in `select'
	from /home/merkushin/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb:193:in `outgoing_edges'
	from /home/merkushin/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb:211:in `successors'
	from /home/merkushin/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb:251:in `path_to?'
	from /home/merkushin/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/l
@bibendi
bibendi / bundler.1.10.5.md
Last active August 29, 2015 14:24
bundler env 1.10.5
View bundler.1.10.5.md
$ time bundler --version
Bundler version 1.10.5

real	0m42.770s
user	0m42.459s
sys	0m0.273s
@bibendi
bibendi / gist:1315929
Created October 26, 2011 09:57
make action and fragment caching of rails 3.0.9 compatible with content_for
View gist:1315929
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?
View Dockerfile.1.9.slim-development
FROM ruby:1.9.3-slim
RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
locales \
make \
gcc \
g++ \
libxml2-dev \
libxslt-dev \
View cosorter
#!/usr/bin/env ruby
# coding: utf-8
gem "activesupport"
gem "optparse-range"
gem "tty-table"
gem "ascii_charts"
require "optparse"
require "optparse/time"
require "optparse/range"
@bibendi
bibendi / resque.rake
Created March 17, 2017 09:29 — forked from denmarkin/resque.rake
My rake task for clearing Resque queues and stats
View resque.rake
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@bibendi
bibendi / join-values-explain.txt
Last active May 29, 2017 07:37
Postgres query optimization
View join-values-explain.txt
Nested Loop (cost=0.42..4594.88 rows=830 width=430) (actual time=0.038..18.896 rows=829 loops=1)
-> Values Scan on "*VALUES*" (cost=0.00..10.40 rows=832 width=4) (actual time=0.005..2.557 rows=832 loops=1)
-> Index Scan using trait_values_pkey on trait_values (cost=0.42..5.50 rows=1 width=430) (actual time=0.006..0.009 rows=1 loops=832)
Index Cond: (id = "*VALUES*".column1)
Filter: (((state)::text = 'accepted'::text) AND (public_state = 'published'::trait_value_public_state))
Rows Removed by Filter: 0
Total runtime: 21.202 ms
View ruby-job.md

Вопросы на собеседование Ruby программиста

Технический блок

  • Чем отличается module от class?
  • Чем отличается String от Symbol?
  • Слышал ли про duck typing?
  • С каким гемами работал? Какие больше всего понравились?
  • С какими версиями RoR работал?
  • Как обстоит дело с тестированием?
@bibendi
bibendi / benchmark.rb
Created October 25, 2017 06:08
Compare map vs map!
View benchmark.rb
key = "id".freeze
rows = []
5000.times { rows << {"id" => rand(5000).to_s} }
require 'benchmark/ips'
Benchmark.ips do |x|
x.report('map') { rows.dup.map { |r| r[key].to_i } }
x.report('map!') { rows.dup.map! { |r| r[key].to_i } }