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 time import time | |
import hmac | |
import hashlib | |
import uuid | |
def get_authorization_header(key: str) -> str: | |
nonce = 'YOUR_NONCE_PREFIX' + str(uuid.uuid4()) | |
authorization = "key=" + key + ",timestamp=" + str(int(time())) + ",nonce=" + nonce | |
return authorization |
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: | |
postgres: | |
image: postgres:13.2 | |
ports: | |
- 5432:5432 | |
environment: | |
POSTGRES_USER: example | |
POSTGRES_PASSWORD: example |
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' | |
x-airflow-common: | |
&airflow-common | |
image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.0.1-python3.8} | |
environment: | |
&airflow-common-env | |
AIRFLOW__CORE__EXECUTOR: CeleryExecutor | |
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow | |
AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://airflow:airflow@postgres/airflow |
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
import aiohttp | |
import nest_asyncio | |
nest_asyncio.apply() | |
from random import randint | |
class HttpClient: | |
def __init__(self, session, concurrency): | |
self.__session = session | |
self.concurrency = asyncio.Semaphore(concurrency) |
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
import aiohttp | |
import asyncio | |
from airflow.decorators import dag, task | |
from airflow.operators.python import task | |
from datetime import date, datetime, timedelta | |
async def async_main(): | |
async with aiohttp.ClientSession() as session: | |
async with session.get('http://httpbin.org/get') as resp: |
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 of sending MS Teams Notifications on DAG failure (Airflow 2.0.0+) | |
import requests | |
from airflow.decorators import dag, task | |
from airflow.operators.python import task, get_current_context | |
from airflow.utils.dates import days_ago | |
from airflow.models import DagRun | |
# from airflow.models import Variable |
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 another/image:example | |
# Credits to https://stackoverflow.com/a/64062083 | |
# some dockerfile commands... | |
ENV JAVA_FOLDER java-se-8u41-ri | |
ENV JVM_ROOT /usr/lib/jvm | |
ENV JAVA_PKG_NAME openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz | |
ENV JAVA_TAR_GZ_URL https://download.java.net/openjdk/jdk8u41/ri/$JAVA_PKG_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
<sequence name="ExternalAuth" statistics="enable" trace="enable" xmlns="http://ws.apache.org/ns/synapse"> | |
<property expression="$axis2:REST_URL_POSTFIX" name="originalResource" scope="default" type="STRING"/> | |
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/> | |
<property name="BLOCKING_SENDER_PRESERVE_REQ_HEADERS" value="false"/> | |
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="POST"/> | |
<callout initAxis2ClientOptions="false" serviceURL="https://api.external.example/auth?token=abcdefg"> | |
<source type="envelope"/> | |
<target key="response"/> | |
</callout> | |
<property expression="$trp:Set-Cookie" name="setCookieHeader" scope="default" type="STRING"/> |
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
# Credentials must be passed in through environment variables (DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME) | |
variables: | |
DOCKER_DRIVER: overlay2 | |
GIT_STRATEGY: fetch | |
PGPASSWORD: "$DB_PASS" | |
services: | |
- docker:19.03.8-dind | |
stages: |
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
#!/bin/bash | |
awk '(NR == 1) || (FNR > 1)' file_*.csv > files.csv |