Skip to content

Instantly share code, notes, and snippets.

View victorhazbun's full-sized avatar
🚀
Work work work

Victor Hazbun Anuff victorhazbun

🚀
Work work work
View GitHub Profile
@victorhazbun
victorhazbun / int_to_base.rb
Created September 19, 2023 19:15
URL shortener
class IntToBase
def self.convert(int, base)
digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
result = ""
while int > 0
result += digits[int % base]
int /= base
end
result.reverse
end
@victorhazbun
victorhazbun / Benchmark.rb
Created October 7, 2023 18:44 — forked from mperham/Benchmark.rb
Leaky bucket limiter usage with Sidekiq Enterprise
require 'benchmark'
require 'sidekiq-ent/limiter'
COUNT = 10_000
Benchmark.bmbm(30) do |x|
x.report("leaky") do
COUNT.times do |count|
lmt = Sidekiq::Limiter.leaky("leaky_#{count%100}", 10, 10, wait_timeout: 0, policy: :skip)
lmt.within_limit do