Skip to content

Instantly share code, notes, and snippets.

@Archonic944
Archonic944 / apply_z_offset.py
Last active September 13, 2025 17:13
Apply an arbitrary Z offset to .gx file (Can be greater than 1 or -1, tested with FlashForge Finder)
#!/usr/bin/env python3
"""
apply_z_offset_safe.py
Binary-safe Z offset applier for FlashForge .gx / generic G-code files.
Designed for use with printers that have broken distance sensors or can otherwise not calibrate the z axis.
FlashPrint provides an option for z offset but it only goes from -1 to 1.
- Reads and writes bytes; preserves ALL non-G-code bytes, line endings, and comments.
- Only modifies Z values on lines whose first non-space char is 'G' or 'M'.
- Tracks absolute/relative mode via G90 / G91 in the code portion of those lines.
# qtpy_esp32s2_i2s_stream.py
#
# Continuous 16-kHz mono recording → HTTP POST
# – no sample loss, no packet loss –
# tailored for Adafruit QT Py ESP32-S2 4 MB Flash / 2 MB PSRAM
#
import _thread, gc, time, network, usocket
from machine import Pin, I2S, reset
### ---------- user settings ---------- ###
// ==UserScript==
// @name MusicNerd Auto-Play, Button Selector, and Next
// @namespace http://tampermonkey.net/
// @version 2.1
// @description Auto-click play button, number-key-based select song, auto press next musicnerd.io
// @author archonic
// @match https://musicnerd.io/quiz/*
// @grant none
// ==/UserScript==
@Archonic944
Archonic944 / look_and_say.py
Created February 13, 2024 16:56
The look and say sequence, implemented in Python.
# Type a number and hit enter for that number's look-and-say product.
# Press enter without entering a number to get the next step after the previous product.
def look_and_say(num):
prev_val = None
occurrence = 0
new_seq = ""
for i in map(int, str(num)):
if i == prev_val:
occurrence += 1
elif prev_val is None:
@Archonic944
Archonic944 / gist:856c1d63cd4bfdfe1294db6cb178caa2
Created January 9, 2024 01:54
A pasting utility that I made for my science project
from openpyxl import Workbook, load_workbook
from pathlib import Path
import csv
from openpyxl.utils import get_column_letter
downloads_path = str(Path.home() / "Downloads")
src_block_path = downloads_path + "/closed_3.xlsx"
src_cells_start = "N1"
src_cells_end = "X5"
@Archonic944
Archonic944 / ParseUtility.java
Created December 21, 2023 17:07
A utility that allows you to parse space-separated, multi-line values from a Scanner as a table.
import java.util.Arrays;
import java.util.Scanner;
public class ParseUtility {
static String[] asArray(String line){
return line.split(" ");
}
static int[] asIntArray(String line){
return asIntArray(asArray(line));