Skip to content

Instantly share code, notes, and snippets.

View kingnebby's full-sized avatar

King Nebby kingnebby

View GitHub Profile
@kingnebby
kingnebby / zshrc.sh
Last active May 19, 2020 15:27
add-proxies-to-your-env
# Pick a location to save your environment details
PROXY_FILE=$HOME/.my-env/proxies
# Source it so that new bash instances will pick up
# the current environment settings.
touch $PROXY_FILE
source <(cat $PROXY_FILE)
# Over-write the env file and soure it to ensure this window
# picks up the changes.
env-az-setup() {
echo "Setting Subscription: dev"
az account set --subscription umbrellaCorp-crankshaft-dev;
echo "Getting Kubectl Creds: dev"
az aks get-credentials --resource-group crankshaft-aks-dev-rg --name crankshaft-aks-dev;
# Just a helper to make sure everything got setup correctly
helm list;
}
@kingnebby
kingnebby / .bashrc.sh
Created May 20, 2020 14:42
Updated with env vars
# AZ_SUB_ENV => the azure subscription env suffix
# AZ_AKS_ENV => the azure kubernetes service env suffix
env-az-setup() {
echo "Setting Subscription: $AZ_SUB_ENV"
az account set --subscription umbrellaCorp-crankshaft-$AZ_SUB_ENV;
echo "Getting Kubectl Creds: dev"
az aks get-credentials --resource-group crankshaft-aks-$AZ_AKS_ENV-rg --name crankshaft-aks-$AZ_AKS_ENV;
helm list;
}
@kingnebby
kingnebby / .bashrc.sh
Last active May 20, 2020 14:46
env-az function
env-az() {
# Display the current entry
echo -n "az subscription env ($AZ_SUB_ENV): "
# Read the user input into a new local var
read az_sub_env;
# If the user input was NOT empty then..
if [ ! -z "$az_sub_env" ]; then;
# Save the value as the new env var
export AZ_SUB_ENV=$az_sub_env;
@kingnebby
kingnebby / .bashrc.sh
Last active May 20, 2020 14:51
Adding in the saving feature
AZ_ENV_FILE=$HOME/.my-env/umbrella-corp-env-az
touch $AZ_ENV_FILE
source <(cat $AZ_ENV_FILE)
env-az() {
#
# ... all read-from-user code that we previously wrote
#
# Can run this before calling the env-az-setup command
@kingnebby
kingnebby / popular-code-solution.js
Created November 13, 2020 16:44
Popular Code Solution
@kingnebby
kingnebby / clean-code-solution.js
Created November 13, 2020 16:45
Clean Code Solution
function humanReadable(seconds) {
let hours = getHours(seconds)
let mins = getMins(seconds - (hours * 60 * 60))
let sec = seconds - (mins * 60) - (hours * 60 * 60)
return [hours, mins, sec].map(padZerosToTensPlace).join(':')
}
function getHours(seconds) {
return Math.floor((seconds / (60 * 60)))
}
@kingnebby
kingnebby / test.js
Created November 30, 2020 16:02
Empty Jest Test
it("#getUsername() should get the username", () => {
// TBD
})
@kingnebby
kingnebby / test.js
Created November 30, 2020 16:03
Evil Jest Test
class UserModel {
async getUsername() {
return "Mullen";
}
}
it("#getUsername() should get the username", async () => {
const user = new UserModel();
const username = user.getUsername();
expect(username).toBeDefined();
});
// Logger.ts
export const LogLevel = {
INFO: 30,
DEBUG: 20,
};
export class Logger {
// default log level
level = LogLevel.INFO;