Skip to content

Instantly share code, notes, and snippets.

MWM seeking Casual code Encounters

Ben Tomasik tomislacker

MWM seeking Casual code Encounters
Block or report user

Report or block tomislacker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tomislacker /
Created Jul 17, 2019 — forked from gregburek/
Rate limiting function calls with Python Decorators
import time
def RateLimited(maxPerSecond):
minInterval = 1.0 / float(maxPerSecond)
def decorate(func):
lastTimeCalled = [0.0]
def rateLimitedFunction(*args,**kargs):
elapsed = time.clock() - lastTimeCalled[0]
leftToWait = minInterval - elapsed
if leftToWait>0:
tomislacker /
Last active Jul 15, 2019
Python Nested Generators with `yield from` Syntax (>=Python.3.3)

TIL about the yield from syntax introduced in >=Python-3.3

In [6]: def f1(p): 
   ...:     yield f'{p}1' 
   ...:     yield f'{p}2' 

In [7]: def f2(): 
tomislacker /
Created May 9, 2019
Test ElasticSearch Connectivity
Simple test for checking if an EC2 instance or ECS task can access an
ElasticSearch domain. This was mainly lifted from the AWS documentation:
To use this, first the requisite libraries must be available:
$ pip install -U \
boto3 \
elasticsearch \
requests \
tomislacker /
Last active Apr 4, 2019
Python logging Module Not Showing All Levels
  • Inspired by this gist.
  • Supporting documentation
  • I made a new gist because I wanted to have a more complete example that compared what happens without using that solution versus using it.
tomislacker /
Created Jan 15, 2019 — forked from earljon/
Delete a Route 53 Record Set in AWS CLI
# Make sure that the value of Name, Type, TTL are the same with your DNS Record Set
tomislacker / all_aws_lambda_modules.txt
Created Oct 22, 2018 — forked from gene1wood/
AWS Lambda function to list all available Python modules and post the list to Pastebin
View all_aws_lambda_modules.txt
# module list (generated by
# timestamp='20160226T200954Z'
# sys.version='2.7.10 (default, Dec 8 2015, 18:25:23) \n[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]'
# sys.platform='linux2'
# platform='Linux-4.1.13-19.31.amzn1.x86_64-x86_64-with-glibc2.2.5'
tomislacker /
Last active Jul 25, 2018
Find Unused Security
find_all_groups ()
aws ec2 describe-security-groups \
--query 'SecurityGroups[*].GroupId' \
--output text \
| tr '\t' '\n' \
| sort -u
tomislacker / vpc.ipynb
Created Jul 10, 2018
VPC Network Designer
View vpc.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:60803e9e0082d05c431d117f897d89c6

How to create a publicly-accessible SNS topic that sends messages when objects are added to a public Amazon S3 bucket.

1. Create something within AWS that triggers notifications.

In this case, that's an S3 bucket that is continually updated by the addition of new sensor data. For the purposes of this tutorial, we’ll use s3://noaa-nexrad-level2 – one of our NEXRAD on AWS buckets – as an example.

2. Create an SNS topic and appropriate policy.

The SNS topic should be in the same region as the bucket. It will need to have a policy that allows our S3 bucket to publish to it, and anyone to subscribe to it using Lambda or SQS.

tomislacker / elasticache_benchmarking.ipynb
Last active May 4, 2018
Benchmarking ElastiCache (Redis) Bandwidth Performance
View elasticache_benchmarking.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.