Skip to content

Instantly share code, notes, and snippets.

DB_CONTAINER="$(docker-compose ps -q pgsql-10.4)"
DB_NAME=postgres
DB_USER=postgres
LOCAL_DUMP_PATH="eeeff09c-9a4f-498a-8098-f38341fc984d.dump"
docker-compose up -d ${DB_CONTAINER}
docker exec -i "${DB_CONTAINER}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_NAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop ${DB_CONTAINER}
sudo ./certbot-auto certonly --manual -d 'example.com' -d '*.example.com' --agree-tos --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory
function (user, context, callback) {
var namespace = 'https://example.com/';
context.idToken[namespace + 'first_name'] = user.user_metadata.first_name;
context.idToken[namespace + 'last_name'] = user.user_metadata.last_name;
context.idToken[namespace + 'mobile_number'] = user.user_metadata.mobile_number;
context.idToken[namespace + 'organizations_name'] = user.user_metadata.organizations_name;
callback(null, user, context);
}
SELECT
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = "$DB_NAME"
AND table_name = "$TABLE_NAME";
# If a second instance of this script starts, it won't run the command and exit with 1.
flock -n /tmp/.process-name.lock <long command with args here>
<!DOCTYPE html>
<head>
<title>autosizing</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
div { border: 1px solid #aaa; }
.w70 { width: 70%; }
.w20 { width: 20%; }
</style>
</head>
# letsencrypt.service
[Unit]
Description=Renew Letsencrypt certificates
[Service]
Type=simple
ExecStart=/usr/bin/letsencrypt renew -n --no-self-upgrade
# letsencrypt.timer
[Unit]

MySQL commands

  • Show table collation from a database:
show table status from <database>;
  • Show collation from an entire database;
[Unit]
Description=Puma Server
[Service]
Type=forking
User=netengine
WorkingDirectory=/var/www/puma/current
Environment=RAILS_ENV=staging
SyslogIdentifier=puma
PIDFile=/var/www/puma/current/tmp/pids/puma.pid
@duderamos
duderamos / delayed_job.service
Created January 1, 2017 19:38
Systemd unit file for delayed_job
[Unit]
Description=delayed_job
After=syslog.target
After=postgresql.service
[Service]
Type=forking
User=netengine
Environment=RAILS_ENV=production
WorkingDirectory=/var/www/unicorn/current