This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function error_fromEvent(event) { | |
const error = new Error(event.message, {cause: event}); | |
if (event.type === 'error') | |
error.name = `${event.target.__proto__.constructor.name}Error`; | |
else | |
error.name = `${event.__proto__.constructor.name}`; | |
return error; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function idb_open(name, version, onupgradeneeded=undefined) { | |
return new Promise((resolve, reject) => { | |
"use strict"; | |
const req = indexedDB.open(name, version); | |
req.onsuccess = (event) => void resolve(event.target.result); | |
req.onerror = (event) => void reject( | |
new Error(`${event.target.__proto__.constructor.name}: ${event.type}`, {cause: event}) | |
); | |
req.onupgradeneeded = async (event) => { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""*BufferLike*, a quasi-ponyfill for collections.abc.Buffer | |
When collections.abc.Buffer is available, exports it directly. | |
Otherwise, crudely constructs an Abstract Base Class via mass ABC.register(). | |
May not be suitable for all use-cases.""" | |
try: | |
# version_info >= (3, 12) | |
from collections.abc import Buffer as BufferLike | |
except ImportError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function offmainthread(f, options) { | |
// Converts long-running synchronous CPU-bound | |
// function or eval-able string | |
// into an asynchronous WebWorker-based function | |
// to avoid blocking the main thread. | |
// DOES NOT CURRENTLY SUPPORT WASM FUNCTIONS. | |
"use strict"; | |
options = options || {}; | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name UAH Transcript to TXT | |
// @version 0.0.3 | |
// @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. | |
// Requires Userscript support: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! James Edington Administrator – Popups | |
||accounts.google.com/gsi/iframe$subdocument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get an element by XPath. | |
* @param {string} expression - A string representing the XPath to be evaluated. | |
* @param {Element} [context] - The context node. Defaults to the current document. | |
* @param {Document} [document] - The document against which evaluate() will be called. Defaults to the context node's document. | |
* @param {boolean} [ordered=true] - Whether to return the "first" node selected by the expression. If false, allows the XPath engine to return an arbitrary node selected by the expression. | |
* @returns {Element|null} | |
*/ | |
function getElementByXPath(expression, context = null, document = null, ordered = true) { | |
if (context === null) context = window.document; |
NewerOlder