Skip to content

Instantly share code, notes, and snippets.

View zaneclaes's full-sized avatar

Zane Claes zaneclaes

View GitHub Profile
@zaneclaes
zaneclaes / heat_index.js
Created October 2, 2023 18:10
Heat Index Calculator
// Returns a Celcius temperature that transforms the input temperature based on the relative humidity
function calculateHeatIndex(airTempC, relativeHumidity){
relativeHumidity = Math.min(100, Math.max(0, relativeHumidity));
var hitemp = 61.0+((airTempC-68.0)*1.2)+(relativeHumidity*0.094);
var hifinal = 0.5*(airTempC+hitemp);
if(hifinal > 79.0){
var hi = -42.379+2.04901523*airTempC+10.14333127*relativeHumidity-0.22475541*airTempC*relativeHumidity-6.83783*(Math.pow(10, -3))*(Math.pow(airTempC, 2))-5.481717*(Math.pow(10, -2))*(Math.pow(relativeHumidity, 2))+1.22874*(Math.pow(10, -3))*(Math.pow(airTempC, 2))*relativeHumidity+8.5282*(Math.pow(10, -4))*airTempC*(Math.pow(relativeHumidity, 2))-1.99*(Math.pow(10, -6))*(Math.pow(airTempC, 2))*(Math.pow(relativeHumidity,2));
if((relativeHumidity <= 13) && (airTempC >= 80.0) && (airTempC <= 112.0)) {
var adj1 = (13.0-relativeHumidity)/4.0;
@zaneclaes
zaneclaes / config.g
Created May 22, 2023 20:12
Modix BIG-60 v4 Corrected Configuration
; Modix Big-60, Generation 4, Single Printhead
; Configuration file for Duet WiFi (firmware version 3.4.5)
; Generated by Modix - Version 3.4.5 Config B
global config_version = "Version 3.4.5 Config B"
global generation = 4 ; Generation 4 printer
global printhead = 1 ; Griffin printhead
global printheads = 1 ; single printhead
global idex = 0 ; no IDEX
global expansion = 1 ; Griffin expansion board is installed
async function testDice(func, bytes = 2, runs = 1000) {
let sequence = '';
const vals = [];
let last = 0;
for (let i=0; i<runs; i++) {
last = await func(i, last);
let hex = last.toString(16);
while (hex.length < (bytes * 2)) hex = `0${hex}`;
for (let b=0; b<(bytes*2); b++) {
@zaneclaes
zaneclaes / gist:4b87a74fd47ad0e41f2d91be47eeb934
Created July 7, 2021 19:39
Windows wrapper to exclude errors
@echo off
ECHO "RUN %*"
CALL %*
ECHO "Real error code was %errorlevel%"
SET ERRORLEVEL=0
exit /B 0
2021-07-07 10:55:19,847 13700 [INFO ] - Installing visualstudio2019buildtools...
2021-07-07 10:55:19,891 13700 [DEBUG] - Running 'Start-VSServicingOperation' for visualstudio2019buildtools with silentArgs:'--quiet --norestart --wait', file:'C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\visualstudio2019buildtools\16.10.2.0\vs_BuildTools.exe', logFilePath:', operationTexts:'instal
led installing installation', assumeNewVS2017Installer:'True'
2021-07-07 10:55:19,911 13700 [DEBUG] - [20210707 10:55:19.911] Looking for still running VS installer processes
2021-07-07 10:55:19,931 13700 [DEBUG] - Did not find any running VS installer processes.
2021-07-07 10:55:19,931 13700 [DEBUG] - [20210707 10:55:19.931] Looking for vs_installer.windows.exe processes spawned by the uninstaller
2021-07-07 10:55:19,931 13700 [DEBUG] - Did not find any running vs_installer.windows.exe processes.
2021-07-07 10:55:19,947 13700 [INFO ] -
2021-07-07 10:55:19,992 13700 [DEBUG] - Running 'Start-VSChocolateyProcessAsAdmin'
@zaneclaes
zaneclaes / electronize start
Created May 28, 2021 00:24
electronize start logs
Start Electron Desktop Application...
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
/Users/zaneclaes/zdrive/zaneclaes/Programming/OWE/src/OpenWorkShop/OpenWorkShop.csproj : warning NU1701: Package 'ArduinoDriver 2.4.6' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net5.0'. This package may not be fully compatible with your project. [/Users/zaneclaes/zdrive/zaneclaes/Programming/OWE/src/OpenWorkShop/OpenWorkShop.sln]
/Users/zaneclaes/zdrive/zaneclaes/Programming/OWE/MakerHub/MakerHub.csproj : warning NU1701: Package 'ArduinoDriver 2.4.6' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramewor
client> $$
$0=10 (Step pulse time, microseconds)
$1=25 (Step idle delay, milliseconds)
$2=0$3=0 (Step pulse invert, mask)
$4=0 (Invert step enable pin, boolean)
$5=0 (Invert limit pins, boolean)
$6=0 (Invert probe pin, boolean)
$10=1 (Status report options, mask)
$11=0.010 (Junction deviation, millimeters)
$12=0.002 (Arc tolerance, millimeters)
@zaneclaes
zaneclaes / maslow-clamping-skirt.nc
Created August 3, 2020 20:47
gcode for the Maslow Clamping Skirt frame plans
(1001)
(T1 D=0.25 CR=0 - ZMIN=-0.8394 - FLAT END MILL)
G0 G40 G90 G17
G20
(POCKET ROUGH)
T1 M6
M3 S10000
G0 X12.3576 Y18.4
G0 Z0.2
@zaneclaes
zaneclaes / update-route53.py
Created March 18, 2020 17:23
Update route53 via AWS CLI with the current IP address. Usage: "update-route53.py subdomain1 subdomain2 domain-name.com"
#!/usr/bin/env python3
import subprocess, re, os, json, sys
zones = None
def _sh(cmd):
return subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True).stdout.strip()
def _whatsmyip():
return _sh('dig +short myip.opendns.com @resolver1.opendns.com')
@zaneclaes
zaneclaes / prometheus-to-mqtt
Created February 3, 2020 19:18
Node Red Forward Prometheus to MQTT
[{"id":"d647cda7.47601","type":"tab","label":"OBD","disabled":false,"info":""},{"id":"c1814e23.3d93d","type":"inject","z":"d647cda7.47601","name":"","topic":"","payload":"","payloadType":"date","repeat":"15","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":240,"wires":[["e8d485cc.aa10a8"]]},{"id":"e8d485cc.aa10a8","type":"http request","z":"d647cda7.47601","name":"prometheus","method":"GET","ret":"txt","paytoqs":false,"url":"localhost:8000","tls":"","proxy":"","authType":"","x":290,"y":240,"wires":[["1360a3fe.df2cdc"]]},{"id":"1360a3fe.df2cdc","type":"function","z":"d647cda7.47601","name":"stats","func":"lines = msg.payload.split(\"\\n\");\nmsg.payload = [];\nfor(var i=0; i<lines.length; i++) {\n if (lines[i][0] == '#')\n continue;\n if (!lines[i].startsWith('obd_'))\n continue;\n var br = lines[i].indexOf('{');\n var sp = lines[i].indexOf(' ');\n var f = (br > 0 && br < sp) ? br : sp;\n var v = parseFloat(lines[i].substr(f+1))\n msg.payload.push([lines[i].substr(0, f),