Skip to content

Instantly share code, notes, and snippets.

View iwalton3's full-sized avatar

Izzie Walton iwalton3

View GitHub Profile
@iwalton3
iwalton3 / nfc-example.py
Created October 3, 2024 03:31
Example usage of pyscard to read and write second sector of xSiiD with password protection turned on.
#!/usr/bin/env python3
from smartcard.System import readers
from smartcard.CardRequest import CardRequest
from smartcard.Exceptions import CardRequestTimeoutException, CardConnectionException
import time
reader = readers()
conn = reader[0].createConnection()
@iwalton3
iwalton3 / write-nfc-file.sh
Last active September 29, 2024 17:26
Backup a small file on your xSiiD or similar while still allowing normal function (e.g. URL on scan) for unused space. File can be protected from deletion and also optionally protected from reading using password. Note you should still encrypt the file if it is sensitive! Please be careful as you can't recover password if forgotten!
#!/bin/bash
read -sp"Password (8 hex chars raw or string): " p
echo
if ! grep -q "^[0-9A-Fa-f]\{8\}$" <<< "$p"
then
echo "You provided a text password."
echo "Hashing with: echo -n \"PASSWORD\" | sha256sum"
echo "The password will be the first 8 chars of the hash."
p=$(echo -n "$p" | sha256sum)
p=${p:0:8}
@iwalton3
iwalton3 / clear-watched.js
Last active July 19, 2023 14:40
Clear Watched (for when you get 502 errors trying to remove watched videos from your YouTube watched later)
window.setInterval(
async() => {
let f = document.querySelector('.ytd-playlist-video-renderer .ytd-thumbnail-overlay-resume-playback-renderer');
if (f) {
f = f.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector('#menu yt-icon-button');
}
if (!f) {
f = document.querySelector('.ytd-playlist-video-renderer img[src="https://i.ytimg.com/img/no_thumbnail.jpg"]');
if (f) {
f = f.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector('#menu yt-icon-button');
@iwalton3
iwalton3 / ai-friend-exllama.py
Created May 31, 2023 02:32
Discord Exllama Chatbot
#!/usr/bin/env python3
from model import ExLlama, ExLlamaCache, ExLlamaConfig
from tokenizer import ExLlamaTokenizer
from generator import ExLlamaGenerator
import argparse
import torch
from timeit import default_timer as timer
torch.set_grad_enabled(False)
torch.cuda._lazy_init()
@iwalton3
iwalton3 / data-format.json
Created May 12, 2023 03:52
Message Splitter - Split chat messages into chunks for training GPTs
{
"data": "%data%"
}
@iwalton3
iwalton3 / jmpapi.ts
Last active March 15, 2023 05:07
Prototype Jellyfin Media Player Typescript API
interface JMPSettings {
appleremote: {
emulatepht: boolean;
};
audio: {
channels: 'auto' | '2.0' | '5.1,2.0' | '7.1,5.1,2.0';
/**
* auto or device name
*/
device: string;
@iwalton3
iwalton3 / jellyfin-cotton-candy.css
Last active March 13, 2023 22:33
Jellyfin Cotton Candy Theme
* {
scrollbar-width: thin;
}
.skinHeader,
html {
color: #222;
color: rgba(0, 0, 0, 0.87);
}
@iwalton3
iwalton3 / jellyscrubPluginHLS.js
Created February 21, 2023 04:38
Replacement "jellyscrubPlugin.js" for experimental HLS version of Jellyscrub.
class jellyscrubPlugin {
constructor({ playbackManager, events }) {
this.name = 'Jellyscrub Plugin';
this.type = 'input';
this.id = 'jellyscrubPlugin';
(async() => {
const api = await window.apiPromise;
const enabled = await new Promise(resolve => {
api.settings.value('plugins', 'jellyscrub', resolve);
@iwalton3
iwalton3 / BME280.py
Created June 11, 2022 05:08
ESP8266 BME280
from machine import I2C
import time
# BME280 default address.
BME280_I2CADDR = 0x76
# Operating Modes
BME280_OSAMPLE_1 = 1
BME280_OSAMPLE_2 = 2
BME280_OSAMPLE_4 = 3
@iwalton3
iwalton3 / boot.py
Created May 8, 2022 03:27
Window Fan Controller
# This file is executed on every boot (including wake-boot from deepsleep)
import gc
import ubinascii
def do_connect():
import network
sta_if = network.WLAN(network.STA_IF)
ap_if = network.WLAN(network.AP_IF)
if not sta_if.isconnected():
print('connecting to network...')