Skip to content

Instantly share code, notes, and snippets.

server {
listen 80;
listen 443 ssl;
server_name $server_name;
# Don't send the nginx version number in error pages and server header.
server_tokens off;
# HSTS - HTTP > HTTPS redirect
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
@ChrisSwanson
ChrisSwanson / tmux-cheatsheet.markdown
Created April 22, 2016 18:22 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ChrisSwanson
ChrisSwanson / update_containers.sh
Created May 28, 2016 21:14
Upgrade all local docker containers to latest.
for container in $(docker images | awk '{ print $1 }' | grep -v 'REPOSITORY'); do docker pull $container; done
# ping until host is up, then ssh to host.
until ping -c1 $hostname >/dev/null 2>&1; do ssh $hostname; done
@ChrisSwanson
ChrisSwanson / cloudsearch.sh
Created April 28, 2021 19:24
Cloudtrail search to JSON
#!/usr/bin/bash
# this one liner searches for a value recursively in cloudtrail logs, to output
# a json structure that can be parsed back through jq later for further slicing
# and dicing of the data.
zgrep -Rhi "$VALUE" . | jq -c '.[]' | awk '{ print $0, "\n" }' > results.json
$!/bin/bash
# if imagemagick is not installed, install it.
if ! command -v mogrify &> /dev/null
then
brew install imagemagick
fi
# convert heic files to jpg
mogrify -format jpg *.heic
@ChrisSwanson
ChrisSwanson / macos_voices.sh
Created September 14, 2021 14:58
Listen and Test Mac Voices
#!/bin/bash
# say -v ? lists the voices available
for voice in $(say -v ? | awk '{ print $1 }')
do
echo "==> ${voice}"
say -v $voice "hello this is ${voice}"
sleep 1
done
@ChrisSwanson
ChrisSwanson / aws_regions_json.sh
Created November 20, 2021 21:48
AWS Regions JSON oneliner
# requires pup, and jq to be installed
# this is likely to break based on the css selector, but a quick hack for now.
curl "https://docs.aws.amazon.com/general/latest/gr/rande.html" | pup "#w420aac12b7b9c13 > tbody > tr json{}" | jq '.[].children | { region: .[1].text, name: .[0].text} ' | sed -e '$!s/"$/",/' | sed -e 's/}/},/'
@ChrisSwanson
ChrisSwanson / dotenv_to_dockerenv.sh
Created June 1, 2022 23:45
.env to Docker ENV oneliner
#!/usr/bin/bash
cat .env | awk -F"\=" '{ print $1 }' | grep -v -e '^$' | while read line; do echo "ENV $line=\"\""; done