Skip to content

Instantly share code, notes, and snippets.

View zaneclaes's full-sized avatar

Zane Claes zaneclaes

View GitHub Profile
@zaneclaes
zaneclaes / wifi-auto-connect.sh
Created October 30, 2019 20:55
Bash script to automatically connect to open WiFi networks, upon disconnect, via nmcli
#!/bin/bash
con="${1}"
if [[ -z "$con" ]]; then
echo "Please provide an interface name as an argument."
exit 1
fi
while true; do
conns=$(nmcli con show "$con" | grep "GENERAL.STATE:" | grep "activated")
@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 / 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),
@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
//
// AMProgressSpinnerComponent.m
// AftermathCore
//
// Created by Zane Claes on 8/29/13.
// Copyright (c) 2013 inZania LLC. All rights reserved.
//
#import "AMProgressSpinnerComponent.h"
#import "AMAssetManager.h"
#!/bin/bash
interfaces=(eth0 eth1 eth2) # which interfaces to auto-detect, in descending order of priority
interface="eth0" # the default/current interface
while true; do
newif="$interface"
for i in "${interfaces[@]}"; do
if $(ip link show dev "$i"); then
newif="$i"
fi
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'