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
# delete and re-create the latest tag on remote | |
rmtag () { | |
export TAG=$(git describe --tags --abbrev=0) | |
git tag -d $TAG | |
git tag $TAG | |
git push origin :$TAG | |
git push origin $TAG | |
} |
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
# Prerequisites: | |
# $ pip install pytest pytest-mock | |
from functools import cache | |
from unittest.mock import MagicMock, mock_open | |
import pytest | |
from pytest_mock import MockerFixture | |
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 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 |
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
# 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 |
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 timeit import timeit | |
data = [ | |
{ | |
"eventStatus": "Failure", | |
"eventType": "Archive", | |
"objectName": "W12 BO Template", | |
"time": "2022-08-23T10:09:33.092Z" | |
}, | |
{ |
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
# dataclass type validation for fields on class instantiation -and- on assignment. | |
from dataclasses import dataclass | |
from validators import TypeValidator | |
@dataclass | |
class FooDC: | |
# alternatively, like: |
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 { 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); |
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
// 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 |
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
# Note: | |
# Lock in build date on the tag (ex: 2023.03.29) - otherwise, we rebuild the | |
# entire Docker image each time a tag is updated (ex: python:3.9-x86_64) | |
# | |
# 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 (-> Image tags) | |
# Date (Timestamp) of the Image to Build |
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
Put below files in `.vscode` folder |