- Create a file that will be your global
.gitignore
, for example~/.gitignore
; - Set
core.excludesFile
in git config
git config --global core.excludesFile ~/.gitignore
- Add the settings below to the global settings file
{
[alias] rr = !git branch --show-current | xargs -I{} git reset --hard origin/{} |
from django.db.models import Model, Q | |
from django.db.models.functions import Length | |
def max_length(field: str, model: Model) -> int: | |
return getattr( | |
model.objects.filter(~Q(**{field: None})) | |
.annotate(**{f"{field}_length": Length(field)}) | |
.order_by(f"{field}_length") | |
.last(), |
from typing import Generic, TypeVar | |
VT = TypeVar("VT") | |
ET = TypeVar("ET") | |
class Matchable: | |
__match_args__ = ("__match_self_prop__",) | |
@property |
from typing import Iterator | |
def sieve(n: int) -> Iterator[int]: | |
def _sieve(xs: Iterator[int]) -> Iterator[int]: | |
if head := next(xs, None): | |
yield head | |
yield from _sieve(x for x in xs if x % head != 0) |
from typing import Iterator | |
def sieve(n: int) -> Iterator[int]: | |
if n < 2: | |
return | |
primes = [True for _ in range(n + 1)] | |
for p in range(2, n + 1): |
diagonalDifference :: [[Int]] -> Int | |
diagonalDifference arr = abs . sum $ differences | |
where | |
differences = map (\(i, row) -> (row !! i) - (row !! (len - 1 - i))) (enumerate arr) | |
len = length arr | |
enumerate = zip [0 ..] |
from __future__ import annotations | |
from abc import abstractmethod | |
from typing import TypeVar, Protocol | |
class Comparable(Protocol): | |
"""Protocol for annotating comparable types.""" | |
@abstractmethod |
import setuptools | |
setuptools.setup( | |
name="example-pkg", | |
version="0.0.1", | |
author="Example Author", | |
author_email="author@example.com", | |
description="A small example package", | |
packages=setuptools.find_packages(), |
[[package]] | |
name = "certifi" | |
version = "2020.12.5" | |
description = "Python package for providing Mozilla's CA Bundle." | |
category = "main" | |
optional = false | |
python-versions = "*" | |
[[package]] | |
name = "chardet" |