Skip to content

Instantly share code, notes, and snippets.

@tim-tang
tim-tang / slack.py
Created October 29, 2016 10:49 — forked from boxysean/slack.py
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
@tim-tang
tim-tang / airflow_eg.py
Created October 29, 2016 09:08 — forked from abridgett/airflow_eg.py
airflow XCOM notification example
MAP_SLACK_ATTACHMENTS = [
{
"fallback": "{{params.map}} {{ task_instance.xcom_pull(task_ids=params.map, key='slack_status') }}",
"pretext": "{{params.map}} update {{ task_instance.xcom_pull(task_ids=params.map, key='slack_status') }}",
"fields": [
{
"title": "Copied",
"value": "{{ task_instance.xcom_pull(task_ids=params.map, key='copied') }}",
"short": True
}
@tim-tang
tim-tang / run-tests.sh
Created October 28, 2016 11:30 — forked from criccomini/run-tests.sh
run-tests.sh
#!/bin/bash
# Runs airflow-dags tests.
# Set Nose defaults if no arguments are passed from CLI.
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NOSE_ARGS=$@
if [ -z "$NOSE_ARGS" ]; then
NOSE_ARGS=" \
--with-coverage \
@tim-tang
tim-tang / test_dags.py
Created October 28, 2016 11:25 — forked from criccomini/test_dags.py
test_dags.py
import os
import unittest
from airflow.models import DagBag
class TestDags(unittest.TestCase):
"""
Generic tests that all DAGs in the repository should be able to pass.
"""
fedora => http://jared.hrpr.us/post/fedora-23-4th-gen-lenovo-x1-carbon/
arch => https://kozikow.com/2016/06/03/installing-and-configuring-arch-linux-on-thinkpad-x1-carbon/
#!/usr/bin/bash
#VRIABLES DEFINITION
CURRENT_YEAR=`date|cut -c 25-28`
CURRENT_MONTH=`date +%m`
CURRENT_DAY=`date +%d`
CURRENT_HOUR=`date|cut -c 12-13`
CURRENT_MINUTE=`date|cut -c 15-16`
CURRENT_SECOND=`date|cut -c 18-19`

Run Netatalk in a SmartOS zone

This guide is based on this blog post: http://blog.smartcore.net.au/blazingly-fast-afp-on-a-smartos-zone/.

Import image and create virtual machine

Find the latest image, in this case 4166f6d6-ea5f-11e4-addd-8351b159d9b6 (15.1.0), or 24648664-e50c-11e4-be23-0349d0a5f3cf (14.4.1) if you need Long Term Support (LTS).

# imgadm avail | grep base-64
@tim-tang
tim-tang / IPaddr
Created May 20, 2016 09:15 — forked from vincepii/IPaddr
#!/usr/gnu/bin/sh
#
# License: GNU General Public License (GPL)
# Support: linux-ha@lists.linux-ha.org
#
# This script manages IP alias IP addresses
#
# It can add an IP alias, or remove one.
#
# usage: $0 {start|stop|status|monitor|validate-all|meta-data}
#! /bin/bash
# HEADS UP! Make sure to use '*' or a valid hostname for the FDQN prompt
echo 01 > ca.srl
openssl genrsa -des3 -out ca-key.pem
openssl req -new -x509 -days 365 -key ca-key.pem -out ca.pem
openssl genrsa -des3 -out server-key.pem
openssl req -new -key server-key.pem -out server.csr
@tim-tang
tim-tang / .psqlrc
Created August 1, 2012 10:15
[conf] - psql
\pset null '<NULL>'
\set HISTFILE ~/.psql_history- :HOST - :DBNAME
\set HISTSIZE 2000
\set FETCH_COUNT 1000
\timing
\set PROMPT1 '(%n@%M:%>) [%/] > '
\set PROMPT2 ''
\encoding unicode
\pset border 2
\pset format wrapped