Skip to content

Instantly share code, notes, and snippets.

View aspen-roller's full-sized avatar

James Roller, Jr. aspen-roller

View GitHub Profile
@aspen-roller
aspen-roller / .bashrc
Last active December 3, 2020 18:58
default devcontainer dotfiles #vscode #devcontainer #ref
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@aspen-roller
aspen-roller / snippet.sh
Created December 2, 2020 17:14
remove _id from mongoexport dump #mongo
// dump.json is the result of a mongoexport using --jsonArray
cat dump.json | sed '/"_id":/s/"_id":[^,]*,//' > new-dump.json
// Regex for global replace
"_id":{[^,]+,
@aspen-roller
aspen-roller / example-xarg.sh
Created December 3, 2020 18:47
xarg one command's output to another #util
# list files on a remote machine
# make empty local files using those filenames
#
# -n1 execute for each line
# -I alias for the output of the piped command
ssh swarm4 ls /srv/mssql/backup | xargs -n1 -I {} touch srv/mssql/backup/{}
@aspen-roller
aspen-roller / .bashrc
Created December 3, 2020 18:48
WSL Ubuntu-18.04 default bashrc #ref
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
@aspen-roller
aspen-roller / create-certificate.sh
Created December 3, 2020 18:49
create localhost self-signed certificate #ssl
# valid for 365 days
# ref: https://letsencrypt.org/docs/certificates-for-localhost/
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") \
-days 365
# https://containo.us/blog/traefik-2-tls-101-23b4fbee81f1/
# add to ca-certificates
@aspen-roller
aspen-roller / update-docker-compose.sh
Created December 3, 2020 18:50
update docker-compose #docker #util
# docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0-rc3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
@aspen-roller
aspen-roller / node-commands.sh
Created December 3, 2020 18:53
Node.js docker-compose #nodejs #docker
# Assumptions
# node_modules installed under /opt
# application installed under /opt/app
# Simple Build Commands
docker image build -t ultimate:dev --target dev .
docker image build -t ultimate:test --target test . # update below for MICROSCANNER
docker image build -t ultimate:prod --target prod .
# MUST pass ARGs as --build-arg
@aspen-roller
aspen-roller / file-to-string.sh
Created December 3, 2020 18:55
read multiline file as string #util
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' zscaler.pem
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' zscaler.pem | sed "s/^/\"/;s/$/\"/"
@aspen-roller
aspen-roller / my-snippets.json
Created December 3, 2020 19:07
vscode snippets #vscode
{
/*
// Place your snippets for JavaScript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
*/
"New Module": {
"prefix": "newmod",
@aspen-roller
aspen-roller / toggle.sh
Created December 3, 2020 19:09
toggle azure vms #azure #util
# resource group is set to "dev-roller"
# OFF (deallocated)
az vm deallocate --ids $(az vm list -g dev-roller --query "[].id" -o tsv)
# ON
az vm start --ids $(az vm list -g dev-roller --query "[].id" -o tsv)