Skip to content

Instantly share code, notes, and snippets.

View nkhitrov's full-sized avatar
🏠
Elixir/Python Backend Developer

Nick Khitrov nkhitrov

🏠
Elixir/Python Backend Developer
View GitHub Profile
@nkhitrov
nkhitrov / install.sh
Created April 27, 2021 21:05
python virtualenv wrapper install script
pip install virtualenv virtualenvwrapper
sudo echo '# where to store our virtual envs
export WORKON_HOME=$HOME/.pythonvenvs
# where is the virtualenvwrapper.sh
source $(which virtualenvwrapper.sh)
' >> ~/.bashrc
source ~/.bashrc
from typing import Optional
import base64
from passlib.context import CryptContext
from datetime import datetime, timedelta
import jwt
from jwt import PyJWTError
from pydantic import BaseModel
#!/usr/bin/python
# A Wake on LAN program that allows you to send magic packets over the Internet
import socket, struct
class Waker():
def makeMagicPacket(self, macAddress):
# Take the entered MAC address and format it to be sent via socket
splitMac = str.split(macAddress,':')
# Pack together the sections of the MAC address as binary hex
@nkhitrov
nkhitrov / logger.py
Last active May 28, 2024 12:18
Configure uvicorn logs with loguru for FastAPI
"""
WARNING: dont use loguru, use structlog
https://gist.github.com/nkhitrov/38adbb314f0d35371eba4ffb8f27078f
Configure handlers and formats for application loggers.
"""
import logging
import sys
from pprint import pformat