Skip to content

Instantly share code, notes, and snippets.

from enum import Enum
class Symbol(Enum):
DIGIT = 1
EXP = 2
SIGN = 3
POINT = 4
INVALID = 5
def measure(array):
spaces = len(array)
left = array.copy()
right = array.copy()
max_left = max_right = 0
for i in range(spaces):
left[i] = max_left = max(left[i], max_left)
right[spaces-i-1] = max_right = max(right[spaces-i-1], max_right)
from collections import defaultdict
def twosum(array, target):
indices = defaultdict(list)
for i, number in enumerate(array):
if number in indices:
for j in indices[number]:
yield (j, i)
user system total real
rotate: 2.813839 2.090703 4.904542 ( 4.915946)
rotate bang: 1.336530 0.001773 1.338303 ( 1.340188)
shift and append: 0.004720 0.000127 0.004847 ( 0.004881)
FROM node:8-slim
RUN apt-get update && apt-get install -y wget --no-install-recommends \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge --auto-remove -y curl \
pignataj@a45e60c7b871:~/workspace/go-lambda$ ab -c 4 -n 500 https://3fjxgk0yzk.execute-api.us-east-1.amazonaws.com/production/fast
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 3fjxgk0yzk.execute-api.us-east-1.amazonaws.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@jpignata
jpignata / amis.sh
Last active March 24, 2018 00:25
Build CloudFormation mappings for the latest ECS Optimized AMI for every Region for your account
echo "AWSRegionToAMI:"
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text)
do
echo " ${region}:"
echo -n " AMI: "
aws ec2 describe-images \
--owners amazon \
--query 'reverse(sort_by(Images[?Name != `null`] | [?contains(Name, `amazon-ecs-optimized`) == `true`], &CreationDate))[:1].ImageId' \
Access Key ID: AKIAJHGI6PW2ROGHAUDQ
Secret Access Key: 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
Access Key ID: AKIAIJB4DI3E7RRLFKYQ
Secret Access Key: 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