I hereby claim:
- I am padde on github.
- I am padde (https://keybase.io/padde) on keybase.
- I have a public key ASAEolg38G1AcHEJA02qn5GcHNIM5025SKK7qMthoGn4RAo
To claim this, I am signing this object:
require 'active_support/duration' | |
offset = 0 | |
puts "attempt 0 immediately" | |
0.upto(24) do |count| | |
# https://github.com/mperham/sidekiq/blob/v6.1.2/lib/sidekiq/job_retry.rb#L225 | |
average_jitter = (15 * (count + 1)) | |
delay = count**4 + 15 + average_jitter |
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env bash | |
############### USAGE ############### | |
# | |
# 1. Create a new workspace on Cloud9 using the "Blank" template | |
# | |
# 2. Run this command in the console: | |
# bash <(curl -fsSL https://gist.githubusercontent.com/padde/3c6301f15cbd5025e131740dae33aa95/raw/c9-elixir.sh) | |
# | |
# 3. There is no step 3! |
defmodule Codepoints do | |
defstruct str: "" | |
def new(str) when is_list(str) do | |
new(to_string(str)) | |
end | |
def new(str) when is_binary(str) do | |
%__MODULE__{str: str} | |
end |
defmodule Parallel do | |
def run(funs, max) do | |
tasks = for fun <- funs, do: {make_ref, fun} | |
results = do_run(tasks, max, 0, %{}) | |
for {ref, _} <- tasks, do: results[ref] | |
end | |
defp do_run([], _max, 0, results) do | |
results | |
end |
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' |
#!/usr/bin/env sh | |
# Automatically renew all installed letsencrypt certificates on this server | |
service nginx stop | |
/root/letsencrypt/letsencrypt-auto renew -nvv --standalone > /var/log/letsencrypt/renew.log 2>&1 | |
RESULT=$? | |
service nginx start | |
# optional: notify yourself of succeeded/failed renewals |
lines = `tput lines`.to_i | |
cols = `tput cols`.to_i | |
# hide cursor | |
print "\e[?25l" | |
# clear screen | |
print "\e[2J" | |
at_exit do |
Here's how I set up a tiny Nginx/Rails server that uses HTTPS via a Let's Encrypt issued certificate.
I use the smallest DigitalOcean droplet (512 MB) here, which is built from the "Ubuntu Ruby on Rails on 14.04" image provided by them.
module RakeOptionParser | |
def self.parse(args) | |
args.extras.each_with_object({}) do |arg, result| | |
key, value = arg.split(/:\s*/, 2) | |
result[key.to_sym] = value | |
end | |
end | |
end | |
namespace :foo do |