Skip to content

Instantly share code, notes, and snippets.

@Bahus
Bahus / gunicorn
Created August 26, 2012 21:29 — forked from suda/gunicorn
Gunicorn init.d script (debian/ubuntu)
#!/bin/sh
### BEGIN INIT INFO
# Provides: gunicorn
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the gunicorn server
# Description: starts gunicorn using start-stop-daemon
# -*- coding: utf-8 -*-
from ansible.callbacks import display
from pprint import pformat
class FilterModule(object):
def filters(self):
return {
'shell_printer': self.shell_printer,
@Bahus
Bahus / json_schemed_field.py
Last active February 28, 2025 10:07
Django JSONField with Pydantic schema support
from functools import partial
import pydantic
import logging
from django.contrib.postgres.fields import JSONField
from typing import Type, Union, Tuple
from django.core.serializers.json import DjangoJSONEncoder
from http import HTTPStatus
import pytest
def browser_client(request):
user_name = request.param
credentials = get_credentials_for_user(user_name)
client = Client()
client.login(**credentials)
client.user = user_name
[tool.flakehell.plugins]
pycodestyle = [
"+*",
"-W503", # line break before binary operator
]
"flake8-docstrings" = ["-*"]
"flake8-*" = [
"+*",
"-S311", # Using random for cryptographic purposes
"-S101", # Assert detected
@Bahus
Bahus / tasks.py
Last active August 1, 2022 15:19 — forked from mihalt/tasks.py
planning of architecture
from decimal import Decimal
import pydantic
@shared_task
def get_provider_api_stocks(api_key, url_constructor, deserialize_constructor):
# api_key в принципе нельзя передавать так
return True
@Bahus
Bahus / main.py
Created March 5, 2026 21:43
Бенчмарки SQLAlchemy
"""
Бенчмарк SQLAlchemy (psycopg/asyncpg) через PgBouncer и прямой Postgres.
Переменные окружения (обязательные):
PGBOUNCER_DSN_NO_PREPARED — DSN к PgBouncer без prepared statements
PGBOUNCER_DSN_PREPARED — DSN к PgBouncer с включёнными prepared statements
POSTGRES_DSN_DIRECT — DSN напрямую к Postgres
Формат DSN: postgresql+psycopg://user:password@host:port/dbname
или postgresql+asyncpg://user:password@host:port/dbname
@Bahus
Bahus / customkeys.txt
Created March 7, 2026 15:35 — forked from francislavoie/customkeys.txt
Warcraft 3 Custom Grid Hotkeys
/////////////////////////////////////////////////////
// Customized for Lefthanded Keyboard Alignment (QWEASZ)
// Simply place this Customkeys.txt file into your WC3
// folder usually under Documents or Program Files then
// in the game options Enable Custom Keyboard Shortcuts
///////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
// This Custom Keys setup aligns all races units, heroes,