Skip to content

Instantly share code, notes, and snippets.

Killing it, hustling, no code is best code

Sergey Alekseev sergey-alekseev

Killing it, hustling, no code is best code
Block or report user

Report or block sergey-alekseev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mysql2-single-column-with-unique-index-reports.txt
=========== [mysql2] Single column with unique index (1000 records) ============
Warming up --------------------------------------
validate_only_if_changed_by_default = true
2.014k i/100ms
validate_only_if_changed_by_default = false
227.000 i/100ms
Calculating -------------------------------------
validate_only_if_changed_by_default = true
21.060k (± 3.1%) i/s - 106.742k in 5.073537s
sergey-alekseev / onliner-by-auto-up.rb
Created Dec 21, 2016
Скрипт для автоматического поднятия объявлений на Барахолке Онлайнера (
View onliner-by-auto-up.rb
# this is a simple Ruby script written by
# to automate dummy "UP"s for adverts on the most popular local Belarusian
# online flea market –
# feel free to create a recurring task from the script
# using launchd on Mac or cron on Linux
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
View rails-uniqueness-validation-scope-with-polymorphic-association_active_record_master.rb
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
gemfile(true) do
source ""
gem "rails", github: "rails/rails"
View logstash-es-to-csv-example.conf
input {
# Read all documents from Elasticsearch matching the given query
elasticsearch {
hosts => "localhost"
index => "index_name"
query => '{"query":{"regexp":{"not_analyzed_field":".*"}}}'
output {
sergey-alekseev /
Last active Dec 2, 2015 — forked from wvengen/
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

sergey-alekseev / merge-vs-merge-with-bang.rb
Created Mar 30, 2015
Ruby Merge vs. Merge! comparison (benchmarking)
View merge-vs-merge-with-bang.rb
Benchmark.ips do |x|'merge') { {}.merge :a => 1 }'merge!') { {}.merge! :a => 1 }!
Calculating -------------------------------------
merge 34.220k i/100ms
merge! 33.039k i/100ms
merge 1.923M (±32.2%) i/s - 7.631M
View exists-vs-where_any-comparison.rb
Benchmark.ips do |x|'exists?') { User.exists?(:id => 1) }'where-any?') { User.where(:id => 1).any? }!
exists?: 636.0 i/s
where-any?: 567.1 i/s - 1.12x slower
View exists-vs-any-comparison.rb
Benchmark.ips do |x|'exists?') { user.printers.exists? }'any?') { user.printers.any? }!
any?: 615.6 i/s
exists?: 601.8 i/s - 1.02x slower
View object-vs-id-comparison.rb
Benchmark.ips do |x|'object comparison') { item.user == print.user }'id comparison') { item.user_id == print.user_id }!
Calculating -------------------------------------
object comparison 1.204k i/100ms
id comparison 1.972k i/100ms
sergey-alekseev / sublime-text-settings-user
Created Feb 12, 2015
Sublime Text configuration. Make sure you have these lines in your Settings - User.
View sublime-text-settings-user
"ensure_newline_at_eof_on_save": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
You can’t perform that action at this time.