Skip to content

Instantly share code, notes, and snippets.

View pwmcintyre's full-sized avatar
🥑
golang fever

Peter McIntyre pwmcintyre

🥑
golang fever
View GitHub Profile
@pwmcintyre
pwmcintyre / purge.py
Last active September 23, 2022 02:28
purge an s3 bucket of all it's contents, including all object versions
#!/usr/bin/env python
# $ nohup python3 ./purge.py foo-bucket &
import sys
import boto3
# Take the bucket name from command line args
BUCKET = sys.argv[1]
s3 = boto3.resource('s3')
@pwmcintyre
pwmcintyre / makefile
Created November 18, 2020 04:40
start AWS Xray local
xray:
cd /tmp \
&& [ -d "./xray" ] || ( \
curl -O https://s3.dualstack.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-macos-3.x.zip \
&& unzip -d xray aws-xray-daemon-macos-3.x.zip \
) \
&& cd xray \
&& ./xray_mac -o -n us-west-2
@pwmcintyre
pwmcintyre / 1-README.md
Last active April 15, 2021 00:46
bulk purge AWS CloudFromation stacks

Simple Stack Purge

Install

npm i

Run

@pwmcintyre
pwmcintyre / 1 - usage.md
Last active July 13, 2021 11:19
promisify a NodeJS http createServer for testing
# create a test server with canned responses
const server: TestServer = new TestServer(new Response(500, payload), new Response(200, payload))

# wait for it to start
const url = await server.ready()

# use it
fetch(url).then(async res => console.log(await res.json()), console.error)
import { STSClient, GetCallerIdentityCommand } from '@aws-sdk/client-sts';
new STSClient({})
.send(new GetCallerIdentityCommand({}))
.then(console.log)
@pwmcintyre
pwmcintyre / clone-tables.ts
Created January 21, 2022 03:49
clone all AWS Glue tables to another database
import { Glue } from 'aws-sdk'
const glue = new Glue()
const SourceDatabaseName = "tmp"
const TargetDatabaseName = "ris-reporting"
// begin async
;(async () => {
@pwmcintyre
pwmcintyre / equal_test.go
Created March 10, 2022 09:20
Do not rely on map order
package equal_test
import (
"testing"
)
func TestMapOrder(t *testing.T) {
for i := 0; i < 100; i++ {
a := map[string]interface{}{
// Example usage:
// $ npm i @aws-sdk/client-glue
// $ DATABASE_NAME=example-database npx ts-node ./purge.ts
import * as AWS from "@aws-sdk/client-glue"
const client = new AWS.Glue({})
const DatabaseName = process.env['DATABASE_NAME']
// begin async
package main
import (
"fmt"
"io/ioutil"
"log"
"strconv"
"github.com/apache/arrow/go/v7/arrow"
"github.com/apache/arrow/go/v7/arrow/array"
@pwmcintyre
pwmcintyre / main.go
Last active May 13, 2022 05:43
list s3 directory by depth
// usage:
// $ AWS_PROFILE=foo AWS_REGION=us-east-1 go run . example-bucket 3
package main
import (
"context"
"fmt"
"log"
"os"
"strconv"