Skip to content

Instantly share code, notes, and snippets.

DROP TABLE IF EXISTS rpi_models;
CREATE TABLE "RPI_Models" (
'Family' TEXT,
'Model' TEXT,
'SoC' TEXT,
'Memory' REAL,
'Formfactor' TEXT,
'Ethernet' TEXT,
'Wireless' TEXT,
@mc3k
mc3k / elevplot.sh
Created January 1, 2025 01:20
Plot the elevation profile of GPX profile using GNUPlot and GPXPlot3.py
#!/bin/bash
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
cd "$SCRIPTPATH"
python3 gpxplot3.py -y elevation -x distance $1 > gpx.dat & pid1=$!
wait $pid1
echo "
set output '$1.png'
@mc3k
mc3k / heatindex.py
Last active December 31, 2024 23:41
Calculate Heat Index from Temperature and Relative Humidity
import math, sys, os
def heat_index_wpc(temp,humid):
# https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
T = float(temp)*9/5 +32
RH = float(humid)
HI = -42.379 + 2.04901523*T + 10.14333127*RH - .22475541*T*RH - .00683783*T*T - .05481717*RH*RH + .00122874*T*T*RH + .00085282*T*RH*RH - .00000199*T*T*RH*RH
if RH < 13 and T > 80 and T < 112 :
HI = HI - ((13-RH)/4)*math.sqrt((17-abs(T-95))/17)
@mc3k
mc3k / log-tp350s.py
Last active December 31, 2024 17:33
Log ThermoPro TP350S temperature and humidity in Linux
import sys, os, logging, datetime
from tp357tool import *
temp, humid = None, None
mac = 'MY:MA:CA:DD:RE:SS'
# Read data from ThermoPro
device, read, write = bt_setup(mac)
temp, humid = wait_for_temp(read, write)
@echo off
Title Batch convert fit to gpx
for %%i in (*.fit) do "C:\Program Files\GPSBabel\gpsbabel.exe" -rt -i garmin_fit -f %%i -x track,course,speed -o gpx -F %%~ni.gpx && echo %%i converted to %%~ni.gpx
pause
-- ====================================================================================================================
-- Author: Martin Childs
-- Create date: 2017-11-09
-- Description: Calculates a mortgage style annuity loan payment schedule
-- Version: v001
-- ====================================================================================================================
Print'Create numbered list'
--http://sqlperformance.com/2013/01/t-sql-queries/generate-a-set-1
Function StaticRandom(Input1 As String, Optional Rand_Input As Double = 0) As Variant
' Create a pseudo random number which doesn't change for a given input
' Martin Childs, 2016-07-05
' v001
'
Prime = 9973
'Checksum
checksum = Len(Input1)
Public Function TrendlineParse(Eqtn As String, Optional xVal As Variant = "eq", Optional xType As Variant = 0) As Variant
'Function Convert trendline equations into formulas
' (c) Martin Childs 2017
Eqtn = Replace(Eqtn, " ", "")
'Return equation
If xVal = "eq" Then
TrendlineParse = Eqtn
Exit Function
#!/usr/bin/env python
from lib_oled96 import ssd1306
import time
#import sys
from PIL import ImageFont, ImageDraw#, Image
from smbus import SMBus
i2cbus = SMBus(1) # 1 = Raspberry Pi but NOT early REV1 board
#!/usr/bin/env python
import time, sys, logging
from daemon2x import Daemon
from lib_oled96 import ssd1306
from PIL import ImageFont, ImageDraw, Image
from smbus import SMBus
# Logging
logging.basicConfig(filename='/home/pi/oled/lib_oled96/clock.log',