Skip to content

Instantly share code, notes, and snippets.

@nickgravel
nickgravel / undo-remote-network-config-error.md
Created March 20, 2024 15:58
Undo your remote networking config mistakes *after* you’ve been disconnected

You were updating some *nix firewall rules or network configs over a remote connection and changed the wrong setting. Oops, now you’re locked out and feeling helpless.

Next time, follow the steps below to undo your network mistakes and avoid getting locked out permanently. The example commands illustrate how you’d recover from fucking-up a sshd_config change.

1. Backup Your Config(s)

Upon connecting to the remote server, immediately make a backup of the file(s) you need to modify.

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.old
@nickgravel
nickgravel / Caddyfile
Created July 16, 2023 20:06
Caddy simple zero downtime reverse proxy config
MYDOMAIN.com {
encode gzip
reverse_proxy 127.0.0.1:3333 {
health_uri /health
lb_try_duration 30s
}
}
@nickgravel
nickgravel / riot-matrix-workshop.md
Last active April 27, 2019 20:05 — forked from attacus/riot-matrix-workshop.md
Create your own encrypted chat server with Riot and Matrix

Running your own encrypted chat service with Matrix and Riot

Workshop Instructor:

This workshop is distributed under a CC BY-SA 4.0 license.

What are we doing here?

The goal of this workshop is to teach you how to configure and run your own Matrix/Riot service. By the end of the workshop, you should be able to log into secure chat rooms and invite others to the same server.

@nickgravel
nickgravel / .htaccess
Last active June 12, 2024 01:31
Apache 2.4 mod_expires suggested settings
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/ld+json "access plus 0 seconds"

Keybase proof

I hereby claim:

  • I am nickgravel on github.
  • I am nickgravel (https://keybase.io/nickgravel) on keybase.
  • I have a public key whose fingerprint is CF9D EFCE D85C C190 70A2 BB69 1652 CE79 7874 7875

To claim this, I am signing this object:

@nickgravel
nickgravel / mysql-tbl-sizes.sql
Created September 29, 2015 14:50
How To List MySQL Table Sizes in MB
-- Here’s a handy script to list your MySQL table sizes in MB.
SET @table_schema = '{YOUR_SCHEMA_NAME}'; -- replace with your schema name
SELECT table_name AS "Tables",
ROUND(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = @table_schema
ORDER BY (data_length + index_length) DESC;
@nickgravel
nickgravel / gencsr
Last active October 4, 2015 16:45
Generate a OpenSSL Private Key and CSR with SHA256 Signature for 2048 SSL Certs
#!/bin/bash
if [ -n "$1" ]
then
FILENAME=$1
else
echo "Please specify a filename. e.g. ./gencsr www.example.com" >&2
exit 1
fi