Skip to content

Instantly share code, notes, and snippets.

View James-E-A's full-sized avatar
🕳️
school...

James E. A. James-E-A

🕳️
school...
View GitHub Profile
@James-E-A
James-E-A / simple_tkinter_threaded_helper.py
Last active October 4, 2024 21:30
simple tkinter multithreaded comunication
import queue
import threading
from tkinter import TclError
import weakref
# Thread-safe workaround for CPython issue #47655
# with a simple, foolproof interface
# NOTE: this does not work around PyPy issue #5066
@James-E-A
James-E-A / tkinter_iss47655_polyfill.py
Last active August 29, 2024 14:23
tkinter module send data with virtual event / event_generate
__all__ = ['check_for_bug', 'patch_bug', 'auto_patch_bug']
import logging
import os
import pdb
import platform
import sys
import threading
import tkinter
@James-E-A
James-E-A / configuration.nix.inc
Last active August 11, 2024 02:36
NixOS custom kernel with AMDGPU SI & CIK support
# Custom Kernel to use AMDGPU driver with Radeon HD 7790, HD 7750-7970, HD 7790, R7 240, R7 250, R7 260, R9 270, R9 280
# https://www.x.org/wiki/RadeonFeature/#:~:text=Southern%20Islands&text=Sea%20Islands
# https://wiki.archlinux.org/title/AMDGPU#:~:text=Compile%20kernel%20which%20supports%20amdgpu%20driver
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/amdgpu/Kconfig?h=v6.10&id=0c3836482481200ead7b416ca80c68a29cfdaabd#n37
boot.kernelPatches = [ {
name = "amdgpu-si-cik";
patch = null;
extraConfig = ''
DRM_AMDGPU_SI y
DRM_AMDGPU_CIK y
@James-E-A
James-E-A / rtc_ex.mjs
Last active August 7, 2024 20:10
WebRTC simple perfect negotiation wrapper
// To use the functions exported by this module,
// you must already have an existing_channel
// connecting the two endpoints -- a so-called
// "signaling server" -- before you can establish
// a WebRTC connection.
/*
const config = { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] };
const _signaling_server = new MessageChannel();
_signaling_server.port1.start();
@James-E-A
James-E-A / maybeuninit_struct_interface.rs
Last active May 1, 2024 18:01
Rust write to fields of MaybeUninit struct/array
/* Example Usage:
#[repr(C,packed)]
struct Foo {
data1: [u8; 3],
data2: [u8; 5]
}
let baz: Foo = {
let mut baz_wip = core::mem::MaybeUninit::<Foo>::uninit();
// 1. Writing fields:
@James-E-A
James-E-A / randombytes.rs
Last active April 24, 2024 20:51
rust randombytes function that returns an array
/* Written on Rust 1.77.2 (Stable), should run on even older builds.
Usage Example:
let my_buffer: [u8; 42] = randombytes().unwrap();
*/
extern crate getrandom; // https://github.com/rust-random/getrandom
use core::mem::MaybeUninit;
@James-E-A
James-E-A / reify_error_event.js
Last active May 13, 2024 15:23
JavaScript convert error event to error object
// Step 1. construct object
let obj = await new Promise((resolve, reject) => {
const obj_pending = API_CONSTRUCTOR();
obj_pending.addEventListener(
'error',
(event) => void reject(new Error(
`${event.target.__proto__.constructor.name}: ${event.type} event`,
{cause: event}
)),
@James-E-A
James-E-A / get_transferables.js
Last active March 28, 2024 20:20
Javascript recursively get all transferables from object
// This is also a demonstration of the Z-combinator.
// h/t https://thenewobjective.com/types-and-programming-languages/deriving-the-z-combinator
const Z = (f => (u => f((...x) => u(u)(...x)))(u => f((...x) => u(u)(...x))));
/* Example usage:
a = new MessageChannel().port1;
b = new ArrayBuffer(42);
my_obj = {a, x: {b, a_again: a}}
get_transferables(my_obj);
@James-E-A
James-E-A / popups.txt
Last active March 25, 2024 21:46
annoy
! James Edington Administrator – Popups
||accounts.google.com/gsi/iframe$subdocument
@James-E-A
James-E-A / uah_transcript.user.js
Last active October 8, 2024 16:27
UAH get machine-readable transcript
// ==UserScript==
// @name UAH Transcript to TXT
// @namespace 9ae3b270-19ab-3cc1-827e-42cc8f3bf51c
// @version 0.0.4
// @match https://ssbprod.uah.edu/PROD/bwskotrn.P_ViewTran
// @grant none
// @namespace james.edington@uah.edu
// ==/UserScript==
// To install from GitHub, click the "Raw" button on the top-right.