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
jeffjohnson9046 / jquery-deferred-promise-example.js
Last active Feb 4, 2019
A quick example of how to use deferred and promise in jquery
View jquery-deferred-promise-example.js
// jsfiddle: https://jsfiddle.net/Lkxtryvp/1/
var myAwesomeLoop = function(x) {
// This is the magic sauce right here - you're creating a unit of work that will be done at some
// point in the future. We're not exactly sure when, but the deferred object will notify us when
// it's done (by calling "resolve()" or "reject()" on itself).
var deferred = $.Deferred();
// We'll create a simple loop to concatenate some values together. This simulates where the
// actual, for-real work would be done (e.g. an AJAX request, some sort of long-running calculation, etc)
@jeffjohnson9046
jeffjohnson9046 / curl-cloud-config-props.sh
Last active Jan 16, 2019
use curl to check out a Spring Boot applicaion's configuration properties from a Spring Cloud Configuration service
View curl-cloud-config-props.sh
# 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: https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html
# 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
jeffjohnson9046 / kops-export-config.sh
Last active May 24, 2019
How to update kubectl to see a new Kubernetes cluster
View kops-export-config.sh
# This is something that I always forget and had a surprisingly hard time finding (or better yet, understanding). Here's the
# scenario: a colleague creates a new kubernetes cluster, named" cluster-foo.example.com". You want to look at it (for
# troubleshooting, updating the deployment, whatever). To get your kubectl installation to "see" the new cluster, take the
# following steps:
# ASSUMPTION: You have pointed kops to some location where the cluster configurations are stored
# (I have this in my ~/.bash_profile):
export KOPS_STATE_STORE=s3://example-state-store
# Use kops to get the list of clusters
View mysql-find-text-in-sp.sql
SELECT
*
FROM
INFORMATION_SCHEMA.ROUTINES
WHERE
ROUTINE_DEFINITION LIKE '%My Text%'
ORDER BY ROUTINE_NAME;
View sql-server-process-monitoring.sql
-- From this article: https://logicalread.com/troubleshoot-high-cpu-sql-server-pd01/#.WW_hjtPytuY
-- Show CPU Utilization by SQL Server, system idle time and other processes
DECLARE @ms_ticks_now BIGINT
SELECT @ms_ticks_now = ms_ticks
FROM sys.dm_os_sys_info;
SELECT TOP 15 record_id
,dateadd(ms, - 1 * (@ms_ticks_now - [timestamp]), GetDate()) AS EventTime
,SQLProcessUtilizationPercent
@jeffjohnson9046
jeffjohnson9046 / spring-cli-encryption-setup.sh
Last active Apr 7, 2018
How I set up my Mac for encrypting values using Spring on the command line
View spring-cli-encryption-setup.sh
# Install the Spring Boot CLI via homebrew (https://brew.sh/)
brew update
brew tap pivotal/tap
brew install springboot
# Download the Java 8 JCE from here: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
# Extract the .zip file somewhere. There should be three files:
#
# local_policy.jar
# README.txt
@jeffjohnson9046
jeffjohnson9046 / mysql-convert-varbinary-to-uuid.sql
Last active Feb 21, 2017
functions for converting a UUID stored as VARBINARY(16) into its UUID form and vice versa
View mysql-convert-varbinary-to-uuid.sql
/*
* From here: http://mysql.rjweb.org/doc.php/uuid
*/
-- Convert a formatted UUID to a BINARY(16)
CREATE FUNCTION UuidToBin(_uuid CHAR(36))
RETURNS BINARY(16)
LANGUAGE SQL DETERMINISTIC CONTAINS SQL SQL SECURITY INVOKER
RETURN
UNHEX(CONCAT(
SUBSTR(_uuid, 15, 4),
@jeffjohnson9046
jeffjohnson9046 / cli-prompt.sh
Last active Apr 12, 2017
Command prompt that shows current git branch
View cli-prompt.sh
GREEN='\[\033[0;32m\]'
YELLOW='\[\033[0;33m\]'
NC='\[\033[0m\]' # No Color
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
@jeffjohnson9046
jeffjohnson9046 / mysql-foreign-key-reference-lookup.sql
Created Jan 6, 2017
MySQL - Identify other tables that reference a table by a foreign key constraint
View mysql-foreign-key-reference-lookup.sql
SELECT *
FROM information_schema.KEY_COLUMN_USAGE
WHERE table_schema = /* the schema you're interested in */
AND referenced_table_name = /* name of the table that is referenced by other tables via foreign key */;
@jeffjohnson9046
jeffjohnson9046 / uuid-to-varbinary-16.sql
Created Nov 16, 2016
MySQL - Generate a UUID and convert it to VARBAINARY(16) for storage
View uuid-to-varbinary-16.sql
SELECT UNHEX(REPLACE(UUID(),'-',''))
You can’t perform that action at this time.