Skip to content

Instantly share code, notes, and snippets.

@maierru
maierru / client_example
Created November 8, 2019 23:42 — forked from sandro/client_example
Ruby select socket server. An example of a single-threaded, event-driven (select) server.
$ irb -r ./select_server
>> client.puts "hi"
=> nil
>> client.puts "bye"
=> nil
>> client.close
=> nil
>> exit
@maierru
maierru / clear-sidekiq-jobs.sh
Created April 15, 2019 07:35 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
@maierru
maierru / line_count_benchmark.rb
Created August 17, 2018 14:24 — forked from guilhermesimoes/line_count_benchmark.rb
Ruby Benchmark: Counting the number of lines of a file
# gem install benchmark-ips
require "benchmark/ips"
path = "lib/rubycritic/cli/options.rb"
Benchmark.ips do |x|
x.report("read + each_line") { File.read(path).each_line.count }
x.report("open + each_line") { File.open(path, "r").each_line.count }
@maierru
maierru / accounting.sql
Created February 6, 2018 09:20 — forked from RichardKnop/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...