Skip to content

Instantly share code, notes, and snippets.

View seeARMS's full-sized avatar

Colin Armstrong seeARMS

View GitHub Profile
# Exponential backoff using Ruby lambdas
#
# Continuously retry sending a request at exponentially increasing
# values, with a top at 1 second
num_retries = 5
exp_backoff = ->(i) { [1, (0.5 * (2.0**(i/2.0) - 1.0))].min }
# stores the delays