Skip to content

Instantly share code, notes, and snippets.

@ArrEssJay
ArrEssJay / gist:2ca9f518b78716bd151bce62f02a74d5
Created July 28, 2023 00:17
Convert GQRX IQ Recording to SDRTrunk
// GQRX IQ recording:
// Raw interleaved IQ samples, 32-bit IEEE float @ receiver sampling rate
//
// SDRTrunk recording:
// WAV file, interleaved IQ samples, signed 16-bit @ receiver sampling rate
//
// 'sox' can be used to downsample and append the WAV header
sox -c 2 -t f32 -r 2400000 <infile> -b 16 -t wav <outfile>
@ArrEssJay
ArrEssJay / gps.sh
Last active August 7, 2022 13:47
Parse gpsd JSON messges with telegraf
#!/bin/bash
gpspipe -w | jq -c -M '. | select( (.class == "SKY" and has("satellites") == true) or .class == "TPV")' | while IFS= read obj
do
echo $obj
done
@ArrEssJay
ArrEssJay / heating_state.py
Created June 29, 2022 14:03
HA PyScript Load Control
@state_trigger("sensor.scheduled_heating_state", state_check_now=True)
@service
def price_load_control():
"""Turn OFF or ON water heater by price signal (obey overrides)"""
if state.get("input_select.water_heating_mode") == "auto":
scheduled_state = sensor.scheduled_heating_state
log.warning(f"Load control state: {scheduled_state}")
if scheduled_state == '0':
switch.turn_off(entity_id = "switch.storage_heater")
log.warning(f"Load control triggered water heater OFF")
@ArrEssJay
ArrEssJay / telegraf.conf
Created April 14, 2022 06:24
UBX GNSS data -> telegraf using pyubx2 outputting JSON
# The lambda function coerces pyubx2 into outputting JSON. Requires importing the `jsons` library
[[inputs.execd]]
command = ["gnssdump", \
"port=/dev/ttyACM0", \
"baudrate=921600",
"protfilter=2", \
"verbosity=0", \
"ubxhandler=lambda msg: print(jsons.dumps((lambda msg: {key:value for (key,value) in dict(msg.__dict__, **{'msg':msg.identity}).items() if not key.startswith('_') } )(msg)))", \
"msgfilter=NAV-PVT"]
@ArrEssJay
ArrEssJay / heaterScheduler.flux
Last active April 12, 2022 14:04
Flux (InfluxDB) Price Driven Heater Controller, using Amber (aus) price data and modbus power monitoring.
// Hybrid wholesale price (feed-forward) and proportional (feedback) storage water heater controller.
// Tries to keep the tank hot and the bill low
// This query runs every half hour (NEM metering period) and determines for the next 18 hours (available forecast period)
// how much time is needed to heat the water tank and which are the cheapest times to do that
// Basic theory
// Wholesale electricity prices are volatile. Lots of renewables means low prices. The storage heater allows us to ride out
// expensive periods by only heating water when it's cheap. This is fine until a week of rain means we run out of hot water.
@ArrEssJay
ArrEssJay / slope.qml
Created October 7, 2019 03:36
QGIS Slope-Aspect Map (Slope)
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis styleCategories="AllStyleCategories" minScale="1e+08" hasScaleBasedVisibilityFlag="0" version="3.8.0-Zanzibar" maxScale="0">
<flags>
<Identifiable>1</Identifiable>
<Removable>1</Removable>
<Searchable>1</Searchable>
</flags>
<customproperties>
<property value="false" key="WMSBackgroundLayer"/>
<property value="false" key="WMSPublishDataSourceUrl"/>
@ArrEssJay
ArrEssJay / aspect.qml
Created October 7, 2019 03:15
QGIS Slope-Aspect Map (Aspect)
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis styleCategories="AllStyleCategories" minScale="1e+08" hasScaleBasedVisibilityFlag="0" version="3.8.0-Zanzibar" maxScale="0">
<flags>
<Identifiable>1</Identifiable>
<Removable>1</Removable>
<Searchable>1</Searchable>
</flags>
<customproperties>
<property value="false" key="WMSBackgroundLayer"/>
<property value="false" key="WMSPublishDataSourceUrl"/>
@ArrEssJay
ArrEssJay / randGrid.py
Created October 7, 2019 00:50
QGIS Geometry generator example - Random polygon grid fill (generates a multipoint geometry)
from qgis.core import *
from qgis.gui import *
import math
import random
"""
Define a grid based on the interval and the bounding box of
the feature. Grid will minimally cover the feature and be centre aligned
Create a multi-point geometry at the grid intersections where
@ArrEssJay
ArrEssJay / survex.rb
Last active August 15, 2018 00:47
Survex Homebrew Formula
class Survex < Formula
desc "Cave Surveying Tool"
homepage "https://www.survex.com"
url "https://survex.com/software/1.2.36/survex-1.2.36.tar.gz"
sha256 "8781f33daf61c5d22e52400e6130e66a1fec7557cf9aa793d0e26e9b37204ed0"
revision 4
depends_on "wxmac"
depends_on "proj"
depends_on "ffmpeg"
@ArrEssJay
ArrEssJay / cleanupMEBankCSV.py
Last active May 17, 2018 23:20
Cleanup MEBank (AU) transaction export CSV files.
#!/usr/local/bin/python3
import csv
import argparse
import sys
parser = argparse.ArgumentParser(description='Cleanup MEbank (AU) CSV files with descriptions split over multiple lines')
parser.add_argument('infile', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'), default=sys.stdout)
parser.add_argument('--invertorder', action='store_true')