Skip to content

Instantly share code, notes, and snippets.

Avatar
🆒

Patrick Oscity padde

🆒
View GitHub Profile
View keybase_proof.md

Keybase proof

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:

@padde
padde / c9-elixir.sh
Last active Nov 21, 2018
Install Script for Erlang/Elixir/Phoenix on Cloud9
View c9-elixir.sh
#!/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!
View codepoints.exs
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
@padde
padde / lpmap.exs
Last active Apr 10, 2016
Limited parallel map in Elixir
View lpmap.exs
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
@padde
padde / shellscript.sh
Created Mar 18, 2016
Shell Script Template
View shellscript.sh
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
View letsencrypt-nginx-autorenew.sh
#!/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
@padde
padde / stars.rb
Last active Jan 29, 2016
Colored stars (dabbling with ANSI escape codes)
View stars.rb
lines = `tput lines`.to_i
cols = `tput cols`.to_i
# hide cursor
print "\e[?25l"
# clear screen
print "\e[2J"
at_exit do
@padde
padde / lets-encrypt-nginx.md
Last active Jul 10, 2018
Let's Encrypt with Nginx
View lets-encrypt-nginx.md

Let's Encrypt with Nginx

Here's how I set up a tiny Nginx/Rails server that uses HTTPS via a Let's Encrypt issued certificate.

https://letsencrypt.paddd.de/

Server

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.

@padde
padde / Rakefile
Created Oct 22, 2015
Pass options hash to Rake
View Rakefile
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
@padde
padde / keybase.md
Created Jul 19, 2015
Keybase proof
View keybase.md

Keybase proof

I hereby claim:

  • I am padde on github.
  • I am padde (https://keybase.io/padde) on keybase.
  • I have a public key whose fingerprint is 7B8E 3327 8E52 E3E1 8392 92AE CCBB 382F 5F9D 1786

To claim this, I am signing this object:

You can’t perform that action at this time.