Skip to content

Instantly share code, notes, and snippets.

@geekman
geekman / webcrypto-hdkf.html
Last active April 11, 2019 17:26
Web Crypto using HKDF
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<style>
* { font-family: sans-serif; font-size: 16px; }
input { font-family: monospace; }
input[readonly] { border: 1px solid #eee; }
div.row { padding: .8em 0; }
@geekman
geekman / remove-cruft.sh
Last active April 9, 2019 15:52
script to remove cruft from Ubuntu post-install
#!/bin/sh
# run as root
apt remove cloud-init unattended-upgrades popularity-contest landscape-common update-manager-core
apt autoremove
# disable upgrade units & timers
systemctl disable --now apt-daily{,-upgrade}.{timer,service}
@geekman
geekman / clock.html
Created April 2, 2019 08:52
clock display HTML snippet. encode onto a QR for quick & dirty time display
data:text/html,<script>setInterval("d = new Date(); document.body.innerHTML = `<h1>${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}`", 500);</script><body>
@geekman
geekman / pin-entry-anim.html
Last active March 13, 2019 13:26
PIN entry animation
<!-- PIN entry animation -->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<style>
.h {
position: relative;
@geekman
geekman / uboot-image.bt
Created December 8, 2018 09:11
010 editor template for U-Boot images that i hacked up
//
// quick 010 Editor template for u-boot images
// darell tan 2018.12.08
//
enum <uchar> IH_TYPES {
TYPE_INVALID,
TYPE_STANDALONE,
TYPE_KERNEL,
TYPE_RAMDISK,
@geekman
geekman / ren_dated_file.py
Created September 16, 2018 16:40
renames a dated file into another date format
#!/usr/bin/env python
#
# renames files with date JAN_18 to "<prefix> 2018-01"
# darell tan 2018.09.14
#
from __future__ import print_function
import sys
import os
import re
@geekman
geekman / boot.cmd
Created July 21, 2018 15:54
boot-time device tree overlays with U-Boot
part uuid ${devtype} ${devnum}:${bootpart} uuid
setenv bootargs console=${console} root=PARTUUID=${uuid} rw rootwait
if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/zImage; then
if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
fdt addr ${fdt_addr_r}
fdt resize
setexpr fdtovaddr ${fdt_addr_r} + F000
@geekman
geekman / fixer.js
Created May 12, 2018 11:07
JS to "fixup" ASCII art on old Apple docs, e.g https://support.apple.com/kb/TA40730
document.querySelector('.SUMMARY').childNodes.forEach(function(e) {
if (e.nodeType == Node.TEXT_NODE && (e.textContent.match(/[+|-]/g) || []).length > 2) {
var n = document.createElement('code');
n.textContent = e.textContent.replace(/^[\r\n]*(.*)[\r\n]*$/, '$1');
n.style = 'white-space:pre-wrap';
e.parentNode.replaceChild(n, e);
}
});
@geekman
geekman / script.ps1
Created March 29, 2018 05:10
making sure your USB network adapter doesn't take over your default gateway & Internet connection
# to verify, use `route print` and check the order in which the interfaces are listed
Get-NetAdapter | Where-Object {$_.InterfaceDescription -like '*USB*'} | Set-NetIPInterface -InterfaceMetric 9999
@geekman
geekman / moveup.py
Last active July 12, 2023 17:01
removes a block within a file and shifts its following contents "upwards"
# moves up file data at current pos to specified to_offset
def moveup(f, to_offset, block_size=4096):
assert f.tell() > to_offset
while True:
data = f.read(block_size)
newpos = f.tell()
f.seek(to_offset)
to_offset += len(data)