Skip to content

Instantly share code, notes, and snippets.

Jefe Johnson jeffjohnson9046

Block or report user

Report or block jeffjohnson9046

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jeffjohnson9046 /
Created Jan 14, 2020
Steps I took to set up my Z shell prompt the way I like
# NOTE: These steps assume that zsh is already installed
# Download and install iTerm2, which can be found here:
# Install oh-my-zsh (details and alternate installation instructions can be found here:
sh -c "$(curl -fsSL"
# Install the Powerlevel9k theme for zsh (details for using the oh-my-zsh installation can be found here:
git clone ~/.oh-my-zsh/custom/themes/powerlevel9k
jeffjohnson9046 /
Created Oct 19, 2019
Get the currently used and maximum available memory for a Docker container running in Kubernetes
# These commands demonstrate how to determine how much memory is availble on a k8s worker node and how much memory is
# available to the k8s _container_ hosted on that node.
# Source:
# Other interesting articles:
# These values are approximations, because according to the first article, calculating/determining available memory
jeffjohnson9046 /
Last active Aug 8, 2019
Create a SAML keystore for SSO
# Create a password-protected keystore. Change the -keypass value to a password that meets your password policy. LastPass (or some other password generator) can come in handy here for creating a password.
keytool -genkeypair -alias my-service-provider -keypass password -keyalg RSA -keysize 2048 -keystore my-sso-keystore.jks
# Use openssl to get the identity provider's public key as a file named sso.crt.
openssl s_client -connect > sso.crt
# Open the sso.crt file in any editor and remove everything around the BEGIN and END lines. If required, concatenate with any intermediate certificates.
vi sso.crt
# When done editing, the file should look similar to this:
jeffjohnson9046 / .psqlrc
Last active Aug 3, 2019
A .psqlrc file gathered from various sources, for use with PostgreSQL
View .psqlrc
-- Set client encoding
\encoding UTF8
\set QUIET 1
-- print 'NULL' (instead of a blank) for any columns that have a null value
\pset null 'NULL'
-- Do not automatically commit after every statement
jeffjohnson9046 /
Last active Jul 30, 2019
Rename files/directories so that the first letter is upper-case on OS X
# Assume you have a directory structure that looks something like this:
ls -alh /path/to/my/directory
drwxr-xr-x 38 jeffjohnson staff 1.2K Jul 18 11:07 ./
drwxr-xr-x 6 jeffjohnson staff 192B Jun 23 15:00 ../
drwxr-xr-x 10 jeffjohnson staff 320B Aug 28 2017 foo/
drwxr-xr-x 12 jeffjohnson staff 384B Dec 18 2017 bar/
drwxr-xr-x 11 jeffjohnson staff 352B Feb 26 2018 baz/
-rw-r--r-- 1 jeffjohnson staff 1.8M Aug 14 2017 some-update.sql
# list continues...
jeffjohnson9046 / .mongrc.js
Created Jun 27, 2019
A prompt for the mongo shell that displays the user you're logged in as and the database you're pointed at.
View .mongrc.js
Set the mongo shell prompt to display [user name]@[database name]. If the user or database name cannot
be captured, then display "<none>" instead.
var prompt = function() {
var user = db.runCommand({connectionStatus : 1}).authInfo.authenticatedUsers[0].user || "<none>";
var dbLabel = db.getName() || "<none>";
return user + "@" + dbLabel + ">";
# From here:
# First, make sure you have everything locally:
$ git fetch --all --tags --prune
# Show the local branches a commit is on (the "b4f8b91" is the first 7 characters of the commit hash):
$ git branch --contains b4f8b91
* feature/ast-3975
jeffjohnson9046 /
Created Apr 8, 2019
Replace UTF-8 "extended" characters with ASCII equivalents
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import io
Input file might look something like this:
cat input.txt
some ñ thing
foo ñññ
jeffjohnson9046 / mvc-add-msg-to-validation-summary.js
Last active Nov 15, 2018
How to programmatically add an error message to the MVC ValidationSummary
View mvc-add-msg-to-validation-summary.js
// Set up an associative array for the error messages. The keys must be the exact name of the
// controls that need to have the error message displayed.
var errorArray = {
SomeProperty: "'SomeProperty' has shit the bed",
SomeOtherProperty: "Whoa - TWO errors? You are up the creek"
// Show the errors next to their associated controls
jeffjohnson9046 / kill-all-connections-to-db.sql
Created Jun 18, 2018
How to kill all connections to a Postgres database
View kill-all-connections-to-db.sql
-- Accepted answer from here:
SELECT pg_terminate_backend(
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '[your database name goes here]'
AND pid <> pg_backend_pid();
You can’t perform that action at this time.