Skip to content

Instantly share code, notes, and snippets.

@tgardiner
tgardiner / dnsoverhttps.md
Last active April 23, 2022 18:23
DNS over HTTPS with cloudflared on macOS

DNS over HTTPS with cloudflared on macOS

The instructions on Cloudflare's website are confusing and incomplete.

  1. Install cloudflared:

     brew install cloudflare/cloudflare/cloudflared
    
  2. Create the configuration file:

Keybase proof

I hereby claim:

  • I am tgardiner on github.
  • I am tgardiner (https://keybase.io/tgardiner) on keybase.
  • I have a public key ASBuUKVmJx8SqFsVjCGkVaZdc7xpI-XHdflK9nTBLgeQrQo

To claim this, I am signing this object:

@tgardiner
tgardiner / api_gateway_block_crawler_wildcards.json
Created January 13, 2019 03:01
API Gateway Resource Policy to block Web Crawlers with wildcards
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:{REGION}:{ACCOUNT_ID}:{API_NAME}/*"
},
{
@tgardiner
tgardiner / api_gateway_block_crawlers.json
Created January 13, 2019 02:57
API Gateway Resource Policy to block Web Crawlers
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:{REGION}:{ACCOUNT_ID}:{API_NAME}/*"
},
{
@tgardiner
tgardiner / aws_s3_etag_local_compare.py
Created January 13, 2019 02:52
Compare AWS S3 Etag to local file
#!/usr/bin/env python3.6
import os
import sys
from hashlib import md5
from argparse import ArgumentParser
parser = ArgumentParser(description='Compare an S3 etag to a local file')
parser.add_argument('inputfile', help='The local file')
parser.add_argument('etag', help='The etag from s3')
args = parser.parse_args()
@tgardiner
tgardiner / s3_default_partsizes.py
Created January 13, 2019 02:47
AWS S3 Default Partsizes
partsizes = [ ## Default Partsizes Map (bytes)
8388608, # aws_cli/boto3
15728640, # s3cmd
factor_of_1MB(filesize, num_parts) # Used by many clients to upload large files
]
@tgardiner
tgardiner / calc_etag.py
Last active January 13, 2019 02:54
Calculate AWS S3 Etag for local file
def calc_etag(inputfile, partsize):
md5_digests = []
with open(inputfile, 'rb') as f:
for chunk in iter(lambda: f.read(partsize), b''):
md5_digests.append(md5(chunk).digest())
return md5(b''.join(md5_digests)).hexdigest() + '-' + str(len(md5_digests))
#!/bin/bash
##
## Statically Compile SSH
## See https://github.com/andrew-d/static-binaries for more binaries
##
set -e
set -o pipefail
set -x