Skip to content

Instantly share code, notes, and snippets.

💪
Every day!

Sergii Demianchuk ndemianc

💪
Every day!
Block or report user

Report or block ndemianc

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
@ndemianc
ndemianc / ruby_prof_sidekiq.rb
Created Jun 29, 2018
How to use Ruby Prof to profile Sidekiq Worker
View ruby_prof_sidekiq.rb
# How to use Ruby Prof to profile Sidekiq Worker
require 'ruby-prof'
result = RubyProf.profile do
#Code to analyse in a method
EsIndexWorker.new.perform
end
@ndemianc
ndemianc / dig_vs_fetch.rb
Last active Jun 25, 2018
Hash#dig vs Hash#fetch
View dig_vs_fetch.rb
require "benchmark"
h = { a: { b: { c: { d: { e: "foo" } } } } }
n = 50_000
Benchmark.bmbm(7) do |x|
x.report "Hash#dig" do
n.times do ; h.dig(:a, :b, :c, :d, :e); end
end
View keybase.md

Keybase proof

I hereby claim:

  • I am ndemianc on github.
  • I am ndemianc (https://keybase.io/ndemianc) on keybase.
  • I have a public key ASBLihFG_HQlBwIv69F1pQ3HTr3VgnpAtkSuCboGTeAARQo

To claim this, I am signing this object:

@ndemianc
ndemianc / docker_container_stop.sh
Last active Mar 12, 2018
Docker: stop and remove all docker containers
View docker_container_stop.sh
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@ndemianc
ndemianc / benchmark.rb
Last active Dec 14, 2017
Benchmark Array#to_h and Enumerable#inject
View benchmark.rb
require 'benchmark'
array = Array.new(1_000_000, { id: 'key' })
values = ['.p12', '.pfx']
Benchmark.bmbm(7) do |bm|
bm.report('to_h') do
array.map do |prop|
[
prop[:id],
View redis.py
import redis
r = redis.StrictRedis(host='localhost', port=6379, decode_responses=True, password='123')
r.hset('candidate:1', 'name', 'Mary Sue')
r.hset('candidate:1', 'position', 'super tester')
r.hget('candidate:1', 'name')
m = r.hgetall('candidate:1')
print(m['name'])
@ndemianc
ndemianc / process.ex
Last active Jan 5, 2017
Small linked task, that can run on the multicore processor, and save a state inside Map like key-value store in Elixir
View process.ex
defmodule Project do
@moduledoc """
This module includes example code of the Elixir linked tasks based on the Elixir linked processes.
"""
@doc """
Create new task.
Returns `{:ok, pid}`
You can’t perform that action at this time.