I hereby claim:
- I am rednafi on github.
- I am rednafi (https://keybase.io/rednafi) on keybase.
- I have a public key ASDO_V0OZ4SXdN3KCubDf2LC6PkT_uLYCxqjhn7LYeGpSQo
To claim this, I am signing this object:
import logging | |
import time | |
from functools import partial, wraps | |
def retry(func=None, exception=Exception, n_tries=5, delay=5, backoff=1, logger=False): | |
"""Retry decorator with exponential backoff. | |
Parameters | |
---------- |
ENV_STATE="dev" # or prod | |
DEV_REDIS_HOST="127.0.0.1" | |
DEV_REDIS_PORT="4000" | |
PROD_REDIS_HOST="127.0.0.2" | |
PROD_REDIS_PORT="5000" | |
import asyncio | |
import time | |
async def square_func(n: int) -> int: | |
await asyncio.sleep(2) | |
print(f"square_func sleeping for 2 seconds") | |
return n * n | |
""" | |
This can be used as a template to execute Proxy | |
design pattern with Python. | |
* Get the json response from PostMan API | |
url: https://postman-echo.com/get?foo1=bar_1&foo2=bar_2 | |
* Print the header properties | |
* Print the argument properties |
""" | |
This is a self contained custom data structure with dict like | |
key-value storage capabilities. | |
* Can store the key-value pairs in any sqlalchemy supported db | |
* Employs thread safe transactional scope | |
* Modular, just change the session_scope to use a different db | |
* This example uses sqlite db for demonstration purpose | |
The code is inspired by Raymond Hettinger's talk `Build powerful, |
I hereby claim:
To claim this, I am signing this object:
from os.path import expanduser | |
import pandas as pd | |
import paramiko | |
import pymysql | |
from paramiko import SSHClient | |
from sshtunnel import SSHTunnelForwarder | |
home = expanduser("~") | |
mypkey = paramiko.RSAKey.from_private_key_file(home + pkeyfilepath) |
from dataclasses import dataclass | |
from functools import singledispatchmethod | |
from typing import List, TypeVar | |
T = TypeVar("T") | |
class Process: | |
@singledispatchmethod | |
def _process(self, arg: T) -> None: |
from dataclasses import dataclass | |
class PrefixMeta(type): | |
def __new__(cls, name, bases, attrs): | |
try: | |
prefix = attrs["Config"].prefix | |
except (KeyError, AttributeError): | |
prefix = None | |
if prefix: |
from typing import Dict, Any | |
class Engine: | |
def __init__(self, name: str, sound: str) -> None: | |
self.name = name | |
self.sound = sound | |
def noise(self) -> str: | |
return f"Engine {self.name} goes {self.sound}!" |