Skip to content

Instantly share code, notes, and snippets.

def split_status(text: str, length: int = 280, footer: bool = False) -> list[str]:
text = text.replace("\r", "").strip()
lines = text.split("\n")
out = []
cur = []
curs = 0
fotempla = "\n(%s/%s)"
if footer:
length -= len(fotempla)

Hello World

import RPi.GPIO as GPIO
import random
import time
#basepins = 14, 15, 18, 23, 24, 25, 8
#extrapins = 7, 11, 9, 10, 22, 27, 17, 2, 3, 4
#pins = list(basepins + extrapins)
@EllieTheYeen
EllieTheYeen / handlediscordwebhook.php
Created July 20, 2025 00:29
How to actually handle Discord interaction webhook. Keep in mind you must return the correct response code dependent if signature is valid or not which this code does. Unlike most API's on almost every single API I have worked with the data to be validated is including the prepended timestamp but now that this is solved, good luck
<?php
ignore_user_abort(true);
$sign = $_SERVER['HTTP_X_SIGNATURE_ED25519'] ?? '';
$stam = $_SERVER['HTTP_X_SIGNATURE_TIMESTAMP'] ?? '';
if (strlen($sign) !== 128) {
http_response_code(405);
echo "Bad signature length\n";
#error_log("Bad signature length " . strlen($sign) . " when it needs 128 ");
import time, shutil, os
class AtomicWrittenFile:
def __init__(self, name, mode="w"):
self.temp = f"{name}.{int(time.time()):X}.{os.getpid()}.tmp"
self.file = open(self.temp, mode)
self.name = name
def __enter__(self):
return self.file
@EllieTheYeen
EllieTheYeen / vectors.rs
Created July 4, 2025 22:21
Rust Swissling Test
#[allow(unused)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Vector2 {
pub x: f64,
pub y: f64,
}
#[allow(unused)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Vector3 {
def itrd(obj, file=None):
stack = []
path = "obj"
pos = 0
def push(pathh, ob):
nonlocal obj, pos, path
stack.append((obj, pos, path))
obj, pos, path = ob, 0, pathh
@EllieTheYeen
EllieTheYeen / listdirs.ru
Last active May 17, 2025 16:16
List all subdirectories Rust
use std::path::Path;
fn main() {
let path = Path::new(".").canonicalize().unwrap();
println!("{:?}", path);
listdir(path.as_path());
}
fn listdir(path: &Path) {
for a in path.read_dir().unwrap() {
user yeen;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
@EllieTheYeen
EllieTheYeen / Application.php
Last active April 26, 2025 16:34
File change monitor post http example for NextCloud. May need <types><filesystem/></types> set in appinfo/info.xml to function. Could not find a single good example how to monitor file changes in NextCloud so posting this
<?php
declare(strict_types=1);
namespace OCA\YeenMonitor\AppInfo;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\EventDispatcher\IEventDispatcher;