Skip to content

Instantly share code, notes, and snippets.

@genadyp
genadyp / sessionrecorder.py
Created February 4, 2020 14:37 — forked from georgevreilly/sessionrecorder.py
WSGI Middleware to record Request and Response data
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
WSGI middleware to record requests and responses.
"""
from __future__ import print_function, unicode_literals
import logging
@genadyp
genadyp / multiprocessing_generator.py
Created April 24, 2020 17:59
Share a python generator across multiple processes using multiprocessing
#!/usr/bin/env python
"""Running a generator in a multiprocessing world."""
from multiprocessing import Pipe, Process
REQUEST_GET_NEXT = '__request_next__'
REQUEST_BREAK = '__request_break__'
RESPONSE_DATA = '__response_data__'
RESPONSE_DONE = '__response_done__'
@genadyp
genadyp / System Design.md
Created May 2, 2020 18:08 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@genadyp
genadyp / docker-functions.sh
Created June 12, 2020 15:14 — forked from jcortejoso/docker-functions.sh
docker-functions.sh
#!/bin/bash
# bash wrappers for docker run commands
#
# Helper Functions
#
docker_dcleanup(){
docker rm $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}
@genadyp
genadyp / react-best-practices.md
Created September 6, 2020 06:39 — forked from cdiggins/react-best-practices.md
React Best Practices
@genadyp
genadyp / curl.md
Created September 13, 2020 16:17 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@genadyp
genadyp / Makefile
Created May 18, 2021 14:06 — forked from rochacbruno/Makefile
Python Setup Tips and Tricks http://j.mp/setup_py
.PHONY: test install pep8 release clean
test: pep8
py.test --cov -l --tb=short --maxfail=1 program/
install:
python setup.py develop
pep8:
@flake8 program --ignore=F403 --exclude=junk
@genadyp
genadyp / setup.cfg
Created May 19, 2021 15:13 — forked from althonos/setup.cfg
A `setup.cfg` template for my Python projects
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = file: {name}/_version.txt
author = Martin Larralde
author_email = martin.larralde@embl.de
url = https://github.com/althonos/{name}
description = {description}
long_description = file: README.md
@genadyp
genadyp / flask skeleton folder tree
Created May 24, 2021 08:31 — forked from efazati/Py Flask Skeleton
flask folders and files structure
.
├── deploy.py
├── project
│   ├── application.py
│   ├── apps
│   │   ├── articles
│   │   │   ├── forms.py
│   │   │   ├── __init__.py
│   │   │   ├── models.py
│   │   │   └── views.py
@genadyp
genadyp / immutabledict.py
Created June 10, 2021 08:47 — forked from glyphobet/immutabledict.py
Immutable dictionary in Python
class ImmutableDict(dict):
def __setitem__(self, key, value):
raise TypeError("%r object does not support item assignment" % type(self).__name__)
def __delitem__(self, key):
raise TypeError("%r object does not support item deletion" % type(self).__name__)
def __getattribute__(self, attribute):
if attribute in ('clear', 'update', 'pop', 'popitem', 'setdefault'):
raise AttributeError("%r object has no attribute %r" % (type(self).__name__, attribute))