Skip to content

Instantly share code, notes, and snippets.

@samunders-core
samunders-core / lookup.roundup.sh
Created December 15, 2024 12:44
multi-expression grep
lookup() { # [awk_options] regex [regex ...]; like grep, but prints all first matches on success, everything when failed
! set +"${-//[^x]/}" > /dev/null 2> /dev/null || RESTORE_TRACING="set -x"
CMDS='
BEGIN { delete PATT[0] }
BEGINFILE { if (FILENAME != "" && FILENAME != "-") { PATT[length(PATT)] = FILENAME; nextfile } }
function matchesAny(text) { for (i in PATT) if (text ~ PATT[i]) { delete PATT[i]; return 1 } }
{ allLines = allLines "" RS "" $0 }
matchesAny($0) { matched = matched "" RS "" $0 }
0 == length(PATT) { exit }
END { system(length(PATT) ? "date >&2" : "true"); printf(length(PATT) ? "Seen " NR " lines since " START "\n" : "") > "/dev/stderr"; print(length(PATT) ? allLines : matched); exit(length(PATT)) }
@samunders-core
samunders-core / uloztoAria2bridge.js
Last active August 7, 2022 14:10
This GreaseMonkey / TamperMonkey / ViolentMonkey user script redirects downloads from https://uloz.to to speciffied Aria2 instance
// ==UserScript==
// @name uloz.to Aria2 bridge
// @namespace Violentmonkey Scripts
// @match https://uloz.to/*
// @run-at document-start
// @grant GM.xmlHttpRequest
// @version 1.0
// @author sam_
// @description Redirects downloads from uloz.to to speciffied Aria2 instance
// ==/UserScript==
@samunders-core
samunders-core / SharedLibrariesMemoryMap.java
Created January 4, 2021 22:20
Ghidra script - add .so files to memory of main executable based on /proc/self/maps offsets. Assumes .so files are already in Ghidra project
//setup memory map from /proc/self/maps
//@author sam_
//@category
//@keybinding
//@menupath
//@toolbar
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@samunders-core
samunders-core / crontab
Last active November 21, 2020 11:52
Self-contained OpenWRT crontab for IP camera records management
# #ffmpeg
# SECONDS=900
# DURATION=$(($(date "+$SECONDS-(%M%%15)*60-%S")))
## tcp transport ensures bottom half of frame is not pixelated
# PRE_IN="-t $DURATION -rtsp_transport tcp"
# LOGIN=
# PASSWORD=
# IP=
# IN=rtsp://$LOGIN${PASSWORD:+:$PASSWORD}@$IP:554/mpeg4
# START="$(date '+%Y%m%d_%H%M%S')"
@samunders-core
samunders-core / LabelInterrupts.java
Created October 8, 2020 21:31
Ghidra SW interrupt labeling script
// prepend comment to each INT
//@author sam_
//@category DOS
//@keybinding
//@menupath
//@toolbar
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@samunders-core
samunders-core / footer_links.lua
Created February 22, 2020 19:12
adds buttons to OpenWRT's GUI footer
@samunders-core
samunders-core / bootloop.log
Created August 18, 2019 21:43
Vernee Thor Plus kernel log (bootloop)
$ 'MINICOM=-w -b 921600' minicom -D /dev/ttyUSB0
Welcome to minicom 2.7.1
OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyUSB0, 22:54:54
Press CTRL-A Z for help on special keys
[590440] [fastboot: command buf]-[getvar:slot-count]-[len=17]
@samunders-core
samunders-core / installer_linux64_patcher.sh
Last active July 17, 2019 17:42
"unprivileged" webOS TV SDK installation
#!/bin/sh
SDK_DIR=$HOME/webOS_TV_SDK
# this nonsense is the reason for sudo in webOS TV SDK installation scripts
sudo ln -s $SDK_DIR /home/.lgsdkTvregistery
patch_sudo() {
sed -i -re '0,/exit [0-9]/s/exit [0-9]//' -e '0,/sudo nohup/s/sudo nohup//' "$@"
}
@samunders-core
samunders-core / nix-unprivileged.sh
Last active May 31, 2019 20:58
Gentoo-debugged nix for non-root user
#!/bin/bash -e
# inspiration: https://gitlab.com/veprbl/nix-bootstrap/blob/master/bootstrap.sh
BOOST=1.68.0 && BOOST="https://dl.bintray.com/boostorg/release/$BOOST/source/boost_${BOOST//./_}.tar.bz2"
BROTLI=1.0.7 && BROTLI="https://github.com/google/brotli/archive/v$BROTLI.tar.gz"
EDITLINE=1.16.0 && EDITLINE="https://github.com/troglobit/editline/releases/download/$EDITLINE/editline-$EDITLINE.tar.xz"
NIX=nix-2.2.2 && NIX="https://nixos.org/releases/nix/$NIX/$NIX.tar.xz"
NIXPKGS=19.03 && NIXPKGS="https://github.com/NixOS/nixpkgs/archive/$NIXPKGS.tar.gz"
SQLITE=sqlite-autoconf-3280000 && SQLITE="https://sqlite.org/2019/$SQLITE.tar.gz"
@samunders-core
samunders-core / proxy.php
Last active November 18, 2018 23:27
URL-rewriting PHP proxy, works with Apache's userdir module
<?php
function debug_exit($msg) {
echo ">{$msg}<";
exit(200);
}
function readFtpLine($line, $s) {
if ("\r" == substr($line, -1)) {
socket_read($s, strlen("\n"), PHP_NORMAL_READ);