Skip to content

Instantly share code, notes, and snippets.

View antibagr's full-sized avatar
🦄
something in the way

Anthony antibagr

🦄
something in the way
View GitHub Profile
— Да?
— Алё!
— Да да?
— Ну как там с деньгами?
— А?
— Как с деньгами-то там?
— Чё с деньгами?
— Чё?
— Куда ты звонишь?
@wshayes
wshayes / poetry_dockerfile
Last active July 10, 2023 23:29
Poetry docker file that can support private git repository packages
# syntax=docker/dockerfile:experimental
FROM python:3.7-slim AS base
# ENV LANG=C.UTF-8 # Sets utf-8 encoding for Python et al
# ENV PYTHONDONTWRITEBYTECODE=1 # Turns off writing .pyc files; superfluous on an ephemeral container.
# ENV PYTHONUNBUFFERED=1 # Seems to speed things up
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
@mahenzon
mahenzon / mixar_and_factory_boy_django_demo.py
Created March 4, 2020 22:02
Demo creating fixtures for Django using mixer and Factory Boy
# myapp/models.py
from django.db import models
class MyModel(models.Model):
class Meta:
abstract = True
def __str__(self):
data = [f'{k}={v!r}' for k, v in self.__dict__.items() if not k.startswith('_')]
#!/usr/bin/env bash
CIPHERS='ALL:eNULL'
DELAY=${2:-0.1}
SERVER=${1:?usage: $0 <host:port> [delay, default is ${DELAY}s] [ciphers, default is ${CIPHERS}]}
MAXLEN=$(openssl ciphers "$CIPHERS" | sed -e 's/:/\n/g' | awk '{ if ( length > L ) { L=length} }END{ print L}')
echo Using $(openssl version).
declare -A TLSMAP=( [tls1_1]=cipher [tls1_2]=cipher [tls1_3]=ciphersuites )
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
from fastapi import FastAPI, Depends, Query
from starlette.requests import Request
from starlette.responses import JSONResponse
import starlette.status
from pydantic import BaseModel, validator
import datetime
from typing import List
from dataclasses import dataclass, field
@dmmeteo
dmmeteo / 1.srp.py
Last active June 7, 2024 14:11
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@wshayes
wshayes / conftest.py
Last active September 6, 2021 18:50
[Example conftest.py for fastapi/sqlalchemy] #fastapi #pytest
# From @euri10 -- https://gitter.im/tiangolo/fastapi?at=5cd915ed56271260f95275ac
import asyncio
import pytest
from sqlalchemy import create_engine
from sqlalchemy_utils import create_database, database_exists, drop_database
from starlette.config import environ
from starlette.testclient import TestClient
# from: https://doc.qt.io/qt-5/qtcharts-nesteddonuts-example.html
import functools
import random
from PyQt5.QtChart import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class Widget(QWidget):
@simonw
simonw / example_output.json
Created August 3, 2017 23:43
Python function for retrieving all git commits (from "git log" in the current directory) as a useful data structure
[
{
"date": "Mon Jan 23 13:03:00 2017 -0800",
"message": "Recommended by Django https://docs.djangoproject.com/en/1.10/ref/databases/#setting-sql-mode",
"title": "SET sql_mode='STRICT_TRANS_TABLES';",
"hash": "a395f401c9a6d3e8602b80ecc729d736da871f46",
"author": "Simon Willison <simonw@example.com>"
},
{
"date": "Mon Jan 23 11:37:38 2017 -0800",