Skip to content

Instantly share code, notes, and snippets.

View danthedaniel's full-sized avatar
👨‍💻
⠠⠵

Daniel danthedaniel

👨‍💻
⠠⠵
View GitHub Profile
@danthedaniel
danthedaniel / main.py
Created March 2, 2025 04:15
Pi Pico 2W LED control web server
import network
import socket
import json
from machine import Pin
LED = Pin("GP21", Pin.OUT)
FAVICON = (
@danthedaniel
danthedaniel / minecraft-text-component-json-schema.json
Created February 24, 2025 04:15
A comprehensive JSONSchema document describing the Minecraft text component JSON serialization format as of Minecraft 1.21
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"definitions": {
"Component": {
"type": "object",
"properties": {
"text": { "type": "string" },
"translate": { "type": "string" },
"with": {
"type": "array",
import time
import board
import digitalio
import usb_hid
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
def init_pin(pin_id):
pin = digitalio.DigitalInOut(pin_id)
import socket
import select
import struct
import time
import signal
import re
import sqlite3
import time
import os
@danthedaniel
danthedaniel / treasure_hunt.py
Last active September 15, 2023 18:52
Minecraft treasure hunt script using GPT-3.5 for location descriptions
import socket
import select
import struct
import time
import signal
import random
import re
import http.client
import json
import os
@danthedaniel
danthedaniel / playtimes.py
Last active September 4, 2023 22:28
Python script to tabulate Minecraft play times from a Paper server (outputs HTML file to dynmap web folder).
import os
import gzip
import re
from collections import defaultdict
from datetime import datetime, timedelta
def log_file_lines(directory):
sorted_files = sorted(os.listdir(directory))
for filename in sorted_files:
if filename == 'latest.log':
const stateLabels = ["A", "B", "C", "D", "E", "F", "G"] as const;
type StateLabel = typeof stateLabels[number];
type Direction = "left" | "right";
interface Edge {
write: 0 | 1;
move: Direction;
next: StateLabel;
}
@danthedaniel
danthedaniel / compressor.py
Last active February 3, 2019 01:09
Python Run-Length Encoder
import sys
from dataclasses import dataclass
from itertools import groupby
from typing import List
from tqdm import tqdm
@dataclass
class Run:
@danthedaniel
danthedaniel / git_prompt.sh
Last active September 17, 2019 18:27
.bash_profile/.bashrc snippet that will show git information (branch, commits ahead and behind) in your prompt
# Add the following code to ~/.bash_profile or ~/.bashrc
function git_branch() {
git rev-parse --abbrev-ref HEAD 2> /dev/null
}
function git_prompt() {
local branch=$(git_branch)
local deltas=$(git rev-list --left-right --count $branch...origin/$branch 2> /dev/null)
local stats=$(git diff --stat 2> /dev/null | tail -n 1)
@danthedaniel
danthedaniel / init.c
Last active February 9, 2023 13:21
DayZ SA Init Script - PvP Classes
void main()
{
Hive ce = CreateHive();
if (ce)
ce.InitOffline();
Weather weather = g_Game.GetWeather();
weather.GetOvercast().SetLimits(0.0, 1.0);
weather.GetRain().SetLimits(0.0, 1.0);