Skip to content

Instantly share code, notes, and snippets.

@mattes
mattes / main.go
Last active October 10, 2021 09:34
package test
import (
"regexp"
guuid "github.com/google/uuid"
suuid "github.com/satori/go.uuid"
)
var re = regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$")
@mattes
mattes / make-a-call.alfredworkflow
Last active June 16, 2021 18:20
Place a call from Alfred using your iPhone (Mac OS X Yosemite & iOS 8)
# trust google cloud load balancer ips
# https://cloud.google.com/load-balancing/docs/https#x-forwarded-for_header
config.action_dispatch.trusted_proxies = %w(130.211.0.0/22 35.191.0.0/16).map { |proxy| IPAddr.new(proxy) }
<%
branch = `git rev-parse --abbrev-ref HEAD`.strip rescue ENV.fetch("RAILS_DATABASE_SUFFIX", "master")
branch = branch.underscore.gsub(/[\.\/\-]/, '_')
%>
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
host: <%= ENV.fetch("RAILS_DATABASE_HOST", "127.0.0.1") %>
@mattes
mattes / main.go
Created February 12, 2021 07:59
Quick HTTPS debug server
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"os"
"golang.org/x/crypto/acme/autocert"
@mattes
mattes / script.sh
Created February 10, 2021 23:20
Allow non-root binary to bind port 80 and 443
sudo setcap CAP_NET_BIND_SERVICE=+eip /path/to/binary
@mattes
mattes / call
Last active December 29, 2020 09:49
Place a call from terminal using your iPhone (Mac OS X Yosemite & iOS 8)
#!/usr/bin/env sh
open "tel://$*"
@mattes
mattes / example.prf
Created November 1, 2012 00:36
unison profile
root = /Users/matthias/somedir
root = ssh://matthias@host:9000/somedir
auto = true
log = true
logfile = /Users/matthias/.unison/unison.log
maxbackups = 5
backup = Name *
@mattes
mattes / resque.rb
Created October 30, 2020 08:02
Resque in distroless docker container
# config/initializers/resque.rb
module Resque
class Worker
# Monkey patch linux_worker_pids because the original function tries to shell out.
# Since we run distroless in production, there is no shell.
# https://github.com/resque/resque/blob/7f6b88404dd18698f6f4023e18fdc1ae8318e5e5/lib/resque/worker.rb#L839
def linux_worker_pids
[Process.pid]
end
end
docker system prune -a
docker rm $(docker ps -a -f status=exited -q)
https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes