Skip to content

Instantly share code, notes, and snippets.

View prrao87's full-sized avatar

Prashanth Rao prrao87

View GitHub Profile
@prrao87
prrao87 / .zshrc
Last active December 21, 2023 20:19 — forked from ines/.zshrc
Command to activate / create Python virtual environmment
# Do not use the alias `python3`
# For this to work properly, explicitly specify the python version as necessary on your system
function venv {
default_envdir=".venv"
envdir=${1:-$default_envdir}
if [ ! -d $envdir ]; then
python3.12 -m venv $envdir
python3.12 -m pip install ruff
echo -e "\x1b[38;5;2m✔ Created virtualenv $envdir\x1b[0m"
@prrao87
prrao87 / httpx-hackernews-async-example.py
Created February 22, 2023 03:45 — forked from danielmichaels/httpx-hackernews-async-example.py
A short realworld example of how to use HTTPX's AsyncClient in a sync class.
"""
HackerNews module.
"""
import logging
import asyncio
from operator import itemgetter
import httpx
@prrao87
prrao87 / log.py
Created February 24, 2023 15:10 — forked from nguyenkims/log.py
Basic example on how setup a Python logger
import logging
import sys
from logging.handlers import TimedRotatingFileHandler
FORMATTER = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
LOG_FILE = "my_app.log"
def get_console_handler():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(FORMATTER)