View Dockerfile
This file contains 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
# Refs: | |
# - https://github.com/peterheb/rembg-lambda/issues/1#issue-1621934443 | |
# - https://docs.aws.amazon.com/lambda/latest/dg/python-image.html | |
# - https://gallery.ecr.aws/lambda/python | |
FROM --platform=linux/amd64 public.ecr.aws/lambda/python:3.9-x86_64 | |
LABEL maintainer="My Team" | |
ARG PYPI_URL | |
ARG PYPI_USER |
View ts-compile.ts
This file contains 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
// TypeScript code to programatically run the equivalent of `tsc` | |
// | |
// With Slight modifications, such as *Colorized* output being displayed. | |
// | |
// However, the nice one-line Error Summary that `tsc` gives you (e.g. Errors in X files) is currently missing. | |
// | |
// Refs: | |
// - https://github.com/microsoft/TypeScript-wiki/blob/main/Using-the-Compiler-API.md | |
// - https://github.com/Microsoft/TypeScript/issues/6387#issuecomment-169739615 |
View cleanupEmptyFolders.ts
This file contains 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 { readdirSync, rmdirSync, statSync } from 'node:fs'; | |
import { basename, join } from 'node:path'; | |
export const cleanupEmptyFolders = ( | |
folder: string, | |
exclude: string[] = ['node_modules'] | |
) => { | |
if (!statSync(folder).isDirectory()) return; | |
const folderName = basename(folder); |
View validate_test_1.py
This file contains 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
# dataclass type validation for fields on class instantiation -and- on assignment. | |
from dataclasses import dataclass | |
from validators import TypeValidator | |
@dataclass | |
class FooDC: | |
# alternatively, like: |
View dump_json_to_term.py
This file contains 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 timeit import timeit | |
data = [ | |
{ | |
"eventStatus": "Failure", | |
"eventType": "Archive", | |
"objectName": "W12 BO Template", | |
"time": "2022-08-23T10:09:33.092Z" | |
}, | |
{ |
View main.py
This file contains 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
# See comment below for an explanation of what this script is testing! | |
from dataclasses import dataclass, is_dataclass | |
from timeit import timeit | |
@dataclass | |
class A: | |
a: int = 10 |
View json_field_remapping.py
This file contains 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 dataclasses import dataclass | |
from .remappers import Alias, remapper # see module `remappers.py` below | |
@dataclass | |
class DiveSpot(metaclass=remapper): | |
id: str = Alias('_id') | |
name: str = Alias('divespot') | |
# stub to satisfy external linters and type checkers |
View conftest.py
This file contains 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
# Prerequisites: | |
# $ pip install pytest pytest-mock | |
from functools import cache | |
from unittest.mock import MagicMock, mock_open | |
import pytest | |
from pytest_mock import MockerFixture | |
View git repush tag
This file contains 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
1. While still on any branch | |
git tag -d v1.1 | |
2. Create the tag again: This will "move" the tag to point to your latest commit on that branch | |
git tag v1.1 | |
3. Delete the tag on remote |
View trim_space.py
This file contains 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 re | |
import string | |
from time import time | |
def main(): | |
# Rust version run with `--release` (for reference), using `only_one_string` from here: | |
# https://stackoverflow.com/a/71864244/10237506 | |
# trim_whitespace: 30ms |
NewerOlder