This file contains 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
{"lastUpload":"2020-08-20T20:27:31.107Z","extensionVersion":"v3.4.3"} |
This file contains 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 os | |
import pymysql | |
from DBUtils.PooledDB import PooledDB | |
from dotenv import load_dotenv | |
MYSQL_CONFIG = { | |
"host": "localhost", | |
"port": 3306, | |
"db": "test_db", |
This file contains 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
# Welcome to Jekyll! | |
# | |
# This config file is meant for settings that affect your whole blog. | |
# | |
# If you need help with YAML syntax, here are some quick references for you: | |
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml | |
# https://learnxinyminutes.com/docs/yaml/ | |
title: Redowan's Digressions | |
description: Sporadic cogitations on software, tech & personal beliefs |
This file contains 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 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 | |
---------- |
This file contains 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 time | |
from concurrent.futures import ThreadPoolExecutor | |
from functools import wraps | |
import requests | |
from tqdm import tqdm | |
def timeit(method): | |
@wraps(method) |
This file contains 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
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" | |
This file contains 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 | |
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 file contains 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 json | |
import os | |
import sys | |
from datetime import timedelta | |
import httpx | |
import redis | |
from dotenv import load_dotenv | |
from fastapi import FastAPI | |
from asgiref.sync import sync_to_async |
This file contains 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
""" | |
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 file contains 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
""" | |
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, |
OlderNewer