Skip to content

Instantly share code, notes, and snippets.

View wattry's full-sized avatar
🎯
Grateful

wattry wattry

🎯
Grateful
View GitHub Profile
@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 / 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 / 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 / History|-101eeeda|entries.json
Last active October 30, 2023 13:21
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///Users/wattry/workspace/customerPortal/customer-portal/client/src/resources/wireless-devices/organizational/Edit.js","entries":[{"id":"vZSi.js","timestamp":1687885567661},{"id":"fHuJ.js","timestamp":1687900303088},{"id":"tCmn.js","timestamp":1687900413788},{"id":"Ral5.js","timestamp":1687900448225},{"id":"MhV9.js","timestamp":1687900491294},{"id":"6wwn.js","timestamp":1687900505994},{"id":"Kwjm.js","timestamp":1687900523985},{"id":"dsHX.js","timestamp":1687900544435},{"id":"u2ia.js","timestamp":1687900604059},{"id":"Cy15.js","timestamp":1687900711448},{"id":"s8cL.js","timestamp":1687903089837},{"id":"VkKO.js","timestamp":1687903173958},{"id":"HWh7.js","timestamp":1687903215391},{"id":"POP9.js","timestamp":1687903297984},{"id":"jO97.js","timestamp":1687903311853},{"id":"on27.js","timestamp":1687903339889},{"id":"DVWl.js","timestamp":1687903513519},{"id":"q9xW.js","timestamp":1687903583254},{"id":"R7dc.js","timestamp":1687903601677},{"id":"UDQo.js","timestamp":1687903619898},{"id
@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.