Skip to content

Instantly share code, notes, and snippets.

View wattry's full-sized avatar
🎯
Grateful

wattry wattry

🎯
Grateful
View GitHub Profile
@wattry
wattry / Git manual
Last active January 30, 2018 13:57
Git manual
GIT(1) Git Manual GIT(1)
NAME
git - the stupid content tracker
SYNOPSIS
git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
@wattry
wattry / validateControl.js
Last active October 5, 2018 12:27
JS function to enable and disable inputs as the previous was filled
function validateRelationshipForm(inputs) {
for (i = 0; i < (inputs.length - 2); i+=2) {
if (inputs[i].value.length > 0) {
inputs[i + 1].disabled = false;
if (inputs[i + 1].type == "button") {
inputs[i + 1].classList = ("btn btn-success");
}
} else {
inputs[i + 1].disabled = true;
if (inputs[i + 1].type == "button") {
@wattry
wattry / notification-manager.js
Created January 11, 2019 13:59
A simple Bootstrap alert/notification manager
/*
* A simple notification manager to handle Bootstrap alerts.
*/
/**
*
* @param {String} selector a jQuery element selector
* @param {String} alertClass success|info|danger a Bootstrap alert class.
* @param {String} message a message to be displayed in the bootstrap alert.
* @param {Boolean} append should this message should append or replace the current message.
@wattry
wattry / DockerAliases
Last active February 14, 2019 19:35
A .bash_profile entry to create aliases for docker commands
# Docker Aliases
# Print all docker aliases
alias dkra='echo -e "1. impa=image prune \n2. pspa=container prune \n3. imra=image rm \$(images -aq) \n4. psra=container rm \$(ps -aq) \n5. pssa=container stop \$(ps -aq) \n6. pska=pssa && psra"'
alias dc='docker-compose'
alias impa='docker image prune'
alias pspa='docker container prune'
alias imra='docker image rm $(docker images -aq)'
alias psra='docker container rm $(docker ps -aq)'
@wattry
wattry / txt
Created January 4, 2018 15:49
Docker Cheatsheet
# Images
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker image ls -a # List all images on this machine
docker image rm <image id> # Remove specified image from this machine
docker image rm $(docker image ls -a -q) # Remove all images from this machine
docker image prune # remove dangling images
docker tag <image> username/repository:tag # Tag <image> for upload to registry
docker push username/repository:tag # Upload tagged image to registry
docker run username/repository:tag # Run image from a registry
@wattry
wattry / groupBy.js
Last active December 4, 2020 18:01
Group arrays by key using Array.prototype.reduce in Javascript
/**
* Groups an array of objects by a key an returns an object or array grouped by provided key.
* @param array - array to group objects by key.
* @param key - key to group array objects by.
* @param removeKey - remove the key and it's value from the resulting object.
* @param outputType - type of structure the output should be contained in.
*/
const groupBy = (
inputArray,
key,
@wattry
wattry / Array.prototype.filterMap.js
Created February 24, 2021 20:16
A function to filter an array and map the result in one call.
Array.prototype.arrayMap = function(callback) {
const newData = [];
for (let i = 0; i < this.length; i++) {
const entry = callback(this[i]);
if (entry !== null && entry !== undefined) {
newData.push(entry);
}
}
@wattry
wattry / ldapts-client.js
Created December 23, 2021 00:13
Bare bones implementation of an ldapts client and binds using SASL
import fs from 'fs';
import ldapts from 'ldapts';
import AWS from 'aws-sdk';
import fs from 'fs';
const LDAP_HOST_CONST = "ldaps://my.ldap.server.com";
// You chose your flavor for fetching secrets, this covers from disk or AWS secret manager.
async function bindFromFile(): void {
const {
@wattry
wattry / terrafrom-destroy.sh
Last active March 15, 2022 14:59
Gitlab bash script to destroy a feature branch
script:
# Try clone the branch, if it does not exist then try clone dev.
- |
REPO_URL="https://gitlab-ci-token:${CI_JOB_TOKEN}@code.vt.edu/${CI_PROJECT_PATH}.git"
RED="\033[31m"
BOLD="\033[1m"
GREEN="\033[32m"
echo $TF_ROOT
# Try clone the branch that was stopped if we can't then clone dev and do the destory.
@wattry
wattry / README.md
Last active December 1, 2022 19:18
Running oracle instant client on Mac M1 ARM chipset

Installing Node

Ensure you have completely removed any versions of node you have. This is very important espciatlly if you have used brew to install. If you have downloaded the .pkg file from node.

Installing Rosetta 2

Rosetta is going to interpret the x86_64 binaries to ARM so you'll need to install this.

softwareupdate --install-rosetta