Skip to content

Instantly share code, notes, and snippets.

@FredLackeyOfficial
FredLackeyOfficial / ncu-update-all.sh
Created March 14, 2017 20:39
Use npm-check-updates recursively to update Node modules and Bower components.
cmd_exists() {
command -v "$1" &> /dev/null
}
ncu-update-all(){
if ! cmd_exists "ncu"; then
printf "ncu is required, please install it!\n"
exit 1
fi
@FredLackeyOfficial
FredLackeyOfficial / eod.sh
Last active February 7, 2020 01:42
Push EOD changes to Git
#!/bin/bash
CUR_DIR=$(pwd)
echo "Committing end of day changes ..."
for i in $(find . -name ".git" | cut -c 3-); do
echo "";
echo "Committing $i ...";
@FredLackeyOfficial
FredLackeyOfficial / setup-docker.sh
Last active April 11, 2020 14:16
Setup Docker on Linux
#!/bin/bash
# curl https://gist.githubusercontent.com/FredLackeyOfficial/d993aa52fbd2795bf39e9226db572dba/raw/setup-docker.sh | sudo bash
# bash <(curl -Ls https://gist.githubusercontent.com/FredLackeyOfficial/d993aa52fbd2795bf39e9226db572dba/raw/setup-docker.sh)
sudo apt remove docker docker-engine docker.io
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
@FredLackeyOfficial
FredLackeyOfficial / defaults-file.json
Last active June 15, 2022 00:19
Merge a simple JSON object with a more complex version to ensure defaults are always included (even if empty).
{
"parentIdentifier": "ROOT",
"name": "",
"protocol": "",
"parameters": {
"port": "",
"read-only": "",
"swap-red-blue": "",
"cursor": "",
"color-depth": "",
@FredLackeyOfficial
FredLackeyOfficial / update-route53-contacts.sh
Created August 6, 2022 10:45
AWS CLI syntax to update all Route 53 domains with the same contact
# Step 1 of 2: Export Contact Info
export CONTACT_INFO="FirstName=Fred,LastName=Lackey,ContactType=PERSON,AddressLine1=PO Box 6066,City=Live Oak,State=FL,CountryCode=US,ZipCode=32060,PhoneNumber=+1.4073743733,Email=fred.lackey@gmail.com"
# Step 2 of 2: Run command
aws route53domains list-domains --profile fredlackey | jq -r '.Domains' | jq -r '.[].DomainName' | while read DOMAIN; do \
eval "aws route53domains update-domain-contact --profile fredlackey --domain $DOMAIN --admin-contact \"$CONTACT_INFO\" --registrant-contact \"$CONTACT_INFO\" --tech-contact \"$CONTACT_INFO\""; sleep 10;
done;
# Format for the contact info blob:
# FirstName=string,LastName=string,ContactType=string,OrganizationName=string,AddressLine1=string,AddressLine2=string,City=string,State=string,CountryCode=string,ZipCode=string,PhoneNumber=string,Email=string,Fax=string,ExtraParams=[{Name=string,Value=string},{Name=string,Value=string}]
@FredLackeyOfficial
FredLackeyOfficial / generate-combinations.js
Created November 5, 2023 15:49
Simple JavaScript method to return all possible combinations from a given array.
const generateCombinations = (arr, length) => {
if (length === 0) return [[]];
if (arr.length === 0 || length > arr.length) return [];
if (length === 1) return arr.map(item => [item]);
const combinations = [];
for (let i = 0; i < arr.length; i++) {