This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import gzip | |
import io | |
import typing as ty | |
if ty.TYPE_CHECKING: | |
from collections.abc import Iterable, Iterator | |
DEFAULT_BLOCK_SIZE = 512 * 1024 # 512 KiB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vmType: "vz" | |
arch: "default" | |
images: | |
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. | |
- location: "https://cloud-images.ubuntu.com/releases/23.04/release-20230829/ubuntu-23.04-server-cloudimg-arm64.img" | |
arch: "aarch64" | |
digest: "sha256:5316a0dc05d83b6aad277b338ec67837792d0d695db1b736a59c8117114b8deb" | |
- location: "https://cloud-images.ubuntu.com/releases/23.04/release-20230829/ubuntu-23.04-server-cloudimg-amd64.img" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vmType: "vz" | |
arch: "default" | |
images: | |
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. | |
- location: "https://cloud-images.ubuntu.com/releases/23.10/release-20231011/ubuntu-23.10-server-cloudimg-arm64.img" | |
arch: "aarch64" | |
digest: "sha256:78d35a2f551d281912ee7e5202660d94d713aa1b5de86a17e261328cc2f093d4" | |
- location: "https://cloud-images.ubuntu.com/releases/23.10/release-20231011/ubuntu-23.10-server-cloudimg-amd64.img" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import logging | |
import pickle | |
import typing as t | |
from contextlib import contextmanager | |
from random import random | |
from django.conf import settings | |
from celery import Task |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import contextlib | |
import enum | |
import hashlib | |
import typing as t | |
from django.apps import apps | |
from django.db import models, transaction, connection, OperationalError, InternalError | |
from psycopg2 import sql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
field = [...] # NxM matrix | |
not_visited = {(x, y) for x in range(N) for y in range(M)} | |
def test_acceptance(x, y): | |
return field[x][y] == 1 and (x, y) in not_visited | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import typing as t | |
from datetime import timedelta | |
from django.views.decorators.cache import cache_page | |
from django.views.decorators.vary import vary_on_cookie, vary_on_headers | |
from django.views.generic import View | |
__all__ = ( | |
"CachedView", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import EnumMeta, Enum | |
__all__ = ['ChoiceEnum'] | |
class ChoiceEnumMeta(EnumMeta): | |
def __iter__(cls): | |
return ((tag.value, tag.name) for tag in super().__iter__()) | |
@property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Union, Collection | |
from django.contrib.postgres.search import SearchVector, SearchQuery | |
from django.db.models.expressions import BaseExpression | |
from django_filters import rest_framework as filters | |
from django_filters.constants import EMPTY_VALUES | |
class FullTextSearchFilter(filters.CharFilter): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import methodcaller | |
from django.utils.functional import cached_property | |
from typing import Union | |
class ContextDefaultValue: | |
""">>> field = serializers.HiddenField( | |
>>> default=ContextDefaultValue("some_context_attr") | |
>>> )""" | |
NewerOlder