Skip to content

Instantly share code, notes, and snippets.

View sobrinho's full-sized avatar

Gabriel Sobrinho sobrinho

View GitHub Profile
SELECT name, COUNT(*)
FROM absences
GROUP BY name
ORDER BY COUNT(*) DESC
FETCH FIRST 3 ROWS WITH TIES;
name | count
------------+-------
John Doe | 2392
Jane Doe | 1960
@sobrinho
sobrinho / sidekiq.rb
Last active December 26, 2025 16:55
Use this to reload a Rails 3.2 application with Sidekiq 4.2 as it happens on Puma
# frozen_string_literal: true
require "thread"
# A writer-preferred read/write lock for Ruby.
#
# Semantics:
# - Multiple threads may hold the read lock concurrently.
# - Only one thread may hold the write lock at a time.
# - While a writer is active, no readers or other writers may proceed.
# - Writer-preferred: once any writer arrives (even if it must wait),