Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / faststart
Created April 26, 2019 15:36
make MP4 files stream better by moving their "moov" atom to the front
#!/bin/sh
# script to make mp4 videos start fast
# (i.e. shifting their moov atoms to the front)
FNAME=$1
[ -f "$FNAME" ] || exit 1
TMPFNAME=`mktemp -u ${FNAME}.XXXXXX`
head -c128 "$FNAME" | grep -F moov -q
@geekman
geekman / strip-query-snippet.js
Created May 22, 2019 01:18
strips query string from selected URLs on page
// strip query string (or search params) from "/xyz/..". URLs
for (let a of document.querySelectorAll('a[href^="/xyz/"]')) {
let u = new URL(a.href.toString());
u.search = '';
a.href = u;
}
@geekman
geekman / ffmpeg-snippets.md
Last active April 22, 2024 13:06
some ffmpeg commands

create a list of filename,title list

for %f in (*.mp4) do @ffprobe -v error -of csv -show_entries format=filename:format_tags=title %f >> list.txt

resizing for uploading video reviews to sites

ffmpeg -i <input-file> -preset fast -crf 18 -vf scale=720:-2 -an output.mp4

flags:

  • scales to 720 x \
@geekman
geekman / subst-exec.sh
Created May 30, 2019 09:23
replaces patterns like "<? cmd ?>" by executing cmd
#
# awk one-liner to replace patterns like "<? cmd ?>" by executing cmd
# handy for use in config files "templates"
#
cat <<EOF | awk '{ if (match($0, /<\?(.*)?>/)) { cmd = substr($0, RSTART+2, RLENGTH-2-2); system(cmd) } else print }'
my directory has these files:
<? ls / ?>
EOF