Skip to content

Instantly share code, notes, and snippets.

@ericsampson
ericsampson / ServiceWithOptionsExample.cs
Last active November 15, 2020 19:22
Configuration pattern and ConfigureServices
// I have a service that needs to be initialized with a FooOptions and then added to the DI container.
// I also want to have IOptions<FooOptions> in the DI container to allow injection in other methods.
// How should I write my AddFoo extension method to support this?
public void ConfigureServices(IServiceCollection services)
{
services.AddFoo(fooOptions =>
{
configuration.GetSection("FooOptions").Bind(fooOptions)
fooOptions.param = "override";
@kmobs
kmobs / frequencytester.md
Last active March 11, 2026 21:30
Frequency Tester

Frequency Testing

This will allow you to test a specific frequency that you hear when you do your resonance testing in Klipper and potentially track down where extra peaks are coming from. If something is rattling at a specific frequency, you can specify that frequency and feel around the printer until you track it down.

Code was adopted by zifnab from somewhere in Klipper.

Usage

You have to have [resonance_holder] in your printer.cfg.

The command is HOLD_RESONANCE AXIS=<axis> FREQ=int SECONDS=<seconds>

@dupontgu
dupontgu / code.py
Last active February 5, 2026 15:12
CircuitPython WiFi HTTP Sensor Template
import time
import wifi
import socketpool
import wifi
import mdns
from adafruit_httpserver import (GET, JSONResponse, Request, Server)
WIFI_SSID = "your-wifi"
WIFI_PASSWORD = "your-password"
POLL_INTERVAL_S = 31