Skip to content

Instantly share code, notes, and snippets.

@jtatum
jtatum / README.md
Last active June 11, 2022 12:10
Running Sendy on AWS ECS + Fargate

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
<?php phpinfo();
@jtatum
jtatum / config.py
Last active March 28, 2018 01:44
Get config from AWS SSM parameters. Import this file in your lambda and access parameters like config.SOME_PARAM
import boto3
def _get_secrets(path: str):
client = boto3.client('ssm')
secrets = {}
kwargs = {}
while True:
result = client.get_parameters_by_path(
Path=path,
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);
}()
);
# 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 April 4, 2013 16:41
Setup logging so that it works with utf-8 log files and ensure stdout is outputting in utf-8
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',
@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 December 14, 2015 06:19
Shell script to start automation in a local terminal window
#!/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 February 12, 2013 19:32
Send a global key in ATOMac
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 19:59
Use ATOMac to click various items in the menubar menu for Skype
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