Skip to content

Instantly share code, notes, and snippets.

View sergey-alekseev's full-sized avatar
🇺🇦
#StandWithUkraine

Sergey Alekseev sergey-alekseev

🇺🇦
#StandWithUkraine
View GitHub Profile
@sergey-alekseev
sergey-alekseev / sublime-text-settings-user
Created February 12, 2015 14:51
Sublime Text configuration. Make sure you have these lines in your Settings - User.
{
"ensure_newline_at_eof_on_save": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}

Keybase proof

I hereby claim:

  • I am sergey-alekseev on github.
  • I am sergeyalekseev (https://keybase.io/sergeyalekseev) on keybase.
  • I have a public key whose fingerprint is 2D4B 460A 441B D5A9 F42E 97A9 781C 4863 C8D7 8D81

To claim this, I am signing this object:

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
sergey-alekseev / merge-vs-merge-with-bang.rb
Created March 30, 2015 12:38
Ruby Merge vs. Merge! comparison (benchmarking)
Benchmark.ips do |x|
x.report('merge') { {}.merge :a => 1 }
x.report('merge!') { {}.merge! :a => 1 }
x.compare!
end
Calculating -------------------------------------
merge 34.220k i/100ms
merge! 33.039k i/100ms
-------------------------------------------------
merge 1.923M (±32.2%) i/s - 7.631M
# Russian. Updated 2014-04-01
ru:
admin:
js:
true: 'True'
false: 'False'
is_present: 'Не пустое'
is_blank: 'Пустое'
date: 'Дата ...'
=========== [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
sergey-alekseev / onliner-by-auto-up.rb
Created December 21, 2016 16:07
Скрипт для автоматического поднятия объявлений на Барахолке Онлайнера (http://baraholka.onliner.by)
# this is a simple Ruby script written by https://github.com/sergey-alekseev
# to automate dummy "UP"s for adverts on the most popular local Belarusian
# online flea market – http://baraholka.onliner.by
# feel free to create a recurring task from the script
# using launchd on Mac or cron on Linux
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", github: "rails/rails"
@sergey-alekseev
sergey-alekseev / gist:5126200
Created March 9, 2013 23:09
Rails pretty flash messages with Twitter Bootstrap
# See http://twitter.github.com/bootstrap/components.html#alerts
#
# USAGE:
# flash.now[:info] = { title: 'New flash messages! ', body: 'Just add :info, :success, :warning or :error.' }
# redirect_to root_path, warning: 'You should use :success and :error instead of :notice and :alert'
#
# in application_controller.rb
def pretty_flash(name, msg)
msg_content = if msg.is_a?(String)
@sergey-alekseev
sergey-alekseev / ga_helper.rb
Created February 3, 2013 16:53
Google Analytics Rails helper
# ERB:
#
# <%= google_analytics 'UA-XXXXXXXX-X' %>
# </head>
#
# Haml:
#
# = google_analytics('UA-XXXXXXXX-X')
# %body