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 / .zshrc
Created July 28, 2023 00:43
.zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/peter/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
#!/usr/bin/env node
/*
This will disable all EventBridge rules for a given prefix
Steps:
- lists all rules for a given prefix
- for all rules found, disables it
example:
#!/usr/bin/env node
/*
This will migrate all tables of a database to a new S3 Bucket
Steps:
- lists all tables of a database, performs the following for each:
- list all objects at the table's storage location (S3 path)
- copies all objects found to new bucket
- updates table config with new S3 path
@pwmcintyre
pwmcintyre / list-lifecycle.sh
Created September 23, 2022 02:43
list all buckets and their lifecycle rules
#! /usr/bin/env bash
# to make this blubage easier to read ...
WHITE="97"
BOLDWHITE="\e[1;${WHITE}m"
ENDCOLOR="\e[0m"
# list buckets and loop
aws s3api list-buckets --query 'Buckets[].[Name]' --output text | while read bucket ; do
echo "${BOLDWHITE}${bucket}${ENDCOLOR}"
@pwmcintyre
pwmcintyre / marp.versent.css
Last active August 3, 2022 09:13
Versent theme for Marp
/* @theme versent */
@import 'default';
:root {
color: #FFFFFF;
background: #11333F;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfcAAAB2CAMAAADiMCrcAAAAqFBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8j1z1tAAAAN3RSTlMAR5/4uCgD/PXpFdAkbKzGj3pTLpzxaQkG4w3s2BEYG01fiXTeH8qywZiEQjbUp1hkfzM6vJM+mREr6wAADLhJREFUeNrs3OmSmkAUBeALqIC4IyIoI+K+7573f7MoJo4CipKRkKK/f6NTlFXHvngalP6tbJOY9NnNiUmf+TRHTOoUxgViUievNIhJHX08ZlM+fZpLQSUmdQ7YEJM6UygmMWnTg8gRkzZdETwxaVMTYHSISRlOA9bEpMyxBWRYdU+brQxorLqnjWoAmBKTLtk+gAWr7imTbQOsuqdO4Rw7q+5pU1gAYNU9bdzYWXVPm+wl9j2r7qmi9nEmbYlJkbkBgFX3xGhSLGYyAFbdk2PVjSN5W4NLtIlJBLM97Or0YV0JAKvuiWIDSjFPn9QTcSEPiEmKEQDDydKnNCv4g90wnyCqhBOpVDPpE6wS/hizb0EmSQUXbWebo5+WHeKEVfcE+jLwm1juZelH2QauHGISpYFvUrm6bdJP6Qk4YdU9mZpD3BKVg/1FUZnH68jIL3HGqntSzUR4tPYbLkL2nVo9c90O2C1wY0lM4iwRQB5XVqpFL8oN7Olew7Lw5++
/*
Deletes all SSM Parameters with the given prefix.
Example usage:
$ npm i @aws-sdk/client-ssm
$ AWS_PROFILE=nbos-ris-np-admin AWS_REGION=us-west-2 SSM_PATH_PREFIX=/ris/dev/1/wombatch/ npx ts-node .
*/
import { SSMClient, DeleteParametersCommand, GetParametersByPathCommand } from "@aws-sdk/client-ssm"
const Path = process.env["SSM_PATH_PREFIX"]
@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"
package main
import (
"fmt"
"io/ioutil"
"log"
"strconv"
"github.com/apache/arrow/go/v7/arrow"
"github.com/apache/arrow/go/v7/arrow/array"
// 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
@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{}{