Skip to content

Instantly share code, notes, and snippets.

Avatar

King Nebby kingnebby

View GitHub Profile
@kingnebby
kingnebby / test.js
Created Nov 30, 2020
Evil Jest Test
View test.js
class UserModel {
async getUsername() {
return "Mullen";
}
}
it("#getUsername() should get the username", async () => {
const user = new UserModel();
const username = user.getUsername();
expect(username).toBeDefined();
});
@kingnebby
kingnebby / test.js
Created Nov 30, 2020
Empty Jest Test
View test.js
it("#getUsername() should get the username", () => {
// TBD
})
View clean-code-solution.js
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)))
}
View popular-code-solution.js
@kingnebby
kingnebby / .bashrc.sh
Last active May 20, 2020
Adding in the saving feature
View .bashrc.sh
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 / .bashrc.sh
Last active May 20, 2020
env-az function
View .bashrc.sh
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
Created May 20, 2020
Updated with env vars
View .bashrc.sh
# 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;
}
View .bashrc.sh
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 / zshrc.sh
Last active May 19, 2020
add-proxies-to-your-env
View zshrc.sh
# 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.