Skip to content

Instantly share code, notes, and snippets.

@boxysean
boxysean / airflow.cfg
Created December 17, 2015 16:33
DAG that crashes Airflow scheduler quickly
# airflow.cfg
[core]
airflow_home = /opt/titan/airflow
dags_folder = /opt/titan/airflow/dags
s3_log_folder = None
executor = CeleryExecutor
sql_alchemy_conn = mysql://airflow:airflow@mysql/airflow
parallelism = 32
dag_concurrency = 16
@boxysean
boxysean / slack.py
Last active December 4, 2020 18:47
PythonSlackOperator -- how I've integrated notifications into my PythonOperators
# airflow/plugins/slack.py
import logging
from airflow.operators.python_operator import PythonOperator
from airflow.plugins_manager import AirflowPlugin
from slackclient import SlackClient
from titan.utils import config
@boxysean
boxysean / 100.py
Created December 22, 2016 15:31
To get you started with problem A...
import fileinput
def main():
for line in fileinput.input():
i, j = [int(x) for x in line.split()]
# beware the min and max!
low = min(i, j)
high = max(i, j)
print('%d %d %d' % (i, j, solve(low, high)))
@boxysean
boxysean / 787.py
Created December 22, 2016 15:43
To get you started with B...
import fileinput
def solve(sequence):
pass
def main():
sequence = []
for line in fileinput.input():
for word in line.split():
@boxysean
boxysean / a-adam.py
Last active December 22, 2016 16:53
Solutions to Warby Parker Programming Contest (SWE Guild, 12/22/2016)
# Problem A - The 3n + 1 problem
# https://vjudge.net/contest/145712#problem/A
# Author: Adam
import sys
import functools
@functools.lru_cache(maxsize=1000000)
def cycle_len(k):
if k == 1:
@boxysean
boxysean / dish.js
Created November 25, 2018 19:33
Bedside dish
// All units inches
function form(length, width, height, thickness) {
return union([
cube({size: [length, thickness, height]}),
cube({size: [length, thickness, height]})
.translate([0, width - thickness, 0]),
cube({size: [thickness, width, height]}),
cube({size: [thickness, width, height]})
.translate([length - thickness, 0, 0])
@boxysean
boxysean / datadog-postgres-example.yaml
Created December 28, 2018 16:20
datadog-postgres-example.yaml
init_config: null
instances:
- collect_activity_metrics: true
collect_default_database: true
collect_function_metrics: true
dbname: mydb
host: main-database.example.com
password: mypassword
port: 5432
relations: null
# dbt_utils/dbt_project.yml
name: 'dbt_utils'
version: '0.1.0'
@boxysean
boxysean / outside-corner.js
Created June 19, 2019 02:15
Outside corner for fixing da cubes
// All units inches
var extrude_ = 0.1;
var nutSize = 0.375;
var threadDiameter = 0.22;
var screwPosition = [0.5, 0.5];
function makeHalf() {
var half = polygon([
[0,0.7],
@boxysean
boxysean / asyncio_example.py
Last active February 16, 2020 19:00
Four approaches to multi-threaded extract-and-load code (including a new one)
import aiohttp
import asyncio
import sqlite3
URLS = [
'http://www.foxnews.com/',
'http://www.cnn.com/',
'http://europe.wsj.com/',
'http://www.bbc.co.uk/',