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 { Expose, Type, plainToClass } from 'class-transformer'; | |
import { Equals, IsString } from 'class-validator'; | |
import 'reflect-metadata'; | |
abstract class FooBar { | |
@IsString() | |
@Expose() | |
type: string; | |
} |
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
"""Parse Suncorp bank statement text and output transactions as CSV. | |
Download e-statements, copy transactions into text file, pass this | |
file as stdin, send stdout to new CSV file. | |
```shell | |
cat statement.txt | python parse-suncorp-statement.py > transactions.csv | |
``` | |
Set `ADDITIONAL_IGNORED_LINES` to exceptional extra lines to be |
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
"""Testing Python queue shutdown. | |
See https://github.com/python/cpython/issues/96471 | |
""" | |
import time | |
import queue | |
import threading | |
import traceback | |
import asyncio.queues |
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 ctypes | |
_bases = (ctypes.Structure,) | |
PyLongPointer = ctypes.POINTER( | |
type("PyLong", _bases, dict(_fields_=[ | |
("ob_base", type("PyVarObject", _bases, dict(_fields_=[ | |
("ob_base", type("PyObject", _bases, dict(_fields_=[ | |
("ob_refcnt", ctypes.c_ssize_t), | |
("ob_type", ctypes.c_void_p), | |
]))), |
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 autodocsumm | |
def make_get_doc(original): | |
def get_doc(*args, **kwargs): | |
r = original(*args, **kwargs) | |
return r or [] | |
return get_doc | |
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
"""Patch ``dataclasses`` to support optional after required fields. | |
Fields used in ``__init__`` without defaults are currently not allowed | |
after fields with defaults, due to the specification in PEP 557. This | |
patch allows these fields, but makes them required keyword-only | |
parameters to ``__init__``. | |
To apply this patch, simply import this module before defining any | |
dataclasses. | |
""" |
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 time | |
import numpy as np | |
# Setup | |
mask = np.zeros((4000, 5000), dtype=np.bool8) | |
for j in range(-50, 50): | |
for k in range(-50, 50): | |
if np.sqrt(j**2 + k**2) < 50: | |
mask[1000 + j, 2000 + k] = True | |
image = np.random.randint(0, 256, (4000, 5000, 3), dtype=np.uint8) |
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
# Licensed under the Apache License, Version 2.0 | |
# License included at https://github.com/docker/docker-py/blob/master/LICENSE | |
"""Patch Docker for Python with device-requests.""" | |
from docker.types import base as docker_types_base | |
from docker.models import containers as docker_models_containers | |
from docker.types import containers as docker_types_containers | |
from docker.utils import utils as docker_utils |