This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assume the following scenario: | |
# * You have a bastion/jump server that is publicly available | |
# * You have an RDS instance that is _not_ publicly accessible, but the bastion can get to it | |
# | |
# We have this setup with some of our k8s clusters: the cluster was created via kops, which _also_ sets up a VPC, a | |
# bastion server, all that good stuff. We use a "private" network topology to minimize public access to any of the | |
# resources in the cluster. | |
# | |
# We _also_ create our RDS instances in the same VPC. The bastion and nodes get access to the RDS instance, but it isn't | |
# available to us common folk out here on the internet. That's good; we want to minimize access to the database, too. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Based on answer from here: | |
-- https://stackoverflow.com/questions/483193/how-can-i-list-all-foreign-keys-referencing-a-given-table-in-sql-server | |
SELECT | |
child.name AS child_table, | |
fk.constraint_column_id AS fk_part_no, | |
c.name AS foreign_key_column | |
FROM | |
sys.foreign_key_columns AS fk | |
JOIN | |
sys.tables child |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @RandomDate datetime | |
SELECT @RandomDate = | |
DATEADD(day, ROUND(DATEDIFF(day, '2015-01-01', '2015-12-31') * RAND(CHECKSUM(NEWID())), 0), | |
DATEADD(second, CHECKSUM(NEWID()) % 48000, '2015-01-01')) | |
/* Verify */ | |
SELECT RandomDate = @RandomDate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER [database owner name] WITH CREATEROLE ENCRYTPED PASSWORD '[database owner's password]'; | |
CREATE DATABASE [database name] OWNER [database owner name]; | |
-- connect to [database name] | |
REVOKE CREATE ON SCHEMA public FROM PUBLIC; | |
REVOKE ALL ON DATABASE [database name] FROM PUBLIC; | |
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM PUBLIC; | |
-- log in as [database owner name] to [database name] db | |
CREATE SCHEMA [schema name]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From the second answer here - this SO answer gets all the credit: | |
# https://stackoverflow.com/questions/32960857/how-to-convert-arbitrary-simple-json-to-csv-using-jq | |
# This is the filter to convert JSON to CSV output: | |
# NOTE: This filter only works on "flat" JSON; nested properties don't work with this filter as-is. | |
jq -r '(.[0] | keys_unsorted) as $keys | ([$keys] + map([.[ $keys[] ]])) [] | @csv' | |
# For example: | |
aws ec2 describe-instances \ | |
--region us-west-2 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set laststatus=2 | |
set nu | |
syntax on | |
set statusline= " clear the statusline for when vimrc is reloaded | |
set statusline+=%-3.3n\ " buffer number | |
set statusline+=%f\ " file name | |
set statusline+=%h%m%r%w " flags | |
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype | |
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 my-sso-domain.example.com:443 > 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |