Skip to content

Instantly share code, notes, and snippets.

@austinmcconnell
austinmcconnell / 0_reuse_code.js
Created March 27, 2014 21:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@austinmcconnell
austinmcconnell / hide-site-tagline-small-screens-minimum-pro
Created March 28, 2014 13:31
Hide Site Tagline for Small Screens in Minimum Pro
@media only screen and (max-width: 600px) {
.minimum .site-tagline{
display: none;
}
.home-featured-1,
.home-featured-2,
.home-featured-3,
.home-featured-4 {

Common Postgres Things

Create

Create new user

CREATE USER $user_name$;

CREATE USER $user_name$ WITH PASSWORD '$password$';

Create new database

CREATE DATABASE $new_db_name$;

@austinmcconnell
austinmcconnell / _upgrade_postgres
Last active November 13, 2017 16:22 — forked from chbrown/_upgrade-pg9.4-to-pg9.5.md
Upgrade PostgreSQL 9.4 to 9.5 on Mac OS X with Homebrew
First, check your current config (example output in `homebrew.mxcl.postgresql.plist.xml` lower down in this gist):
cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Most importantly, note the `-D /usr/local/var/postgres` argument.
Second, shut down your current PostgreSQL.
brew services stop postgresql
@austinmcconnell
austinmcconnell / reinitialize_git_repositories.py
Last active November 22, 2017 17:12
Simple python script to reinitialize all git repositories nested one level under a "projects" folder. Primarily this is useful to "upgrade" global hooks in a ~/.git-templates folder as git init will not overwrite any existing file.
from pathlib import Path
import subprocess
CURRENT_DIR = Path('.')
projects = sorted([x for x in CURRENT_DIR.iterdir() if x.is_dir()])
for project in projects:
print('*' * 70)
command+delete Send Hex Code: 0x15 kill line backward
command+shift+delete Send Hex Code: 0x0B kill line forward
option+delete Send Hex Code: 0x17 kill word backward
option+shift+delete Send Escape Sequence: Esc+d kill word forward
command+left Send Hex Code: 0x01 move to start of line
command+right Send Hex Code: 0x05 move to end of line
option+left Send Escape Sequence: Esc+b move word backward
option+left Send Escape Sequence: Esc+f move word forward
@austinmcconnell
austinmcconnell / create_sftp_user.txt
Created February 1, 2018 20:57
Linux helper function to create an sftp user
# usage: create_sftp_user <username>
function create_sftp_user() {
# create user
sudo adduser --disabled-password --gecos "" $1
# prevent ssh login & assign SFTP group
sudo usermod -g sftpaccess $1
sudo usermod -s /bin/nologin $1
# chroot user (so they only see their directory after login)
@austinmcconnell
austinmcconnell / statistics.sql
Created August 9, 2018 18:18 — forked from ruckus/statistics.sql
Postgres statistics queries
** Find commmonly accessed tables and their use of indexes:
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct;
Returns output like:
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct
----------------------+--------------+---------------+------------------------
schema_migrations | 817 | 0 | 0.00000000000000000000
user_device_photos | 349 | 0 | 0.00000000000000000000

Keybase proof

I hereby claim:

  • I am austinmcconnell on github.
  • I am austinmcconnell (https://keybase.io/austinmcconnell) on keybase.
  • I have a public key whose fingerprint is AD0E FDBD 8AB8 C942 B24F 45EB D10D 0D7D E28C E6C6

To claim this, I am signing this object:

@austinmcconnell
austinmcconnell / postmortem.md
Created April 24, 2019 14:31 — forked from mlafeldt/postmortem.md
Example Postmortem from SRE book, pp. 487-491

Shakespeare Sonnet++ Postmortem (incident #465)

Date

2015-10-21

Authors

  • jennifer
  • martym