Skip to content

Instantly share code, notes, and snippets.

View sjlongland's full-sized avatar

Stuart Longland sjlongland

View GitHub Profile
@sjlongland
sjlongland / case01-setuppy-inline-license.txt
Created August 20, 2023 02:52
License output for setuptools with different projects
+ tail -n +0 setup.py
import setuptools
setuptools.setup(
name="mypackage",
version="1.2.3",
license="""Mock License 1.0
This is a dummy license text to check how setuptools represents
it in the metadata so it can be exposed to pyproject.toml."""
# Manually typed from https://theblower.au/@DropBear/110647780217493876
Discussion over vote on Voice
A VOICE that can't be deleted.
When Assistant Minister for Indigenous Australians Malarndirri McCarthy said
that we will need to "call out the misinformation and disinformation" on the
Voice to Parliament. I got to work doing just that. I was seeing a lot of
it.
@sjlongland
sjlongland / dumpmeta.py
Last active June 27, 2023 03:07
Mucking around with `distutils` command packages
#!/usr/bin/env python3
from distutils.cmd import Command
import json
def to_json(v):
if (v is None) or isinstance(v, (bool, int, str)):
return v
elif isinstance(v, list):
@sjlongland
sjlongland / fail2ban-subnet-scrape.py
Last active May 21, 2023 03:12
fail2ban-subnet scraper
#!/usr/bin/env python3
"""
Automatically coalesce IPs from fail2ban into subnets and flag them for
banning.
"""
# © 2023 Stuart Longland <me@vk4msl.com>
# SPDX-License-Identifier: BSD-2-Clause
@sjlongland
sjlongland / example-chirp-output.csv
Last active April 21, 2023 11:29
Python script to sort WIA Repeater Data entries by geographic location
Location Name Frequency Duplex Offset Tone rToneFreq cToneFreq DtcsCode DtcsPolarity RxDtcsCode CrossMode Mode TStep Skip Comment URCALL RPT1CALL RPT2CALL DVCODE
0 8CAWest Gap 2 146.95 - 0.6 Tone 91.5 91.5 23 NN 23 Tone->Tone FM 25.0 0
1 8ITWest Gap U 438.525 - 5.0 Tone 91.5 91.5 23 NN 23 Tone->Tone FM 25.0 0
2 6AAMt Barker 2 146.825 - 0.6 88.5 88.5 23 NN 23 Tone->Tone FM 25.0 0
3 6AAMt Barker U 439.95 - 5.0 88.5 88.5 23 NN 23 Tone->Tone FM 25.0 0
4 6ALMt Clarence U 439.95 - 5.0 88.5 88.5 23 NN 23 Tone->Tone FM 25.0 0
5 6AWFairfield 2 147.0 - 0.6 88.5 88.5 23 NN 23 Tone->Tone FM 25.0 0
6 6MJManjimup 2 147.15 + 0.6 88.5 88.5 23 NN 23 Tone->Tone FM 25.0 0
7 6AKKalgoorlie 2 147.0 - 0.6 88.5 88.5 23 NN 23 Tone->Tone FM 25.0 0
8 6RRKalgoorlie 2 147.05 + 0.6 88.5 88.5 23 NN 23 Tone->Tone DMR 25.0 0
@sjlongland
sjlongland / teststn.log
Last active April 3, 2023 09:30
Quick and dirty test of aioax25 connected mode
2023-04-02 17:06:44,073 aioax25.kiss[kiss.py: 385] DEBUG OPEN new port 0
2023-04-02 17:06:44,074 aioax25.interface[router.py: 56] DEBUG Binding callsign 'VK4MSL' (regex False) SSID 4 to <bound method AX25Station._on_receive of <aioax25.station.AX25Station object at 0x7f26b28c19f0>>
2023-04-02 17:06:44,074 aioax25.kiss[kiss.py: 396] DEBUG Opening device
2023-04-02 17:06:44,074 aioax25.kiss[kiss.py: 435] DEBUG Awaiting KISS transport
2023-04-02 17:06:44,074 asyncmain[teststn.py: 59] INFO Waiting for connections
2023-04-02 17:06:44,074 aioax25.kiss[kiss.py: 488] DEBUG Delegating to KISS serial device '/dev/ax0'
2023-04-02 17:06:44,074 aioax25.kiss[kiss.py: 420] DEBUG Constructing protocol object
2023-04-02 17:06:44,075 aioax25.kiss.protocol[kiss.py: 689] DEBUG Announcing connection: SerialTransport(<_UnixSelectorEventLoop running=True closed=False debug=False>, <aioax25.kiss.KISSProtocol object at 0x7f26b28c1f60>, Serial<id=0x7f26b28c1570, open=True>(port='/dev/ax0', baudrate=9600, bytesize=8, parity='N', stop
@sjlongland
sjlongland / comparenacl.py
Created March 14, 2023 01:02
Re-format the NACL change output from Terraform to make changes easier to spot.
import re
import argparse
PROTOCOLS = {
"1": "icmp",
"6": "tcp",
"17": "udp",
}
ap = argparse.ArgumentParser()
@sjlongland
sjlongland / gist:1dc5b4dc5dca0cf5fd928f795f64bb8a
Last active March 29, 2022 04:23
Shell script to generate blacklists by country code
#!/bin/sh
# This is a script I use on my own personal servers to block the following countries:
# Belarus: for supporting Russia
# China: for human rights abuses in Xinjiang
# Hong Kong: because China claims this is "their" territory and the HK government seems to agree
# Russia: Invasion of Ukraine (ohh, and BTW… Пу́тін — хуйло́ / Пу́тин — хуйло́)
# Provided in the public domain without any guarantee or warranty whatsoever, use at your own risk.
# Typical usage in `pf`:
@sjlongland
sjlongland / mqtt.py
Last active August 22, 2021 07:43
Proxying MQTT/websockets from aiohttp to back-end MQTT server (amqtt in this case)
from yaml import safe_load
from asyncio import coroutine, gather, get_event_loop, ensure_future
from aiohttp.web import json_response, Application, View, WebSocketResponse
from aiohttp import WSMsgType, ClientSession
# Read a configuration file
config = safe_load(open('config.yml','r').read())
# Set up the core application
@sjlongland
sjlongland / gist:43bbe76efcb7a63a0e12ff1cceef55ee
Created April 6, 2020 11:16
Asterisk codec negotiation with SIP provider on incoming call
[Apr 6 20:49:17] Asterisk 16.6.2 built by _pbuild @ amd64-stable.ports.openbsd.org on a amd64 running OpenBSD on 2019-11-22 09:21:53 UTC
[Apr 6 20:49:17] NOTICE[-1] loader.c: 306 modules will be loaded.
[Apr 6 20:49:18] ERROR[-1] res_config_sqlite3.c: Missing config file 'res_config_sqlite3.conf'
[Apr 6 20:49:18] ERROR[-1] config_options.c: Unable to load config file 'statsd.conf'
[Apr 6 20:49:18] NOTICE[-1] res_statsd.c: Could not load statsd config; using defaults
[Apr 6 20:49:18] ERROR[-1] config_options.c: Unable to load config file 'udptl.conf'
[Apr 6 20:49:18] NOTICE[-1] udptl.c: Could not load udptl config; using defaults
[Apr 6 20:49:18] ERROR[-1] config_options.c: Unable to load config file 'acl.conf'
[Apr 6 20:49:18] NOTICE[-1] manager.c: Unable to open AMI configuration manager.conf, or configuration is invalid.
[Apr 6 20:49:18] ERROR[-1] config_options.c: Unable to load config file 'features.conf'