Skip to content

Instantly share code, notes, and snippets.

@jg75
jg75 / threadpool.py
Created October 26, 2018 23:14
Multiprocessing and threading example.
"""Multiprocessing and threading example."""
import logging
import multiprocessing.pool
import random
import threading
import time
logging.basicConfig(
level=logging.INFO,
"""Example CLI."""
import argparse
class Example:
"""Python lorem ipsum."""
@staticmethod
def show_base(**arguments):
"""Show the current base."""
@jg75
jg75 / user_stuff.py
Created September 12, 2018 18:15
Just some stuff to remember
"""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"]
"""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]
@jg75
jg75 / sample_workflow.py
Last active January 19, 2020 09:58
SWF Sample Workflow
"""
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.
"""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):
@jg75
jg75 / Dockerfile
Last active July 16, 2018 21:30
How to install Chrome in Debian (Jessie)
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 \
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 = '';
#! /bin/bash
api='https://api.amberengine.com'
auth='<your email>:<your password>'
split-array() {
awk '{
gsub(/^\[/, "")
gsub(/\]$/, "")
gsub(/ /, "")
"""Get a bunch of products from the API."""
import json
import os
import requests
from requests.auth import HTTPBasicAuth
class APISession:
"""An API session."""