This file contains hidden or 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
| # 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: | |
| # https://shuheikagawa.com/blog/2017/05/27/memory-usage/ | |
| # | |
| # Other interesting articles: | |
| # https://docs.docker.com/engine/docker-overview/#the-underlying-technology | |
| # https://docs.docker.com/config/containers/resource_constraints/ | |
| # | |
| # These values are approximations, because according to the first article, calculating/determining available memory |
This file contains hidden or 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
| # NOTE: These steps assume that zsh is already installed | |
| # Download and install iTerm2, which can be found here: https://iterm2.com/downloads/ | |
| # Install oh-my-zsh (details and alternate installation instructions can be found here: https://github.com/ohmyzsh/ohmyzsh): | |
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
| # Install the Powerlevel9k theme for zsh (details for using the oh-my-zsh installation can be found here: https://github.com/Powerlevel9k/powerlevel9k/wiki/Install-Instructions#option-2-install-for-oh-my-zsh): | |
| git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k |
This file contains hidden or 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
| # I have several AWS profiles in my ~/.aws/config thus there are several access keys and secret keys in my | |
| # ~/.aws/credentials file. Sometimes (e.g. when using kops or kubectl) I need to have the AWS_ACCESS_KEY_ID | |
| # and AWS_SECRET_ACCESS_KEY environment variables set. There doesn't seem to be a way to use the aws cli to set these | |
| # environment variables for me, so... well... here we are. | |
| # | |
| # This script will: | |
| # * Look at the ~/.aws/credentials file for the specified profile | |
| # * Get the next two lines beneath the profile name, which are the access_key_id and secret_key respectively | |
| # * Export those two values as environment variables | |
| # |
This file contains hidden or 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 the function I created that's a wee bit less shitty than the file above. I created a file called (oddly enough) | |
| # ec2-instance-query.zsh and put it in my ~/.oh-my-zsh/custom directory. After sourcing my ~/zshrc, I have a fancy-pants | |
| # function for querying EC2 instances and ElasticIP addresses for a given IP: | |
| function ec2-instance-query() { | |
| echo "Finding EC2 information for IP $1:" | |
| for r in `aws ec2 describe-regions --output text | cut -f4 | grep "us-"` | |
| do | |
| aws ec2 describe-instances \ | |
| --region $r \ | |
| --filter "Name=network-interface.addresses.association.public-ip, Values=$1" \ |
This file contains hidden or 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 hidden or 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 hidden or 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 here: https://dataedo.com/kb/query/postgresql/list-foreign-keys | |
| 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, | |
| kcu.constraint_name | |
| 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 |
This file contains hidden or 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
| <project name="condition-test" default="all"> | |
| <target name="condition"> | |
| <condition property="isTomcat"> | |
| <matches pattern="^(tomcat)" string="${webContainer}" /> | |
| </condition> | |
| <condition property="isWebLogic"> | |
| <matches pattern="^(web)" string="${webContainer}" /> | |
| </condition> | |
| </target> |
This file contains hidden or 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
| // Source: | |
| // https://dev.to/ycmjason/how-to-create-range-in-javascript-539i | |
| function* range(start, end) { | |
| yield start; | |
| if (start === end) { | |
| return; | |
| } | |
| yield* range(start + 1, end); | |
| } |
This file contains hidden or 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
| { | |
| "workbench.iconTheme": "material-icon-theme", | |
| "workbench.startupEditor": "newUntitledFile", | |
| "workbench.colorCustomizations": { | |
| "editorRuler.foreground": "#1a1a1a", | |
| // Came from snazzy.json, here: https://github.com/Tyriar/vscode-snazzy/blob/master/snazzy.json | |
| "terminalCursor.background": "#282a36", | |
| "terminalCursor.foreground": "#97979b", | |
| "terminal.selectionBackground": "#97979b33", |