Skip to content

Instantly share code, notes, and snippets.

View sblack4's full-sized avatar
:shipit:
taking care of business

Steven B sblack4

:shipit:
taking care of business
View GitHub Profile
@sblack4
sblack4 / ecs-run
Last active April 15, 2024 17:36 — forked from vcastellm/ecs-run
Run task and wait for result in AWS ECS
#!/usr/bin/env bash
set -e
function usage() {
set -e
cat <<EOM
##### ecs-run #####
Simple script for running tasks on Amazon Elastic Container Service
One of the following is required:
Required arguments:
# looops through subdirs
# look for file or symlink named Makeifle
# creates a new one
for folder in $(echo *); do
if [ -d $folder ]; then
cd $folder
# test for file
if [ -f "Makefile" ]
@sblack4
sblack4 / screw-this-sg.sh
Created March 1, 2023 16:59
Nuke a security group. Deletes all rules referencing it. you may have to turn this multiple times if there are security groups that reference your group in multiple rules
#!/bin/bash
# abbreviations refer to resource IDs
# security group = SG
# security group rule = SGR
# referencing security group = RGS
# SG to delete
SG=$1
@sblack4
sblack4 / copy-changes-from-pr.sh
Created June 28, 2022 13:27
Copy all the changes from a PR into another branch or repo
#!/bin/bash
# clone to copies of the same repo, side by side
# add this script to the repo you want to copy from
# the name of the repo you want to copy to
REPO_NAME="myrepo"
# the PR number with the modifications
PR_NUMBER="5"
@sblack4
sblack4 / cfn-terraform-backend.yaml
Created December 2, 2021 15:09
CloudFormation for creating the Terraform backend in AWS (s3 bucket, dynamodb table)
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Bootstraps Terraform S3 backend'
Parameters:
AccountId:
Type: 'String'
Description: 'Account ID of the account that will manage state in this bucket (leave blank if the state is for this AWS account)'
CreateDynamoDB:
Default: true
Type: String
@sblack4
sblack4 / file-crawler.py
Created August 26, 2021 15:52
Crawls through files and provides hooks to process name or contents
#!/usr/bin/env python3
import glob
import os.path
root_dir = ''
def filename_hook(filename):
print(filename)
@sblack4
sblack4 / magic.sql
Created June 8, 2021 18:34
insert a column with the last year of dates in it. This can be adjusted to any contiguous period but must be specified relative to the present.
insert into myschema.mytable
with ten_numbers as (select 1 as num union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9 union select 0)
,generted_numbers AS
(
SELECT (1000*t1.num) + (100*t2.num) + (10*t3.num) + t4.num-5000 as gen_num
FROM ten_numbers AS t1
JOIN ten_numbers AS t2 ON 1 = 1
JOIN ten_numbers AS t3 ON 1 = 1
JOIN ten_numbers AS t4 ON 1 = 1
@sblack4
sblack4 / nohup-yes.sh
Created June 1, 2021 20:42
nohup stdout and stder to logfile, send process to background
#!/bin/bash
[ -f nohup.log ] && rm -f nohup.log
nohup \
yes \
> nohup.log 2>&1 &
@sblack4
sblack4 / run_jmeter.sh
Last active May 4, 2021 17:02
Run Jmeter for dev and test then tar it all up
#!/bin/bash
run_datetime=`date +%F_%H-%M-%S`
test_artifacts_name="${run_datetime}/TEST"
dev_artifacts_name="${run_datetime}/DEV"
run() {
rm -rf 2021-*
mkdir -p $test_artifacts_name $dev_artifacts_name
@sblack4
sblack4 / save-sqs-queue.py
Last active August 26, 2021 15:33 — forked from fabiob/save-sqs-queue.py
Saves all messages from an AWS SQS queue into a folder, messages are TXT or JSON
#!/usr/bin/env python3
import argparse
import boto3
import json
import os
from datetime import datetime
parser = argparse.ArgumentParser(