Skip to content

Instantly share code, notes, and snippets.

Avatar

Stuart Longland sjlongland

View GitHub Profile
@sjlongland
sjlongland / example-output.csv
Last active Nov 13, 2022
Python script to sort WIA Repeater Data entries by geographic location
View example-output.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have columns, instead of 11. in line 6.
Sector,Band,Region,Mode,Output,Offset,Call,mNemonic,Location,Service Area,Latitude,Longitude,Angle,Distance,S,ERP,HASL,T/O,Sp,Tone,Notes
BT015,2m,VK8,FM,146950.0,-600.0,VK8RCA,8CAWest Gap 2,West Gap,Alice Springs,-23.722205,133.856578,-150.90415202120502,2.8145313409004022,O,25,776,3,8AR,91.5,
BT015,70cm,VK8,FM,438525.0,-5000.0,VK8RIT,8ITWest Gap U,West Gap,Alice Springs,-23.722205,133.856578,-150.90415202120502,2.8145313409004022,O,25,776,3,8AR,91.5,
DM110,2m,VK6,FM,146825.0,-600.0,VK6RAA,6AAMt Barker 2,Mt Barker,South Coast 6/15,-34.655747,117.647055,-131.34467418282028,1986.480317081825,X,25,450,5,6SR,-,
DM110,70cm,VK6,FM,439950.0,-5000.0,VK6RAA,6AAMt Barker U,Mt Barker,South Coast,-34.655747,117.647055,-131.34467418282028,1986.480317081825,O,25,450,5,6SR,-,54
DM110,70cm,VK6,FM,439950.0,-5000.0,VK6RAL,6ALMt Clarence U,Mt Clarence,Albany,-35.024783,117.894701,-132.70948648430002,1990.659292236595,O,25,-,-,6SR,-,54
DT109,2m,VK6,FM,147000.0,-600.0,VK6RAW,6AWFairfield 2,Fairfield,Katanning,-33.7939
@sjlongland
sjlongland / gist:1dc5b4dc5dca0cf5fd928f795f64bb8a
Last active Mar 29, 2022
Shell script to generate blacklists by country code
View gist:1dc5b4dc5dca0cf5fd928f795f64bb8a
#!/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 Aug 22, 2021
Proxying MQTT/websockets from aiohttp to back-end MQTT server (amqtt in this case)
View mqtt.py
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 Apr 6, 2020
Asterisk codec negotiation with SIP provider on incoming call
View gist:43bbe76efcb7a63a0e12ff1cceef55ee
[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'
@sjlongland
sjlongland / aes.c
Last active Sep 24, 2019
AES/SHA mbedtls implementation
View aes.c
/* vim: set tw=78 sw=4 ts=4 et:
* Copyright (c) 2017, VRT Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
View gist:7ef0f7cb7a5a2c76e686701889110f18
{
"cs": {
"p": 123,
"m": "a",
"a": "2001:db8:aaaa:bbbb::101"
},
"ts": {
"c": {
"c1": [
"p"
View gist:007d0385b1f6cd2b37c0192a2ce0cecc
# MeterMaster Data Access Layer
# (C) 2017 VRT Systems
#
# The following Software is the proprietary property of VRT Systems.
# Unauthorised disclosure or use of this Software is forbidden to the extent
# permitted by law.
#
# vim: set ts=4 sts=4 et tw=78 sw=4:
from threading import Event, Semaphore, Thread
@sjlongland
sjlongland / test.sh
Created Feb 7, 2018
pika test case: channel close bug
View test.sh
#!/bin/sh -ex
: ${PYTHON2:=$( which python2 )}
: ${PYTHON3:=$( which python3 )}
pass=""
fail=""
for python in ${PYTHON2} ${PYTHON3}; do
for pika in 0.9.14 0.10.0 0.11.2; do
@sjlongland
sjlongland / radio.c
Last active Jan 8, 2018
Debugging the CC2538 radio driver.
View radio.c
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@sjlongland
sjlongland / README.md
Created Dec 21, 2017
syslogd implementation for OpenThread
View README.md

RFC 5424 compatible syslog implementation for OpenThread.

This requires:

  • a filesystem of some kind, with stubs for newlib's file I/O functions… we're using SPIFFS with a SPI EEPROM, but there are lots of options.
  • a real-time clock with an implementation of gettimeofday… we use a NXP PCF8523 I²C RTC to synchronise a software counter

If sending of a message fails (because buffers are full) and the message severity is high enough,