Skip to content

Instantly share code, notes, and snippets.

@sector119
sector119 / config.py
Created February 20, 2024 13:01
taskiq cron scheduling with structlog and sentry middlewares
import os
from pydantic import AmqpDsn
from pydantic import BaseSettings
from pydantic import HttpUrl
from pydantic import PostgresDsn
from pydantic import RedisDsn
from . import VERSION
@usr-ein
usr-ein / Dockerfile
Last active September 12, 2024 13:50
Optimal multistaged Dockerfile for poetry
# syntax=docker/dockerfile:1
# Keep this syntax directive! It's used to enable Docker BuildKit
# Based on https://github.com/python-poetry/poetry/discussions/1879?sort=top#discussioncomment-216865
# but I try to keep it updated (see history)
################################
# PYTHON-BASE
# Sets up all our shared environment variables
################################
@imankulov
imankulov / sqlalchemy_with_pydantic.py
Last active September 19, 2024 23:53
Using pydantic models as SQLAlchemy JSON fields (convert beween JSON and pydantic.BaseModel subclasses)
#!/usr/bin/env ipython -i
import datetime
import json
from typing import Optional
import sqlalchemy as sa
from sqlalchemy.orm import declarative_base, sessionmaker
from sqlalchemy.dialects.postgresql import JSONB
from pydantic import BaseModel, Field, parse_obj_as
@michels
michels / openweather_emoji.rb
Last active June 8, 2021 21:32
Uses the OpenWeatherMap to get an emoji based on the current weather // OpenWeaterMap emoji matcher in ruby.
OPENWEATHER_APIKEY = "" # TODO add your apikey here
lat = "49.868183" # latitude of the city you want to get the weather from
lon = "8.626288499" # longitude of the city you want to get the weather from
def getWeatherEmoji(weatherID)
# Openweathermap Weather codes and corressponding emojis
thunderstorm = "\u{1F4A8}" # Code: 200's, 900, 901, 902, 905
drizzle = "\u{1F4A7}" # Code: 300's
rain = "\u{02614}" # Code: 500's