Skip to content

Instantly share code, notes, and snippets.

View tomislacker's full-sized avatar

Ben Tomasik tomislacker

View GitHub Profile
param (
[ValidateNotNullOrEmpty()]
[string] $ScriptPath,
[ValidateNotNullOrEmpty()]
[string] $TaskName
# Pass in as many arguments as you want....
)
# Setup error handling.
Trap
@tomislacker
tomislacker / rateLimitDecorator.py
Created July 17, 2019 12:51 — forked from gregburek/rateLimitDecorator.py
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
tomislacker / aws_route53_delete.sh
Created January 15, 2019 16:32 — forked from earljon/aws_route53_delete.sh
Delete a Route 53 Record Set in AWS CLI
#!/bin/sh
# NOTE:
# Make sure that the value of Name, Type, TTL are the same with your DNS Record Set
HOSTED_ZONE_ID=<YOUR_HOSTED_ZONE_ID>
RESOURCE_VALUE=<YOUR_DNS_RESOURCE_VALUE-ex:IP or dns>
DNS_NAME=<YOUR_DNS_NAME-ex: subdomain.domain.com>
RECORD_TYPE=<DNS_RECORD_TYPE-ex: A, CNAME>
TTL=<TTL_VALUE>
@tomislacker
tomislacker / all_aws_lambda_modules.txt
Created October 22, 2018 18:44 — forked from gene1wood/all_aws_lambda_modules_python.md
AWS Lambda function to list all available Python modules and post the list to Pastebin
# module list (generated by listmodules.py)
#
# 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'
#
BaseHTTPServer
Bastion
CDROM

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
tomislacker / Output
Created May 9, 2017 15:45 — forked from speshak/Output
Convert CIDR networks into string glob (like what ssh_config expects)
10.255.0.0/11
['10.224.*',
'10.225.*',
'10.226.*',
'10.227.*',
'10.228.*',
'10.229.*',
'10.230.*',
'10.231.*',
'10.232.*',