Skip to content

Instantly share code, notes, and snippets.

View myarik's full-sized avatar
🇺🇦

Yaroslav Muravskyi myarik

🇺🇦
View GitHub Profile
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.
@myarik
myarik / python_kafka_examples.py
Created January 30, 2021 10:15
Kafka examples
import asyncio
from dataclasses import dataclass
import random
from aiokafka import AIOKafkaConsumer, AIOKafkaProducer
async def consume(loop, total_events=10):
consumer = AIOKafkaConsumer(
@myarik
myarik / country.go
Created March 30, 2020 14:04
Country code
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",
@myarik
myarik / struct_custom_unmarshal.go
Created March 23, 2020 09:54 — forked from miguelmota/struct_custom_unmarshal.go
Golang custom struct unmarshal function example
package main
import (
"encoding/json"
"fmt"
"log"
"time"
)
type MyStruct struct {
@myarik
myarik / sliding_window_sort.py
Created November 16, 2017 07:18 — forked from benhoyt/sliding_window_sort.py
Efficient sliding-window sorting of time-series data in CSV file (in Python)
"""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
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
# 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)
@myarik
myarik / docker_compose.yml
Created March 17, 2016 16:18
docker_compose
redis:
restart: always
image: redis:latest
ports:
- "6379"
base:
dockerfile: Dockerfile
build: .
volumes:
# Simple way
from pympler import summary, muppy
def go():
list1 = []
f = 5
for i in range(10000000):
f += 1
list1.append(f)
go()
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