Skip to content

Instantly share code, notes, and snippets.

View seandstewart's full-sized avatar

Sean seandstewart

View GitHub Profile
@seandstewart
seandstewart / sqlite_pypika_repository.py
Last active December 29, 2022 18:06
A base repository in Python using sqilte3 and pypika. Bugs and optimizations are left as an exercise to the user.
from __future__ import annotations
import contextlib
import sqlite3
from typing import Iterator, TypeVar, Generic
import pypika
_T = TypeVar("_T")
@seandstewart
seandstewart / setup-python.zsh
Last active February 27, 2024 02:11
Setup your MacOS for modern Python development (Python3.8-9, Poetry, Pyenv, Pipx, plus many the necessary system packages and compiler links)
#!/usr/bin/env zsh
###############################
# -*- Runtime -*- #
###############################
main() {
prologue
local code
local restart
@seandstewart
seandstewart / netlify.toml
Created January 7, 2020 12:58
A Netlify config with a custom build script supporting Poetry and MkDocs
[build]
publish = "site"
command = """
restore_home_cache ".cache" "pip cache" &&
restore_cwd_cache '.venv' 'python virtualenv' &&
pip3 install -q poetry &&
poetry config virtualenvs.in-project true &&
poetry install -v &&
mkdocs build -d site
"""
@seandstewart
seandstewart / mkdocs.yml
Created January 7, 2020 12:29
A MkDocs-Material configuration including custom CSS, extensions, and social links.
site_name: Sean D Stewart
site_author: Sean D Stewart
copyright: "Copyright © 2019 - 2020 Sean Stewart"
site_url: https://seandstewart.io
repo_url: https://github.com/seandstewart/website
repo_name: seandstewart/website
nav:
- index.md
- projects.md
- words.md
@seandstewart
seandstewart / hamlet.json
Created October 11, 2019 15:14
The generated out-put of parsing Shakespeare's Hamlet with iambic.
This file has been truncated, but you can view the full file.
{
"children":[
{
"node":{
"index":0,
"text":"ACT I",
"num":1,
"type":"act"
},
"children":[
@seandstewart
seandstewart / python_url_regex.py
Last active October 3, 2019 08:51
url regex regular expression pattern python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import re
"""
I developed the following regex pattern after researching popular libraries which support some form of URL type validation
for use in my own forthcoming implementation in my library, `typical`. You can see a sneak-peek of the action here:
https://github.com/seandstewart/typical/blob/schema/typic/types/url.py
The pattern is largely based upon marshmallow's regex pattern, found here:
@seandstewart
seandstewart / gunicorn-17-workers-8-cpu.md
Created June 25, 2019 21:35
aiohttp app deployed on Kubernetes with 2 Pods - 8 CPU, 17 workers each pod

GET

Deployment Req/Sec Avg. Response Time (ms) 50% 75% 90% 99% 99.9% 99.999% 100%
Gunicorn (8 CPU, 17 workers) 4623 8.417 7.7 9.5 11.8 17.8 22.8 32.49 32.5
@seandstewart
seandstewart / aiohttp-run_app-vs-gunicorn.md
Last active June 25, 2019 21:30
aiohttp Response Times - GET - 50 connections, 5000 requests

GET

Deployment Req/Sec Avg. Response Time (ms) 50% 75% 90% 99% 99.9% 99.999% 100%
aiohttp.web.run_app 4830 10.352 10.1 11.0 12.4 20.601 24.6 25.475 25.5
Gunicorn 4753 10.518 10.3 11.3 12.5 18.6 23.4 25.14 25.2

POST

| Deployment | Req/Sec | Avg. Response Time (ms) | 50% | 75% | 90% | 99% | 99.9% | 99.999% | 100% |