Skip to content

Instantly share code, notes, and snippets.

@af-inet
af-inet / fix_file_extensions.py
Last active March 4, 2020 13:06
rename files to their inferred extension
import os
import os.path
import glob
import argparse
try:
import filetype
except ImportError as e:
print('missing package "filetype", try running:')
print("pip install filetype")
@af-inet
af-inet / ecr-delete-untagged.py
Last active February 22, 2019 16:30
delete untagged images from ecr
#!/usr/bin/env python
#
# https://boto3.readthedocs.io/en/latest/reference/services/ecr.html
#
import argparse
import json
import boto3
client = boto3.client("ecr")
@af-inet
af-inet / create-credstash-table.py
Created January 24, 2019 17:14
Create a credstash table with the appropriate attributes.
import json
import argparse
import boto3
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('name', action='store', type=str, help='name of the credstash table you would like to create')
args = parser.parse_args()
return args
@af-inet
af-inet / ld-find.py
Created January 2, 2019 16:25
find libraries in your ld path (linux)
#!/usr/bin/env python
import os
import os.path
import argparse
DEFAULT_LIBRARY_PATH = "/usr/lib/x86_64-linux-gnu"
LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", DEFAULT_LIBRARY_PATH)
@af-inet
af-inet / delete-facebook-posts.js
Created December 27, 2018 09:50
delete all your facebook posts
/*
HOW TO USE THIS PROGRAM
1. Log in to facebook, and go to your "Activity Feed".
2. Scroll down a little bit so you have posts on the screen.
3. Paste this code into the developer console.
4. Execute deletePost() in the console.
5. Done; watch as the bot will delete roughly 1 post every 4 seconds.
6. Refresh the page to disable the script.
*/
@af-inet
af-inet / routevpn.py
Created May 24, 2018 17:10
Create routes from an AWS VPC to a Virtual Private Gateway.
#!/usr/bin/env python
#
# https://boto3.readthedocs.io/en/latest/reference/services/ec2.html
#
import argparse
import boto3
client = boto3.client("ec2")
@af-inet
af-inet / watch-dynamodbstream.py
Last active September 5, 2022 05:44
A working example of DynamoDB Stream usage.
#!/usr/bin/env python
#
# A working example of DynamoDB Stream usage.
#
# Given a DynamoDB table name, this script will go find the first shard in the first stream and
# perform 1 iteration every 10 seconds. Resulting records will be dumped to stdout.
#
import argparse
import time
import boto3
@af-inet
af-inet / routetables.py
Created February 24, 2018 20:33
AWS create routes for a peering connection between 2 VPCs
#!/usr/bin/env python
#
# https://boto3.readthedocs.io/en/latest/reference/services/ec2.html
#
import argparse
import boto3
client = boto3.client("ec2")