Skip to content

Instantly share code, notes, and snippets.

@ebeigarts
ebeigarts / README.md
Last active Sep 14, 2017
Dokku redeploy fix
View README.md

Rebuild dokku nginx configuration with correct container IP addresses after system reboot until #2736 is released.

sudo curl -L -o /etc/systemd/system/dokku-redeploy-fix.service https://gist.github.com/ebeigarts/e3256021986f625acec62d9add04dfc3/raw/d85afd4e8beba843e273f4c8b7237c375a7eabea/dokku-redeploy-fix.service &&
sudo curl -L -o /usr/bin/dokku-redeploy-fix https://gist.github.com/ebeigarts/e3256021986f625acec62d9add04dfc3/raw/b4b3be7f3fdf51ba4e7716ac8cf04f40b97a762b/dokku-redeploy-fix.sh &&
sudo chmod +x /usr/bin/dokku-redeploy-fix &&
sudo systemctl enable dokku-redeploy-fix
View -
#!/bin/bash
send-message() {
local message=$(echo "$@" \
| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" \
| sed 's/\\/\\\\/g' \
| sed 's/"/\\"/g' \
| sed "s/'/\\'/g")
echo $message
json="{ \"text\": \"$message\" }"
View post.sh
#!/bin/bash
exec >> /var/log/backup.log 2>&1
set -ex
echo "post.sh"
date
if [ -e /tmp/dump.pids ]; then
for PID in `cat /tmp/dump.pids`; do
View pre.sh
#!/bin/bash
exec >> /var/log/backup.log 2>&1
set -ex
/usr/local/avamar/etc/scripts/post.sh
echo "pre.sh"
date
@ebeigarts
ebeigarts / dokku-reip.sh
Last active Mar 27, 2017
dokku-reip.sh
View dokku-reip.sh
for APP in `dokku apps | grep -v '=====> My Apps'`; do
ID=$(cat /home/dokku/$APP/CONTAINER.web.1)
IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $ID)
if [ ! -z $IP ]; then
echo " ---> $APP: $IP"
echo $IP > /home/dokku/$APP/IP.web.1
dokku nginx:build-config $APP
fi
done
View i18n_safe.rb
require "i18n"
I18n.backend = I18n::Backend::KeyValue.new({})
I18n.backend.store_translations(:en, { test: "Hello %{value}" }, escape: false)
module I18nSafeTranslations
def translate(*args)
super
rescue I18n::MissingInterpolationArgument => e
# Raven.capture_exception(e) # send to Sentry
View -
{{ range $port_map := .PROXY_PORT_MAP | split " " }}
{{ $port_map_list := $port_map | split ":" }}
{{ $scheme := index $port_map_list 0 }}
{{ $listen_port := index $port_map_list 1 }}
{{ $upstream_port := index $port_map_list 2 }}
server {
{{ if eq $scheme "http" }}
listen [::]:{{ $listen_port }} default_server;
listen {{ $listen_port }} default_server;
View instrument_template_resolver.rb
if Rails.env.development?
ActionView::PathSet.class_eval do
private
alias_method :__find_all, :_find_all
def _find_all(*args)
t1 = Time.now
__find_all(*args)
ensure
t2 = Time.now
Thread.current["find_template_time"] ||= 0
View keybase.md

Keybase proof

I hereby claim:

  • I am ebeigarts on github.
  • I am ebeigarts (https://keybase.io/ebeigarts) on keybase.
  • I have a public key whose fingerprint is A14B 0A98 2061 C331 E4D8 C62B BD92 D3E2 0910 B700

To claim this, I am signing this object:

@ebeigarts
ebeigarts / deploy.rb
Created Feb 24, 2016
Capistrano 2 + Slack
View deploy.rb
set :slack_webhook_url, "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXX"
namespace :slack do
task :deploy_started do
username = ENV['USER']
on_rollback do
slack(
color: "danger",
message: "*#{username}* cancelled deployment of *#{application}* to *#{rails_env}*"