This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import boto3 | |
client = boto3.client('ecs', region_name='us-east-1') | |
used_tds = {re.match(r'arn:aws:ecs:us-east-1:667583086810:task-definition/([\w-]+):\d+$', | |
s['taskDefinition'] | |
).group(1) | |
for c in client.list_clusters()['clusterArns'] | |
for s in | |
client.describe_services(cluster=c, services=client.list_services(cluster=c)['serviceArns'])['services'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script analyses logs data copied from kibana to reconstruct | |
the history of a single key storing JSON on S3. | |
It prints out the first value of the key, followed by coloured diffs | |
between consecutive values. To use the script: | |
Open kibana | |
Open Network tab in Chrome console | |
Search for the following in kibana: | |
"'Key': 'key_here'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def attr_to_arg(func): | |
""" | |
This is stupid and I love it. | |
Basically instead of calling: | |
foo("thing", stuff) | |
You can call: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from bdb import Bdb | |
from traceback import print_stack | |
class Tracker(Bdb): | |
""" | |
Debugger which looks for a given value by identity in local variables of all frames | |
it comes across. When it finds it and the given condition function called with the value | |
is true, prints out a stack trace and stops tracing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script iterates through all your SQS queues (based on your default | |
AWS credentials), shows you a few helpful attributes, and asks if you want | |
to delete it. It's meant as an easy way to clean out old queues that are | |
no longer needed. | |
Requires boto3 (pip install boto3). | |
The names of queues are derived from their URLs which are assumed to have | |
a common prefix: replace the 12345 in the URL below. If you don't know what |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import random | |
from urllib.request import urlopen | |
lines = urlopen( | |
"https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english-no-swears.txt" | |
) | |
words = list({ | |
line.decode("utf8").strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Box(str): | |
def __new__(cls, s): | |
lines = s.split("\n") | |
width = max(len(line) for line in lines) | |
top_bottom = '-' * width | |
return super().__new__(cls, box_template.format( | |
top_bottom=top_bottom, | |
middle="\n".join(f"| {line:{width}} |" for line in lines))) | |
def __add__(self, other): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice | |
marks = map(unichr, range(768, 879)) | |
string = 'clear the current exception in between your catch and the bare raise OH GOD NO EVENTLET IT COMES' | |
words = string.split() | |
print(' '.join(''.join(c + ''.join(choice(marks) | |
for _ in range(i // 2 + 1) | |
) * c.isalnum() | |
for c in word) | |
for i, word in enumerate(words))) |