Skip to content

Instantly share code, notes, and snippets.

View hd-genius's full-sized avatar

Roy Stewart hd-genius

View GitHub Profile
@hd-genius
hd-genius / xbox-update-drive.py
Last active January 10, 2026 11:48
Python script to create an offline system update (OSU) drive for xbox one and series consoles
# *************************************************************************** #
# Copyright 2025 Roy Stewart. All rights reserved. #
# Released under the GPL3 license. #
# License URL: https://www.gnu.org/licenses/gpl-3.0.en.html#license-text #
# *************************************************************************** #
import os
from pathlib import Path
import shutil
from urllib.request import urlretrieve
function *primerNumbers() {
// Special case to handle the first prime number
const previousPrimes = [2];
yield 2;
for (const current = 2; true; current++) {
const isPrime = !previousPrimes.some(x => current % x === 0);
if (isPrime) {
yield current;
}
@hd-genius
hd-genius / phoneNumberInput.js
Created May 21, 2021 11:00
A simple phone number input element for US phone numbers. Implemented in plain javascript.
class PhoneNumberInput extends HTMLInputElement {
constructor() {
super();
this.setAttribute('type', 'tel');
this.addEventListener('input', () => this.formatInput());
}
formatInput() {
const phoneNumberSections = [];
if (this.areaCode) {
@hd-genius
hd-genius / factorsCalculator.hs
Created May 21, 2021 10:59
Prime Factors Calculator
import System.Environment
import Data.List
isFactorOf :: Integer -> Integer -> Bool
isFactorOf y x = y `mod` x == 0
possibleFactorsOf :: Integer -> [Integer]
possibleFactorsOf n = [2..n]
smallestFactorOf :: Integer -> Integer
@hd-genius
hd-genius / tree-view.css
Last active May 31, 2020 16:42
Custom tree view element implemented in JavaScript and CSS.
tree-group, tree-view {
display: flex;
flex-direction: column;
}
tree-group {
--indentation-size: 1em;
position: relative;
left: var(--indentation-size);
}
@hd-genius
hd-genius / custom-element.js
Last active February 15, 2021 11:51
A decorator that simplifies registering custom components
// The decorator that simplifies registration
function RegisterCustomElement(elementName, options) {
return classToRegister => {
window.customElements.define(elementName, classToRegister, options);
};
}
// An example component registered using the decorator
@RegisterCustomElement('my-element')
class MyElement extends HTMLElement {