Skip to content

Instantly share code, notes, and snippets.

Jefe Johnson jeffjohnson9046

View GitHub Profile
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();
jeffjohnson9046 / settings.json
Created Jun 30, 2020
My settings.json for VS Code
View settings.json
"workbench.iconTheme": "material-icon-theme",
"workbench.startupEditor": "newUntitledFile",
"workbench.colorCustomizations": {
"editorRuler.foreground": "#1a1a1a",
// Came from snazzy.json, here:
"terminalCursor.background": "#282a36",
"terminalCursor.foreground": "#97979b",
"terminal.selectionBackground": "#97979b33",
jeffjohnson9046 / range-generator.js
Created Jun 27, 2020
A Javascript generator to generate a range of numbers
View range-generator.js
// Source:
function* range(start, end) {
yield start;
if (start === end) {
yield* range(start + 1, end);
jeffjohnson9046 /
Last active Jun 17, 2020
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 /
Last active Jun 16, 2020
Convert UUID to byte array and vice versa. Useful for when UUIDs are stored in MySQL tables as VARBINARY(16)
import java.nio.ByteBuffer;
import java.util.UUID;
public class UuidAdapter {
public static byte[] getBytesFromUUID(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
return bb.array();
jeffjohnson9046 / ant-condition-test.xml
Created Jun 11, 2020
A quick test of condition elements in ant
View ant-condition-test.xml
<project name="condition-test" default="all">
<target name="condition">
<condition property="isTomcat">
<matches pattern="^(tomcat)" string="${webContainer}" />
<condition property="isWebLogic">
<matches pattern="^(web)" string="${webContainer}" />
jeffjohnson9046 / sinatra-server.rb
Last active Jun 3, 2020
A simple sinatra server that accepts a POST with JSON content.
View sinatra-server.rb
# To make this server publicly available on the inter-webs while running from localhost, use ngrok, which can be found here:
# Follow the installation instructions for ngrok and start it up:
# ./ngrok 4567 # (or whatever port you want to listen on).
# ngrok will spit out an ugly but unique URL. After ngrok starts up, you should be able to POST to the sinatra server:
require 'sinatra'
require 'json'
jeffjohnson9046 / title-case-filter.js
Created Mar 26, 2014
A title-case filter for AngularJs
View title-case-filter.js
// Came from the comments here:
app.filter('titlecase', function() {
return function (input) {
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
input = input.toLowerCase();
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) {
if (index > 0 && index + match.length !== title.length && > -1 && title.charAt(index - 2) !== ":" &&
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
jeffjohnson9046 /
Last active May 8, 2020
use curl to check out a Spring Boot applicaion's configuration properties from a Spring Cloud Configuration service
# Occasionally I want to see the application properties that are pulled down from the Spring Cloud Config service that provides
# content to our Spring Boot apps. Since I seem to have to re-discover this every time, I figured I'd write it down to help me
# remember.
# Additional docs can be found here:
# To see the output in YML format
curl -u {the user name}:{the user password} http://{the domain:port}/{the application name}-{the spring profile name}.yml
# For example:
jeffjohnson9046 / find-foreign-keys.sql
Created May 4, 2020
Find all the foreign keys in a Postgres database.
View find-foreign-keys.sql
-- from here:
select kcu.table_schema || '.' ||kcu.table_name as foreign_table,
'>-' as rel,
rel_tco.table_schema || '.' || rel_tco.table_name as primary_table,
string_agg(kcu.column_name, ', ') as fk_columns,
from information_schema.table_constraints tco
join information_schema.key_column_usage kcu
on tco.constraint_schema = kcu.constraint_schema
and tco.constraint_name = kcu.constraint_name
You can’t perform that action at this time.