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 logging | |
| import os | |
| import shutil | |
| from datetime import datetime, timedelta | |
| import pendulum | |
| import structlog | |
| from airflow.sdk import DAG, task | |
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 random | |
| import datetime as dt | |
| from airflow.decorators import task, dag | |
| default_args = {"owner": "airflow", "start_date": dt.datetime(2024, 2, 1), "retries": 1} | |
| @task.branch() | |
| def choose_branch(): | |
| return random.choice(["task_a", "task_b"]) # Randomly chooses a branch |
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
| const std = @import("std"); | |
| const process = std.process; | |
| pub fn main() !void { | |
| var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | |
| defer _ = gpa.deinit(); | |
| const allocator = gpa.allocator(); | |
| const args = try std.process.argsAlloc(allocator); | |
| defer std.process.argsFree(allocator, args); |
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 typing as t | |
| from concurrent.futures import ThreadPoolExecutor, as_completed | |
| from functools import wraps | |
| import requests | |
| def parallelize(f: t.Callable = None, max_workers: int = 5): | |
| def decorator(func): | |
| @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
| from urllib.request import urlopen | |
| from urllib.error import HTTPError | |
| from concurrent.futures import ThreadPoolExecutor, as_completed | |
| class HttpError(Exception): | |
| def __init__(self, url: str, code: int) -> None: | |
| self.url = url | |
| self.code = code |
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 datetime as dt | |
| from urllib.parse import urljoin | |
| import requests | |
| from airflow.models import DAG | |
| from airflow.operators.python import PythonOperator | |
| default_args = { | |
| 'owner': 'airflow', |
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 requests | |
| from http import HTTPStatus | |
| import pprint | |
| class HttpError: | |
| def __init__(self, status_code: int): | |
| self.status_code = status_code | |
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 logging | |
| from logging import Handler, LogRecord | |
| from airflow.operators.python import get_current_context | |
| class RowsAffectedHandler(Handler): | |
| def emit(self, record: LogRecord) -> None: | |
| msg = self.format(record) | |
| context = get_current_context() |
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 re | |
| from operator import add, mul | |
| from functools import reduce | |
| from typing import List | |
| def multiply(iin: str, weights: List[int]) -> int: | |
| result = reduce( | |
| add, | |
| map(lambda i: mul(*i), zip(map(int, iin), weights)) |
NewerOlder