This file contains hidden or 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
Example infrastructure outage incident report | |
Friday, May 13, 2077 | |
By the Example Security Team | |
Earlier this week we experienced an outage in our API infrastructure. Today we’re providing an incident report that details the nature of the outage and our response. | |
The following is the incident report for the Example Security outage that occurred on April 30, 2077. We understand this service issue has impacted our valued developers and users, and we apologize to everyone who was affected. |
This file contains hidden or 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 asyncio | |
from dataclasses import dataclass | |
import random | |
from aiokafka import AIOKafkaConsumer, AIOKafkaProducer | |
async def consume(loop, total_events=10): | |
consumer = AIOKafkaConsumer( |
This file contains hidden or 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
var countryCodeMap = map[string]string{ | |
"BD": "Bangladesh", | |
"BE": "Belgium", | |
"BF": "Burkina Faso", | |
"BG": "Bulgaria", | |
"BA": "Bosnia and Herzegovina", | |
"BB": "Barbados", | |
"WF": "Wallis and Futuna", | |
"BL": "Saint Barthelemy", | |
"BM": "Bermuda", |
This file contains hidden or 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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
"time" | |
) | |
type MyStruct struct { |
This file contains hidden or 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
"""Efficient sliding-window sorting of time-series data in CSV file. | |
Demo for http://stackoverflow.com/a/42398981/68707 | |
Tested on Python 3.5. | |
""" | |
import collections | |
import csv | |
import datetime |
This file contains hidden or 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
conn = aiohttp.TCPConnector(verify_ssl=False, limit=5) | |
session = aiohttp.ClientSession(connector=conn, loop=loop) | |
futures = list() | |
for link in links: | |
futures.append(asyncio.ensure_future(task(session, link))) | |
await asyncio.gather(*futures) | |
concurrent.futures._base.TimeoutError |
This file contains hidden or 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
# http://codereview.stackexchange.com/questions/137898/memoization-with-factorial-in-python | |
import functools | |
def memoize(func): | |
cache = func.cache = {} | |
@functools.wraps(func) | |
def wrapper(n): | |
if n not in cache: | |
cache[n] = func(n) |
This file contains hidden or 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
redis: | |
restart: always | |
image: redis:latest | |
ports: | |
- "6379" | |
base: | |
dockerfile: Dockerfile | |
build: . | |
volumes: |
This file contains hidden or 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
# Simple way | |
from pympler import summary, muppy | |
def go(): | |
list1 = [] | |
f = 5 | |
for i in range(10000000): | |
f += 1 | |
list1.append(f) | |
go() |
This file contains hidden or 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 functools | |
def float_args_and_return(function): | |
@functools.wraps(function) | |
def wrapper(*args, **kwargs): | |
args = [float(arg) for arg in args] | |
return float(function(*args, **kwargs)) | |
return wrapper | |
@float_args_and_return |
NewerOlder