#!/usr/bin/env bash
# Added bash strict mode.
set -euo pipefail
# Remove old golang versions.
whereis go | xargs -n1 sudo rm -rf
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 argparse | |
import functools | |
import another | |
def tag(*name): | |
def outer(func): | |
func.tag = name | |
@functools.wraps(func) |
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
#!/bin/python3 | |
import toml | |
import subprocess | |
import sys | |
class UpdateDeps: |
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
""" Classes and metaclasses for easier ``__slots__`` handling. """ | |
from itertools import tee | |
import dis | |
__version__ = "2021.1.6" | |
__all__ = ("Slots",) | |
def self_assignemts(method) -> set: |
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
"""Simple FIFO queue with Redis to run tasks asynchronously. | |
=========== | |
Description | |
=========== | |
This script implements a rudimentary FIFO task queue using Redis's list data | |
structure. I took a peek under Celery and RQ's source code to understand how | |
they've implemented the async task queue — harnessing the features of Redis and | |
Python's multiprocessing paradigm. |
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
"""Custom logger with colorized output. | |
MODULE_NAME: LINE_NUMBER: LOG_LEVEL: LOG_MESSAGE | |
Usage | |
====== | |
from common.logger import logger | |
logger.debug(f"{__name__}: This is a debug message.") | |
logger.info(f"{__name__}: This is an info message.") |
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
#!/bin/bash | |
docker-compose down | |
# Remove dangling images (-q=quiet, -f=without prompt) | |
docker rmi $(docker images -q -f dangling=true) | |
# Remove all stopped containers | |
docker rm -v $(docker ps -a -q -f status=exited) |
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 Dict, Any | |
class Engine: | |
def __init__(self, name: str, sound: str) -> None: | |
self.name = name | |
self.sound = sound | |
def noise(self) -> str: | |
return f"Engine {self.name} goes {self.sound}!" |
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 | |
class PrefixMeta(type): | |
def __new__(cls, name, bases, attrs): | |
try: | |
prefix = attrs["Config"].prefix | |
except (KeyError, AttributeError): | |
prefix = None | |
if prefix: |
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 functools import singledispatchmethod | |
from typing import List, TypeVar | |
T = TypeVar("T") | |
class Process: | |
@singledispatchmethod | |
def _process(self, arg: T) -> None: |