Skip to content

Instantly share code, notes, and snippets.

View adilkhash's full-sized avatar
:octocat:
0 ⇢ 1

Adylzhan Khashtamov adilkhash

:octocat:
0 ⇢ 1
View GitHub Profile
import logging
import os
import shutil
from datetime import datetime, timedelta
import pendulum
import structlog
from airflow.sdk import DAG, task
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
@adilkhash
adilkhash / iin_validation.zig
Last active January 3, 2025 08:34
Validation of IIN of Kazakhstan
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);
import time
from multiprocessing import Process, Value
from multiprocessing import Pool
def sum_numbers(numbers):
result = 0
for number in numbers:
result += number
return result
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)
@adilkhash
adilkhash / exception_groups.py
Created October 25, 2022 08:54
Python 3.11 Exception Groups
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
@adilkhash
adilkhash / external_dag_rest_api_trigger.py
Created October 31, 2021 16:31
Trigger external dag via Airflow REST API
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',
import requests
from http import HTTPStatus
import pprint
class HttpError:
def __init__(self, status_code: int):
self.status_code = status_code
@adilkhash
adilkhash / airflow_rows_affected.py
Last active March 14, 2021 17:39
Apache Airflow Rows Affected Catcher
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()
@adilkhash
adilkhash / iin_validation.py
Created September 7, 2020 06:46
Валидация ИИН/БИН Республики Казахстан
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))