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
IF OBJECT_ID (N'[ts_round_base]', N'FN') IS NOT NULL | |
DROP FUNCTION ts_round_base; | |
GO | |
CREATE FUNCTION [dbo].[ts_round_base](@ts datetime, @secs_delta int) | |
RETURNS DATETIME | |
AS | |
-- ============================================= | |
-- Author: Arthur Harduim | |
-- Description: DATETIME rounding function | |
-- |
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 typing import Iterable, TypeVar | |
T = TypeVar("T") | |
def first(items: Iterable[T], pred: callable) -> T | None: | |
return next((i for i in items if pred(i)), None) |
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 import_submodules(package, recursive=True): | |
"""Import all submodules of a module, recursively, including subpackages | |
:param package: package (name or actual module) | |
:type package: str | module | |
:rtype: dict[str, types.ModuleType] | |
""" | |
if isinstance(package, str): | |
package = importlib.import_module(package) | |
results = {} |
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 pendulum import datetime | |
from airflow.decorators import dag, task | |
from platform import node | |
from typing import Optional, Callable, Sequence | |
from airflow.providers.docker.decorators.docker import _DockerDecoratedOperator | |
from airflow.decorators.base import task_decorator_factory | |
class DockerDecoratedOperator(_DockerDecoratedOperator): |
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 typing import List, Dict | |
def vaquinha(lista_de_compras: List[list], emails: List[str]) -> Dict[str, int]: | |
"""Esta função recebe uma lista de compras e uma lista de e-mails e divide de forma | |
justa o valor total da lista de compras entre os e-mails. | |
Args: | |
lista_de_compras (List[list]): | |
Lista de compras como matriz: | |
[ |
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
version: "3" | |
services: | |
sonarqube: | |
image: sonarqube | |
expose: | |
- 9000 | |
ports: | |
- "127.0.0.1:9000:9000" | |
networks: |
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 itertools import combinations | |
from functools import cache | |
NOTAS = [50, 20, 10, 5, 2] | |
@cache | |
def int_div(a, b): | |
return a // b | |
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
# Dynamically binds port 1080 on localhost to a remote ssh server. | |
# can be used as a socks 5 proxy | |
# usage ./ssh_proxy.sh user host port | |
ssh -f -N -n -D localhost:1080 -p $3 -l $1 $2 |
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
flags_bytes = ["00000000", "00000001", "00000110", "00000011", "01001100", "10001000"] | |
flags = [0, 1, 6, 3, 76, 136] | |
lsb_expected = [0, 1, 2, 1, 4, 8] | |
def naive_lsb(num): | |
for i, bit in enumerate(bin(num)[2:][::-1]): | |
if int(bit) == 1: | |
return 2**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 itertools import combinations | |
def diminishing_combinations(arr: list): | |
for i in range(len(arr)): | |
for c in combinations(arr, i): | |
if len(c) < 1: | |
continue | |
yield c | |
NewerOlder