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
# 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
@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.);
@thinkier
thinkier / dsa-notification.php
Last active April 26, 2020 01:57
PHP Script to fetch the RSS feed to debian security and send a webhook to discord when it has a new one. (This generates dsaCache where it's ran.) Prerequisite: PHP>= 5.6, php5-cron, php5-cli, read and write access to local directory.
<?php
/**
* Usage: php dsa-notification.php
* In cron (hourly): 0 * * * * cd /absolute/path/of/your/directory && php dsa-notification.php
*/
$hooks = ["https://discordapp.com/api/webhooks/{webhook.id}/{webhook.token}"];
if (php_sapi_name() == "cli") {
$knownDSA = json_decode(file_get_contents("dsaCache"), true);
$rssFeed = simplexml_load_string(file_get_contents("https://www.debian.org/security/dsa"));
@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 / 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 / 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 / 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 / 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 / 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 / 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: