Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
"""Helper module to calculate function execution time.""" | |
import logging | |
from functools import wraps | |
from time import perf_counter | |
from typing import Any, Awaitable, Callable, Coroutine, ParamSpec, TypeVar | |
FORMAT = "%(asctime)s %(message)s" | |
logging.basicConfig(level=logging.DEBUG, format=FORMAT) | |
logger = logging.getLogger(__name__) |
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
# | |
# Example on how to add user to the group in Python | |
# | |
import win32net | |
def add_user_to_group(domain, group, user): | |
user_group_info = { |
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
"""Flatten multy-level nested iterable.""" | |
from typing import Any, Iterable | |
def deep_flatten(data: Iterable[Any]) -> Iterable[float]: | |
def inner(data): | |
if isinstance(data, (int, float)): | |
return [data] | |
elif not data: |
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
kind: pipeline | |
name: python_code_check | |
type: kubernetes | |
steps: | |
- name: isort | |
pull: if-not-exists | |
image: python:3.10-alpine | |
depends_on: [clone] | |
commands: |
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 enum import Enum | |
class Status(str, Enum): | |
STOPPED = "STOPPED" | |
RUNNING = "RUNNING" | |
COMPLETE = "COMPLETE" | |
status = Status.RUNNING |
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
def emulated_zip(*iterables): | |
lists = [list(iterable) for iterable in iterables] | |
while all(lists): | |
yield tuple(current_list.pop(0) for current_list in lists) | |
numbers = emulated_zip(["one", "two"], [1, 2]) | |
for i in numbers: | |
print(i) | |
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 contextlib import contextmanager | |
from typing import List, Any, Iterator | |
class StringJoiner(List[str]): | |
def __init__(self, sep: str = " ", *args: str) -> None: | |
super().__init__(*args) | |
self.sep = sep | |
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 collections import Counter | |
from fractions import Fraction | |
penny = Fraction(1, 100) | |
nickel = Fraction(5, 100) | |
dime = Fraction(10, 100) | |
quarter = Fraction(25, 100) | |
usd = [penny, nickel, dime, quarter] |
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
// remove top navigation bar | |
document.querySelectorAll(".navbar").forEach(el => el.remove()) | |
// remove status bar (bottom bar) | |
document.querySelectorAll(".drip-tab-container").forEach(el => el.remove()) | |
// remove sign-in red bell | |
document.querySelectorAll(".onesignal-bell-container").forEach(el => el.remove()) | |
// remove column on the right (ads) | |
document.querySelectorAll(".col-md-7, .col-lg-4").forEach(el => el.remove()) | |
// remove chat button on the right-bottom corner | |
//document.getElementById("beacon-container-body").remove() |
NewerOlder