Skip to content

Instantly share code, notes, and snippets.

View bsamuel-ui's full-sized avatar
🥖

Ben Samuel bsamuel-ui

🥖
View GitHub Profile
@bsamuel-ui
bsamuel-ui / executor_imap.py
Created June 12, 2019 20:01
An implementation of Executor.map that reads its inputs only on demand.
from functools import partial
from queue import SimpleQueue
def imap(exc, func, src, size=None, return_exc=False):
if size is None:
size = exc._max_workers
if size < 1:
raise ValueError("imap hang if size is less than one.")
results = SimpleQueue()
futures = {}
@bsamuel-ui
bsamuel-ui / test-ecs-cf-bug.yaml
Created March 27, 2019 15:28
Test for fix of ECS long ARN GetAttr bug in Cloudformation
AWSTemplateFormatVersion: 2010-09-09
Description: >-
A test case for the GetAttr bug with ECS's long ARNs. When this is fixed,
if you are opted in to long ARNs, the output ServiceName should be 'stack-Service-texttext'
and not equal to ClusterName.
Resources:
DummyCluster:
Type: AWS::ECS::Cluster
@bsamuel-ui
bsamuel-ui / serverless-deploy-user.yaml
Last active June 5, 2019 17:20
Cloudformation template to deploy permissions for deploying a serverless project.
AWSTemplateFormatVersion: 2010-09-09
Description: >
Constructs a managed IAM policy to deploy a serverless project.
This template assumes the stack is being deployed in the current region and account.
You can then attach this policy to other IAM objects, such as users or roles.
Based on the work done in: https://github.com/serverless/serverless/issues/1439
@bsamuel-ui
bsamuel-ui / many_uniform_plots.py
Created April 5, 2018 18:30
Run many log plots of a uniform distribution
import numpy as np
%matplotlib inline
from seaborn import tsplot
stars_planets = np.sort(0.05 + np.random.rand(100, 8), axis=1)
tsplot(np.log(stars_planets), err_style='unit_traces')
@bsamuel-ui
bsamuel-ui / test_log_name_bug.py
Last active August 24, 2017 08:56
Test if cloudformation can create stacks with CW log groups with the same name
template = '''
Resources:
LambdaLogGroup1234:
Type: "AWS::Logs::LogGroup"
Properties:
LogGroupName: !Join [ "", [ "/aws/lambda/", !Ref "AWS::StackName", "1234" ] ]
LambdaLogGroup:
Type: "AWS::Logs::LogGroup"
Properties: