This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Worker | |
def self.start(num_threads:, queue_size:) | |
queue = SizedQueue.new(queue_size) | |
worker = new(num_threads: num_threads, queue: queue) | |
worker.spawn_threads | |
worker | |
end | |
def initialize(num_threads:, queue:) | |
@num_threads = num_threads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[server] | |
SERVER | |
[server:vars] | |
server_name=SERVER | |
email=noc@gopractice.io | |
docker_nginx_ssl=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest' | |
require 'benchmark' | |
hash = {} | |
10_000_000.times do | |
key = Digest::MD5.hexdigest(rand.to_s) | |
value = Digest::MD5.hexdigest(rand.to_s) | |
hash[key] = value | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (context, trackingId, options) { | |
const history = context.history; | |
const doc = document; | |
const nav = navigator || {}; | |
const storage = localStorage; | |
const encode = encodeURIComponent; | |
const pushState = history.pushState; | |
const typeException = 'exception'; | |
const generateId = () => Math.random().toString(36); | |
const getId = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# | |
# class Mail | |
# include SimpleStateMachine | |
# | |
# self.initial_state = 'unread' | |
# self.transitions_map = { | |
# read: {from: 'unread', to: 'read'}, | |
# unread: {from: 'any', to: 'unread'}, | |
# delete: {from: 'any', to: 'deleted'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SimpleRailway | |
class Result | |
attr_accessor :success, :data | |
def initialize(success, data) | |
@success = success | |
@data = data | |
end | |
def success?; !!success; end | |
def failure?; !success?; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'pg' | |
gem 'activerecord', '5.2.0' | |
gem 'memory_profiler' | |
gem 'benchmark-ips' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'pg' | |
gem 'activerecord', '5.2.0' | |
gem 'benchmark-ips' | |
end | |
require 'active_record' |
parentheses: ( )
braces: { }
brackets: < >
square-brackets: [ ]