Skip to content

Instantly share code, notes, and snippets.

View gene1wood's full-sized avatar
🎩

Gene Wood gene1wood

🎩
View GitHub Profile
@gene1wood
gene1wood / delete_all_s3_bucket_files
Created April 29, 2021 00:51
Command to delete all objects from S3 bucket using lifecycle configuration
for bucket in `cat list-of-s3-buckets.txt`; do
aws s3api put-bucket-lifecycle \
--bucket $bucket \
--lifecycle-configuration '{"Rules":[{"ID":"cleanup","Status":"Enabled","Prefix":"","Expiration":{"Days":1}}]}';
done
@gene1wood
gene1wood / peertube-cannot-retrieve-oauth-client-credentials-undefined-clien-invalid-fix.md
Created February 26, 2021 04:08
Fix for the peertube error "Cannot retrieve OAuth Client credentials: undefined" and "client invalid"

I deployed Peertube via Docker but did not use the included nginx docker container and instead put Peertube behind an Apache httpd reverse proxy.

I was getting the error : Cannot retrieve OAuth Client credentials: undefined when loading the peertube page and the error client invalid when attempting to log in.

The cause was that I wasn't passing the host header through Apache because I was missing the ProxyPreserveHost On directive.

I added this and resolved the issue

@gene1wood
gene1wood / bugzillarc-for-use-at-Mozilla
Created February 24, 2021 19:49
The ~/.config/python-bugzilla/bugzillarc file to use for bugzilla.mozilla.org
[DEFAULT]
url = https://bugzilla.mozilla.org/xmlrpc.cgi
[bugzilla.mozilla.org]
api_key = xxxxxxxxxxxxxxx
@gene1wood
gene1wood / postfix-debconf-get-selections.txt
Last active April 15, 2021 07:09
postfix debconf-get-selections using myhost.example.com as an example domain name
# Internet protocols to use:
# Choices: all, ipv6, ipv4
postfix postfix/protocols select all
# System mail name:
postfix postfix/mailname string myhost.example.com
# Add a 'mydomain' entry in main.cf for upgrade?
postfix postfix/mydomain_warning boolean
# Correct tlsmgr entry in master.cf for upgrade?
postfix postfix/tlsmgr_upgrade_warning boolean
# Root and postmaster mail recipient:
#!/bin/bash -x
if [ -n "$2" ]; then
percent="$2"
else
percent=0
fi
camera="$(v4l2-ctl --list-devices | grep -A1 "$1" | tail -1 | awk '{print $1}')"
$(v4l2-ctl -d "$camera" -l | awk '$1 == "white_balance_temperature" {print "export "$5" "$6}')
(( range = max - min ))
@gene1wood
gene1wood / thick-graph-paper.md
Created September 8, 2020 03:43
Thick graph paper
@gene1wood
gene1wood / ngrok-flask-redirect-https.md
Created September 8, 2020 01:27
How to configre ngrok and flask to redirect to https
@gene1wood
gene1wood / example-aws-api-gateway-lambda-proxy-mode-event.json
Created July 30, 2020 20:46
Example Lambda event from API Gateway in Proxy mode
{
"resource": "/{proxy+}",
"path": "/post",
"httpMethod": "POST",
"headers": {
"accept": "*/*",
"Authorization": "Bearer REDACTED",
"content-type": "application/x-www-form-urlencoded",
"Host": "myapi.example.com",
"User-Agent": "curl/7.58.0",
@gene1wood
gene1wood / apply_mozilla_ciphersuites_to_elb.py
Last active July 30, 2020 17:43
A 2015 script to apply the old cipersuite settings to AWS ELBs
#!/usr/bin/env python
# Apply recommendation from https://wiki.mozilla.org/Security/Server_Side_TLS
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Contributors:
# Gene Wood [:gene]
@gene1wood
gene1wood / .person_api.sh
Created July 20, 2020 19:56
Small script to get users from CIS
export person_api_client_id=xxx
export person_api_client_secret=xxx
if [ -z "$person_api_bearer_token" ]; then
echo "Fetching bearer token"
export person_api_bearer_token=$(curl --silent --request POST --url https://auth.mozilla.auth0.com/oauth/token --header "Content-Type: application/json" --data "{\"client_id\":\"${person_api_client_id}\",\"client_secret\":\"${person_api_client_secret}\",\"audience\":\"api.sso.mozilla.com\",\"grant_type\":\"client_credentials\"}" | jq -r '.access_token')
fi
function url_quote {
echo $1 | python3 -c "import urllib.parse; print(urllib.parse.quote(input()))"
}
function get_auth0_user {