Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import sys
temps = sys.argv[1:]
for ln in sys.stdin:
if ln.rstrip() == 'M600':
sys.stdout.write('M104 S' + temps.pop(0) + '\n')
else:
sys.stdout.write(ln)
#!/usr/bin/env python3
import random
from colormath.color_objects import LabColor, sRGBColor
from colormath.color_conversions import convert_color
from colormath.color_diff import delta_e_cie2000
print("<style>body { font-size: 24pt; font-family: monospace; }</style>");
def random_srgb():
return sRGBColor(
#!/usr/bin/env python3
import sys
temps = sys.argv[1:]
for ln in sys.stdin:
if ln.rstrip() == 'M600':
sys.stdout.write('M104 S' + temps.pop(0) + '\n')
else:
sys.stdout.write(ln)
@kmcallister
kmcallister / slant-rack.scad
Created March 27, 2021 03:33
Parametric culture slant rack
// Copyright 2021 Keegan McAllister
// License: CC-BY 4.0
// https://creativecommons.org/licenses/by/4.0/
include <MCAD/units.scad>
/* [Part selection] */
// Part selection
part = "assembly"; // [assembly, plate, grid, rail, base]
module menger_sponge(n) {
if (n <= 0) {
cube(center=true);
} else {
for (x=[-1:1]) {
for (y=[-1:1]) {
for (z=[-1:1]) {
if (abs(x)+abs(y)+abs(z) >= 2) {
scale(1/3)
translate([x,y,z])
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
#define PERIOD 5000
DHT dht(DHTPIN, DHTTYPE);
void setup() {
@kmcallister
kmcallister / calc
Created July 28, 2019 17:11
Weight tracking scripts
#!/bin/sh
#set -e
./ewma.py < log > smoothed
echo
./progress.py "$@" < smoothed
echo
gnuplot < weight-graph.gpl
#!/usr/bin/env python3
import time
import sys
repeats = 12
phases = [
('Inhale', 4),
('Hold', 2),
('Exhale', 6),
@kmcallister
kmcallister / logger.py
Created July 4, 2019 06:17
Dead-simple DS1054Z data logger
#!/usr/bin/env python
import time
import visa
IP_ADDR = '192.168.50.219'
INTERVAL = 1.0
rm = visa.ResourceManager('@py')
scope = rm.open_resource('TCPIP::%s::INSTR' % (IP_ADDR,))
@kmcallister
kmcallister / bot.py
Created June 12, 2019 21:35
LED strip code
#!/usr/bin/env python
import itertools
import colorsys
import datetime
import irc.bot
import random
import socket
import struct
import sys
import re