Skip to content

Instantly share code, notes, and snippets.

View tobiasmcnulty's full-sized avatar

Tobias McNulty tobiasmcnulty

View GitHub Profile
@tobiasmcnulty
tobiasmcnulty / ansibleSetupPostfixSES.yml
Last active March 25, 2021 16:08 — forked from l0neranger/ansibleSetupPostfixSES.yml
Ansible Playbook - Postfix for SES Delivery
#
# According to AWS Docs - http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
#
# Rewrites all sender addresses to a single canonical ses verified address.
#
# Expects a vars files at ../vars/PostfixSES-vars.yml with the following variables:
# - ses_host: email-smtp.us-west-x.amazonaws.com
# - ses_port: 587
# - ses_username: ses-smtp-username
# - ses_password: ses-smtp-password
class DbValidatingCacheMixin(object):
"""
Cache mixin that avoids returning database objects from the cache that
reference invalid databases (databases that no longer exist in the settings
file).
"""
def _validate(self, key, obj, default=None):
"""
If ``obj`` appears to be a model object or list of model objects that
Elastic Load Balancer, CloudFront and Let's Encrypt
@tobiasmcnulty
tobiasmcnulty / form_group.py
Created February 5, 2017 15:19
Django form-like object that wraps a related group of forms.
class FormGroup(object):
"""
Form-like object that wraps a related group of forms.
"""
def __init__(self, main_form, **other_forms):
self.main_form = main_form
self.other_forms = list(other_forms.values())
for k, v in other_forms.items():
setattr(self, k, v)

Keybase proof

I hereby claim:

  • I am tobiasmcnulty on github.
  • I am tobiasmcnulty (https://keybase.io/tobiasmcnulty) on keybase.
  • I have a public key ASBZ7dIhp5zA1a__DiQ070SobSPwLXNJxh0RXTr26iW9cgo

To claim this, I am signing this object:

@tobiasmcnulty
tobiasmcnulty / neighbor_wifi_sharing.rsc
Last active October 23, 2020 01:07
If you have a neighbor with a different internet service provider (ISP) and you want to share guest wifi networks for when those ISPs inevitably go down (hopefully at different times), you can fairly easily use a single Mikrotik device to share your internet connection with them, and bring their connection into the house.
# Configure a bridge with vlan-filtering enabled (might want to enable VLAN filtering at the end, on a new device)
/interface bridge
add ingress-filtering=yes name=bridge vlan-filtering=yes
# Configure interface lists for firewall rules
/interface list
add name=WAN
add name=LAN
# Configure wireless security profiles (these have passwords stripped; be sure to add some)
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
import collections
import select
import socket
import smpplib
class ThreadSafeClient(smpplib.client.Client):
"""
Thread-safe smpplib Client, adapted from:
- name: Disable onboard audio
replace:
path: /boot/config.txt
regexp: '^dtparam=audio=on$'
replace: '#dtparam=audio=on'
register: disable_onboard
when: dac_type is defined
- name: Enable DAC ({{ dac_type }})
lineinfile:
@tobiasmcnulty
tobiasmcnulty / g-mass-storage.service
Last active March 17, 2022 02:42
Unit file to load the `g_mass_storage` module after `iscsi.service`
# Adapted from: https://unix.stackexchange.com/a/260022/18065
[Unit]
Description=Loads kernel module for USB OTG
After=iscsi.service
DefaultDependencies=false
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/modprobe g_mass_storage file=/dev/xyx
$ docker run --rm -e POSTGRES_PASSWORD=mysecretpassword -d postgres:13
a9fd95ccfeaeaa94c0a0a39deac52e74f59841607258c6827eabd2b33972f633
$ docker exec -it a9fd95ccfeaeaa94c0a0a39deac52e74f59841607258c6827eabd2b33972f633 bash
root@661543604ec8:/# apt-get update && apt-get install -y procps
<snip>
root@661543604ec8:/# psql -U postgres -c 'SELECT pg_sleep(60)' &
[1] 463
root@661543604ec8:/# ps auxww
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
postgres 1 0.0 0.1 213072 27168 ? Ss 14:45 0:00 postgres