Skip to content

Instantly share code, notes, and snippets.

@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 / myusbgadget
Created January 17, 2017 02:47
Pi Zero multiple USB gadgets minimal example
#!/bin/bash -e
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir g && cd g
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
@geekman
geekman / hexdump.java
Created March 26, 2013 06:31
simple hex dump in Java
public static String hexdump(byte[] data) {
final int perRow = 16;
final String hexChars = "0123456789ABCDEF";
StringBuilder dump = new StringBuilder();
StringBuilder chars = null;
for (int i = 0; i < data.length; i++) {
int offset = i % perRow;
if (offset == 0) {
chars = new StringBuilder();
@geekman
geekman / usbasp-fw.diff
Created July 20, 2017 14:12
USBasp patch for the zhifengsoft USB ISP device (and newer avr-gcc)
diff -ur firmware/Makefile firmware-new/Makefile
--- firmware/Makefile 2011-05-28 15:57:49 +0800
+++ firmware-new/Makefile 2017-07-16 01:12:03 +0800
@@ -7,7 +7,7 @@
# TARGET=atmega8 HFUSE=0xc9 LFUSE=0xef
# TARGET=atmega48 HFUSE=0xdd LFUSE=0xff
# TARGET=at90s2313
-TARGET=atmega8
+TARGET=atmega88
HFUSE=0xc9
@geekman
geekman / dumpscript-gen.py
Created November 18, 2019 07:47
minicom script generator for dumping firmware
#!/usr/bin/python2
#
# script to generate a minicom script that dumps entire flash
# problem is the stub seems to read all data into RAM first,
# so you can only do in batches
#
# 2019.10.24
# inc needs to be low enough to complete within `expect` timeout
inc = 0x20000
@geekman
geekman / query.js
Created August 13, 2023 13:59
copy-paste snippet to un-download all unwatched episodes in DuckieTV
// un-download any unwatched episodes
// this problem was created during initial Trakt.TV sync and it added everything to the "collection"
CRUD.Find('Episode', {}, {'limit': 100000}).then(function(eps) {
eps.map(function(ep) {
if (ep.hasAired() && !ep.isWatched() && ep.isDownloaded()) {
console.log(ep.ID_Serie, ep.getFormattedEpisode(), ep);
ep.markNotDownloaded(/*pairing:*/ false);
}
})
})
@geekman
geekman / mpv-rtsp.sh
Created August 1, 2023 17:30
mpv stream RTSP command
mpv --no-cache --profile=low-latency --rtsp-transport=tcp rtsp://192.168.0.1/stream
@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)
@geekman
geekman / itunes-migrate-files.js
Last active July 11, 2023 13:52
WSH script to perform string replacement on iTunes Library media file paths
//
// WSH script to replace all paths in iTunes after moving media files.
// iTunes will prompt you to locate missing files, but you need to do them
// one by one, which is not humanly feasible.
//
// run using: cscript.exe itunes-migrate-files.js
//
// 2022.04.23 darell tan
//
@geekman
geekman / .sigrok toy decoder.md
Last active June 28, 2023 08:17
libsigrok toy decoder

libsigrok Toy Decoder

This is a very minimal example for writing your own quick-and-dirty decoder that you can use in PulseView.

This decoder displays annotations for a signal that's made up of 1 ms units. It annotates from one signal edge to another, without regard for time. If you want to handle the actual units of time, more logic is required and that's left as an exercise for the reader.