Skip to content

Instantly share code, notes, and snippets.

@daniel-thompson
daniel-thompson / example.sh
Created May 11, 2022 17:48
Quick 'n dirty GNOME screencast concatenation
cd ~/Videos/Screencasts
# Generate the list of file to be joined. The `sort -n` is a bit paranoid but
# ensures this gist works on directories containing 9.webm and 10.webm !
ls *.webm | sort -n | sed -e "s/^/file '/" -e "s/\$/'/" > mywork.list
# Join everything together and place the output in the parent diectory
# (so that *.webm never matches the spliced file).
ffmpeg -f concat -safe 0 -i mywork.list -c copy mywork.webm
@daniel-thompson
daniel-thompson / dmesg.txt
Created July 4, 2018 10:45
SCSI, SD and MMC activity during boot
root@linaro-alip:~# dmesg | egrep '(sd|mmc|scsi)'
[ 3.427017] scsi host0: ufshcd
[ 3.546211] scsi 0:0:0:49488: Well-known LUN TOSHIBA THGBF7G8K4LBATRB 0300 PQ: 0 ANSI: 6
[ 3.565778] scsi 0:0:0:49456: Well-known LUN TOSHIBA THGBF7G8K4LBATRB 0300 PQ: 0 ANSI: 6
[ 3.572829] scsi 0:0:0:49476: Well-known LUN TOSHIBA THGBF7G8K4LBATRB 0300 PQ: 0 ANSI: 6
[ 3.581358] scsi 0:0:0:0: Direct-Access TOSHIBA THGBF7G8K4LBATRB 0300 PQ: 0 ANSI: 6
[ 3.590301] scsi 0:0:0:1: Direct-Access TOSHIBA THGBF7G8K4LBATRB 0300 PQ: 0 ANSI: 6
[ 3.596773] sd 0:0:0:0: [sda] 6335488 4096-byte logical blocks: (26.0 GB/24.2 GiB)
[ 3.604485] sd 0:0:0:0: [sda] Write Protect is off
[ 3.663635] sdhci: Secure Digital Host Controller Interface driver
@daniel-thompson
daniel-thompson / crc32_extractor.c
Created July 3, 2018 10:18
Simple CRC based randomness extractor/whitener
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#define DIGESTSZ 4
#define FRAMESZ 7
#define CHUNK FRAMESZ
static const uint32_t table[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@daniel-thompson
daniel-thompson / parallel.bash
Created November 13, 2017 19:50
bash job server
# `parallel <cmd...>` works similarly to `<cmd...> &` but limits the
# maximum job count to prevent over-zealous memory consumption when
# batch processing huge numbers of files.
parallel () {
while [ "$(jobs | wc -l)" -ge $((3 * $(nproc) / 2)) ]
do
wait -n
done
"$@" &
}
@daniel-thompson
daniel-thompson / .config
Created October 13, 2017 13:55
Example AArch64 buildroot configuration
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2017.02-rc3-01411-g10ac06496cde-dirty Configuration
#
BR2_HAVE_DOT_CONFIG=y
BR2_HOST_GCC_AT_LEAST_4_5=y
BR2_HOST_GCC_AT_LEAST_4_6=y
BR2_HOST_GCC_AT_LEAST_4_7=y
BR2_HOST_GCC_AT_LEAST_4_8=y
BR2_HOST_GCC_AT_LEAST_4_9=y
@daniel-thompson
daniel-thompson / 0001-usb-hub-Treat-all-hubs-as-self-powered.patch
Last active September 22, 2017 11:49
[PATCH] usb: hub: Treat all hubs as self-powered
From f7e2c2b19ea87fd300c3732ce7c1eb93cdad03c7 Mon Sep 17 00:00:00 2001
From: Daniel Thompson <daniel.thompson@linaro.org>
Date: Fri, 22 Sep 2017 12:40:08 +0100
Subject: [PATCH] usb: hub: Treat all hubs as self-powered
This works around a board misconfiguration on the poplar by treating
all hubs as self-powered. This effectively disables all the code in the
kernel to prevent hubs from drawing too much power. USB sockets must be
current limited so physical harm is unlikely... but now an overloaded
bus may end up with all devices being reset (rather than than the
@daniel-thompson
daniel-thompson / gist:25edcda403037629210b60a34f51a799
Created June 22, 2017 15:40
Latency at 64, 184 and 304 seconds
[ 0.021463] PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
[ 0.050940] 64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=28.5 ms
[ 1.045819] 64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=23.1 ms
[ 2.048649] 64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=24.4 ms
[ 3.050729] 64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=25.6 ms
[ 4.060123] 64 bytes from 8.8.8.8: icmp_seq=5 ttl=56 time=34.0 ms
[ 5.048851] 64 bytes from 8.8.8.8: icmp_seq=6 ttl=56 time=22.3 ms
[ 6.050887] 64 bytes from 8.8.8.8: icmp_seq=7 ttl=56 time=23.6 ms
[ 7.050986] 64 bytes from 8.8.8.8: icmp_seq=8 ttl=56 time=22.7 ms
[ 8.110527] 64 bytes from 8.8.8.8: icmp_seq=9 ttl=56 time=82.1 ms
wychelm$ mkdir -p Documents/Wiki
wychelm$ cat > Documents/Wiki/Demo.md <<EOF
# Markdown title
## This sub-title will appear in kb help
If you want to really document what the fragment does I put it here including
any hyperlinks, etc, to remind me everything I need to know.
The fragment will execute with tracing (-x) and halt-on-first-error (- e)
@daniel-thompson
daniel-thompson / typescript
Created April 27, 2016 08:26
lsof and pstree on Dragonboard 410c
root@linaro-alip:~# lsof | grep ttyMSM
login 1823 root 0u CHR 252,0 0t0 1074 /dev/ttyMSM0
login 1823 root 1u CHR 252,0 0t0 1074 /dev/ttyMSM0
login 1823 root 2u CHR 252,0 0t0 1074 /dev/ttyMSM0
bash 1860 root 0u CHR 252,0 0t0 1074 /dev/ttyMSM0
bash 1860 root 1u CHR 252,0 0t0 1074 /dev/ttyMSM0
bash 1860 root 2u CHR 252,0 0t0 1074 /dev/ttyMSM0
bash 1860 root 255u CHR 252,0 0t0 1074 /dev/ttyMSM0
lsof 2189 root 0u CHR 252,0 0t0 1074 /dev/ttyMSM0
lsof 2189 root 2u CHR 252,0 0t0 1074 /dev/ttyMSM0
@daniel-thompson
daniel-thompson / gist:71cd4f3e02e89dc570ce
Last active August 29, 2015 14:14
test-patchset: Make a copy of the typo dictionary
From d28dcca5f8f1e364347ae6232ef32517be582a4f Mon Sep 17 00:00:00 2001
From: Daniel Thompson <daniel.thompson@linaro.org>
Date: Fri, 23 Jan 2015 09:59:24 +0000
Subject: [PATCH] test-patchset: Make a copy of the typo dictionary
Currently aiaiai issues the following warning for each patch under test:
No typos will be found - file '/tmp/aiaiai-test-patchset.32BU/checkpatch/spellin
g.txt': No such file or directory
In fact the problem can even more accute when testing older kernels that do not