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
"""Multiprocessing and threading example.""" | |
import logging | |
import multiprocessing.pool | |
import random | |
import threading | |
import time | |
logging.basicConfig( | |
level=logging.INFO, |
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 CLI.""" | |
import argparse | |
class Example: | |
"""Python lorem ipsum.""" | |
@staticmethod | |
def show_base(**arguments): | |
"""Show the current base.""" |
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
"""Some boto3 user stuff.""" | |
import boto3 | |
def get_account_id(session): | |
"""Get the account id for the current session.""" | |
sts_client = session.client("sts") | |
identity = sts_client.get_caller_identity() | |
return identity["Account"] |
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
"""Convert number (0 indexed) to Excel spread sheet column.""" | |
import string | |
def number_to_column(number): | |
"""Convert number (0 indexed) to Excel spread sheet column.""" | |
if number < 0: | |
return "" | |
elif number < 26: | |
return string.ascii_uppercase[number] |
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
""" | |
This is a sample workflow that includes a manual task. | |
Activities: | |
1. get_contact_activity | |
Get a subscription address. | |
2. subscribe_topic_activity | |
Create an SNS topic and subscribe the provided endpoints to the topic. |
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
"""AWS SWF domains stuff.""" | |
import argparse | |
import boto3 | |
def get_swf_domains(client=boto3.client("swf"), **parameters): | |
"""Get AWS SWF domain names.""" | |
paginator = client.get_paginator("list_domains") | |
for response in paginator.paginate(**parameters): |
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 debian:jessie | |
RUN apt-get update -qq \ | |
&& apt-get install -qqy \ | |
apt-transport-https \ | |
curl \ | |
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub \ | |
| apt-key add - \ | |
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \ | |
&& echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list.d/jessie-backports.list \ |
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
const https = require('https'); | |
function getProductsByBrand(brand, limit, offset) { | |
let params = '?limit=' + limit.toString() + '&offset=' + offset.toString(); | |
let path = '/brands/' + brand + '/products' + params; | |
let options = {host: host, path: path, auth: auth} | |
https.get(options, (response) => { | |
data = ''; |
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 | |
api='https://api.amberengine.com' | |
auth='<your email>:<your password>' | |
split-array() { | |
awk '{ | |
gsub(/^\[/, "") | |
gsub(/\]$/, "") | |
gsub(/ /, "") |
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
"""Get a bunch of products from the API.""" | |
import json | |
import os | |
import requests | |
from requests.auth import HTTPBasicAuth | |
class APISession: | |
"""An API session.""" |