Skip to content

Instantly share code, notes, and snippets.

Avatar
🎲

Redowan Delowar rednafi

🎲
View GitHub Profile
View settings.py
"""
Django settings for main project.
Generated by 'django-admin startproject' using Django 4.0.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
View find_fk_relationship_of_entity.md
WITH foreign_keys
     AS (SELECT conname,
                conrelid,
                confrelid,
                Unnest(conkey)  AS CONKEY,
                Unnest(confkey) AS CONFKEY
         FROM   pg_constraint
@rednafi
rednafi / arch.md
Last active Nov 4, 2021
Django Init Model for Bro
View arch.md

Directory Structure

.
├── app             # I know this app name sucks.
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   └── __init__.py
│   ├── __init__.py
│   ├── admin.py
View Epiphanies.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rednafi
rednafi / asyncio_limit_concurrency.py
Last active Apr 18, 2021
Python Asyncio MRE scripts.
View asyncio_limit_concurrency.py
import asyncio
import httpx
MAX_CONSUMERS = 50
async def make_request(url):
async with httpx.AsyncClient(http2=True) as client:
response = await client.get(url)
@rednafi
rednafi / execute_tagged.py
Created Apr 12, 2021
Run a tagged function in python
View execute_tagged.py
import argparse
import functools
import another
def tag(*name):
def outer(func):
func.tag = name
@functools.wraps(func)
View go.md

Update & Installation

#!/usr/bin/env bash

# Added bash strict mode.
set -euo pipefail

# Remove old golang versions.
whereis go | xargs -n1 sudo rm -rf
@rednafi
rednafi / update.py
Last active Feb 14, 2021
Update python poetry dependencies
View update.py
#!/bin/python3
import toml
import subprocess
import sys
class UpdateDeps:
View add_slot.py
""" Classes and metaclasses for easier ``__slots__`` handling. """
from itertools import tee
import dis
__version__ = "2021.1.6"
__all__ = ("Slots",)
def self_assignemts(method) -> set:
@rednafi
rednafi / redis_queue.py
Last active Dec 25, 2020
Simple FIFO queue with Redis to run tasks asynchronously in Python.
View redis_queue.py
"""Simple FIFO queue with Redis to run tasks asynchronously.
===========
Description
===========
This script implements a rudimentary FIFO task queue using Redis's list data
structure. I took a peek under Celery and RQ's source code to understand how
they've implemented the async task queueharnessing the features of Redis and
Python's multiprocessing paradigm.