Skip to content

Instantly share code, notes, and snippets.

@jtatum
jtatum / README.md
Last active Jun 11, 2022
Running Sendy on AWS ECS + Fargate
View README.md

Sendy on ECS + Fargate

It's possible to run Sendy on ECS + Fargate. My infrastructure is as follows:

  • RDS MySQL
  • EFS
  • ALB
  • ACM certificate
  • ECS Service
  • ALB target group
@jtatum
jtatum / config.py
Last active Mar 28, 2018
Get config from AWS SSM parameters. Import this file in your lambda and access parameters like config.SOME_PARAM
View config.py
import boto3
def _get_secrets(path: str):
client = boto3.client('ssm')
secrets = {}
kwargs = {}
while True:
result = client.get_parameters_by_path(
Path=path,
View frozen cookies bookmarklet.js
javascript:(
function () {
var js = document.createElement('script');
js.setAttribute('type', 'text/javascript');
js.setAttribute('id', 'frozenCookieScript');
js.setAttribute('src', 'https://rawgithub.com/jtatum/FrozenCookies/master/frozen_cookies.js');
document.head.appendChild(js);
}()
);
View main.py
# Why not to just put all your code under if __name__ == '__main__':
# (AKA why you should use a main(argv) function)
import sys
def my_func(param):
print param
# You'd think this would fail, but it works, because new_param is in the
# parent level scope. It will fail if you import this file and call
@jtatum
jtatum / logging.py
Created Apr 4, 2013
Setup logging so that it works with utf-8 log files and ensure stdout is outputting in utf-8
View logging.py
import logging
# Change the default encoding of stdout to utf-8.
# This is effective if the output is piped or redirected.
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
# Add a file handler with utf-8 encoding
handler = logging.FileHandler('output.log', 'w',
View gist:5240548
@issue
Feature: Issue #TBD: Logging starts with a StreamHandler way too early
Scenario:
Given a file named "features/steps/steps.py" with:
"""
import logging
from behave import given, when, then, step
@jtatum
jtatum / startauto.sh
Last active Dec 14, 2015
Shell script to start automation in a local terminal window
View startauto.sh
#!/bin/bash
# Note - you can't run this script in the local terminal.
# Run it via SSH or cron or something else.
COMMANDS="your automation script here"
killall python 2>/dev/null
killall Terminal 2>/dev/null
@jtatum
jtatum / sendkey.py
Created Feb 12, 2013
Send a global key in ATOMac
View sendkey.py
import atomac
from atomac.AXKeyCodeConstants import *
app=atomac.getAppRefByLocalizedName('iTerm')
# the COMMAND constant here comes from AXKeyCodeConstants
app.sendGlobalKeyWithModifiers('n', [COMMAND])
@jtatum
jtatum / atomac_skype.py
Last active May 21, 2019
Use ATOMac to click various items in the menubar menu for Skype
View atomac_skype.py
import atomac
a=atomac.getAppRefByLocalizedName('Skype')
cloud_menu = a.AXChildren[2].AXChildren[0]
print cloud_menu
# Some apps are coded so menu items aren't populated until they're displayed
try:
cloud_menu.Press()
except atomac.ErrorCannotComplete:
# An accessibility bug you'll see sometimes - the app never reports