Skip to content

Instantly share code, notes, and snippets.

View thinkier's full-sized avatar
🍑
uwu?

thinkier

🍑
uwu?
  • Victorian Government
  • Melbourne, Australia
View GitHub Profile
@thinkier
thinkier / nano_matter_lightbulb_colour_decomissioning.ino
Created May 21, 2024 11:52
Arduino Nano Matter (Community Preview) sketch with colour-changing LED controls & an option to decomission the Matter accessory.
/*
Matter color lightbulb example for the Nano Matter
The example shows the basic usage of the Arduino Matter API.
The example lets users control the onboard RGB LED on the Nano Matter as a Matter lightbulb.
It's possible to switch the LED on/off, adjust the brightness and the color as well.
The device has to be commissioned to a Matter hub first.
Compatible boards:
@thinkier
thinkier / UUIDv7.swift
Last active February 19, 2024 23:35
Swift script to generate UUID version 7 in accordance with draft-ietf-uuidrev-rfc4122bis-14. Can generate about 4k/ms on a Release profile on my A16 Bionic.
/// License: Public Domain, or MIT License where Public Domain is not available
import Foundation
extension UUID {
/// Implementation of UUIDv7 generator based on the specifications in draft-ietf-uuidrev-rfc4122bis-14
///
/// UUIDv7 is generated without using any additional methods of Monotonicity Guarantees. (Section 6.2) As such, the UUID is accurate to the millisecond only.
///
// Field and Bit Layout:
@thinkier
thinkier / PrusaConnectUploader.sh
Last active October 2, 2023 12:47
Upload a libcamera-jpeg snapshot to Prusa Connect using this shell script and curl!
#!/bin/bash
TOKEN='YOUR_TOKEN_HERE'
FINGERPRINT=$(hostname | sha1sum)
IMAGE_PATH='/tmp/snapshot.jpg'
libcamera-jpeg -n --rotation 180 -o "$IMAGE_PATH"
curl -X PUT \
-H "Token: $TOKEN" \
-H "Fingerprint: $FINGERPRINT" \
@thinkier
thinkier / raidmon.py
Created June 1, 2023 07:59
Discord webhook for reporting RAID drive failure(s)
#!/usr/bin/python3
from socket import gethostname
from requests import post
WEBHOOK_URL=''
USERNAME=gethostname() + ' /proc/mdstat'
with open('/proc/mdstat') as f:
mdstat = f.read()
@thinkier
thinkier / tax.ts
Created June 10, 2022 05:45
Australian Marginal Income Tax calculator (dumps to csv)
const brackets: Array<[number, number]> = [
[ 0, 0],
[ 18200, 19],
[ 45000, 32.5],
[ 120000, 37],
[ 180000, 45]
];
console.log("Income", "Tax");
@thinkier
thinkier / github_webhook.php
Created April 4, 2022 07:19
Automanted code deployment based on github webhooks (on pull request merge into the main branch)
<?php
const REPO_DIR = "/env";
const DISCORD_WEBHOOK = "...";
const TOKEN = "...";
if (key_exists('auth', $_GET) && $_GET['auth'] == TOKEN) {
$payload = json_decode($_POST['payload'], true);
if (key_exists("action", $payload) &&
$payload["action"] == "closed" &&
@thinkier
thinkier / pickletime.rs
Created May 7, 2020 12:35
Convert unix time to skyblock time
const TIME_OFFSET: f64 = 1559829300.0;
pub fn unix_to_date(mut unix: f64) -> String {
let time = (unix - TIME_OFFSET) as u64;
let year = time / 12 / 31 / 1200;
let month = (time / 31 / 1200) % 12;
let day = ((time / 1200) % 31) + 1;
format!("Year {}, {} {}{}", year, month_str(month), day, day_suffix(day))
@thinkier
thinkier / update-usernames.sh
Last active April 26, 2020 02:01
Updates usernames on your old git repositories.
#!/bin/sh
###
### License: Public Domain, or the equivalent in your jurisdiction
### USE AT YOUR OWN RISK, I WILL NOT TAKE ANY RESPONSIBILITY IF YOU USED THIS AND FUCKED UP YOUR REPOSITORY.
###
### # Description
### Updates usernames on your old repositories.
###
# I know it's a bad hack but I'm too lazy to even do the replace command in an editor
@thinkier
thinkier / rh4.rs
Created November 30, 2019 08:42
Calculate how different armors tank Revenant Horror 4 in Hypixel Skyblock
fn main() {
let base_hp = 479.;
let base_def = 58.;
print!("Revenant Armor (50k)");
let mut rev = RevArmor::new(base_hp, base_def, 280. * 3., 5., 5., 0.);
tank(&mut rev);
print!("Revenant Armor (25k)");
let mut rev = RevArmor::new(base_hp, base_def, 260. * 3., 5., 5., 0.);
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
fields=0 48 17 111 2 46 47 49 1
sort_key=0
sort_direction=1
hide_threads=0
hide_kernel_threads=1
hide_userland_threads=0
shadow_other_users=0
show_thread_names=1