Skip to content

Instantly share code, notes, and snippets.

Dmitry Semenyuk semenyukdmitry

Block or report user

Report or block semenyukdmitry

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
semenyukdmitry / hashquiz.rb
Created Aug 15, 2018 — forked from potatosalad/hashquiz.rb
Ruby quiz for convert hash "dot paths" into actual hash hierarchy.
View hashquiz.rb
#require 'rubygems'
require 'pp'
#require 'ap' # Awesome Print
class Object
# expects [ [ symbol, *args ], ... ]
def recursive_send(*args)
args.inject(self) { |obj, m| obj.send(m.shift, *m) }
View State Pattern
module TestState
InvalidStateError =
def get_state stately
Object.const_get("TestState::#{stately.state}").new stately
rescue NameError
raise InvalidStateError, "Invalid State '#{stately.state}'"
ACTIONS = [:start, :stop]
View simple_thread_pool.rb
# Ruby Thread Pool
# ================
# A thread pool is useful when you wish to do some work in a thread, but do
# not know how much work you will be doing in advance. Spawning one thread
# for each task is potentially expensive, as threads are not free.
# In this case, it might be more beneficial to start a predefined set of
# threads and then hand off work to them as it becomes available. This is
# the pure essence of what a thread pool is: an array of threads, all just
# waiting to do some work for you!
You can’t perform that action at this time.