Skip to content

Instantly share code, notes, and snippets.

View alexhulbert's full-sized avatar
🐞
debugging

Alex Hulbert alexhulbert

🐞
debugging
View GitHub Profile
@alexhulbert
alexhulbert / mrtd-to-firmware.py
Created September 10, 2025 00:51
Gets Google OVMF firmware based on MRTD
#!/usr/bin/env python3
import sys, os, subprocess, tempfile, urllib.request
with tempfile.TemporaryDirectory() as d:
# Download proto files
urllib.request.urlretrieve("https://raw.githubusercontent.com/google/gce-tcb-verifier/refs/heads/main/proto/endorsement.proto", f"{d}/endorsement.proto")
os.makedirs(f"{d}/google/protobuf", exist_ok=True)
urllib.request.urlretrieve("https://raw.githubusercontent.com/protocolbuffers/protobuf/main/src/google/protobuf/timestamp.proto", f"{d}/google/protobuf/timestamp.proto")
# Download binarypb
@alexhulbert
alexhulbert / fixquotes.py
Created April 13, 2023 18:21
Edits jsonnet files to use multiline strings
import os
import difflib
import re
# NOTES:
# This doesn't work on multiline strings that end with a backslash
# - The fix would be to odd number of backslashes in string_pattern
# This doesn't automatically indent the multiline strings
# - The fix would be to match the whitespace characters at the beginning
# of the line for each string and append it to the \n on the inner_string line
@alexhulbert
alexhulbert / __init__.py
Last active December 4, 2025 04:13 — forked from tarikjn/friedrich.py
Friedrich A/C platform for home-assistant
from homeassistant.const import Platform
async def async_setup_entry(hass, entry):
hass.config_entries.setup_platforms(entry, [Platform.CLIMATE])
return True
@alexhulbert
alexhulbert / userscript.js
Last active May 5, 2022 21:21
OrganizeYourMusic Import/Export
const w = window
const importBtn = document.createElement('label')
importBtn.style.display = 'inline-block'
importBtn.style.cursor = 'pointer'
importBtn.style['margin-right'] = '20px'
importBtn.setAttribute('class', 'btn btn-primary')
importBtn.setAttribute('id', 'importBtn-btn')
importBtn.innerHTML = 'Import'
import os
from datetime import datetime, timedelta
import todoist # pip3 --target . install todoist-python
API_KEY = os.environ['TODOIST_API_KEY']
PROJ_ID = int(os.environ['TODOIST_PROJECT_ID'])
LABEL_ID = int(os.environ['TODOIST_LABEL_ID'])
RUN_GAP_HRS = 48
def lambda_handler(event, context):
@alexhulbert
alexhulbert / runjs.html
Created February 23, 2016 19:09
A small utility for testing Javascript in an HTML preview window. See also: https://www.squarefree.com/shell/shell.html
<html>
<head>
<script>
console.print = function(text) {
document.write(text.replace(/\n/g, '<br>'));
}
console.log = function(text) {
console.print(text + '\n');
}
console.error = function(text) {
cd $LIB_PATH
mkdir bin
wget http://www.tortall.net/projects/yasm/releases/yasm-$YASM_VER.tar.gz
wget http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VER.tar.gz
tar -xvf yasm-$YASM_VER.tar.gz
cd yasm-$YASM_VER
./configure --prefix=$LIB_PATH/bin --bindir=$LIB_PATH/bin
make
make install
@alexhulbert
alexhulbert / fixPearson.js
Created May 1, 2014 01:32
Fixes a bug with my PearsonSuccessNet online Science Book.
var jquery_new = document.createElement('script');
jquery_new.src = '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(b);
$(frames['content'].frames['menu'].document).find('body').attr('marginwidth','');
$(frames['content'].frames['tabs'].document).find('body').attr('marginwidth','');
@alexhulbert
alexhulbert / uiproto
Created March 19, 2014 14:19
GUI Page prototyping
assumes:
p = page number (starts @ 0)
n = # of devices on page
a = number of devices connected (starts @ 1)
list actual devices:
for (int i = n*p; i < min(n*p+n, a); i++) {
...
}