Skip to content

Instantly share code, notes, and snippets.

@samunders-core
samunders-core / openra_replay_details.sh
Created December 27, 2016 15:46
parse OpenRa cnc 2 teams replay file for duration, team factions and outcome
#!/bin/sh
egrep -aHo '[-0-9a-zA-Z_@]+:.*' "$@" | \
awk '
$0 == $1 {
group=$1
next
}
{
print group""substr($0,index($0, ":") + 1)
@samunders-core
samunders-core / unmangle.h
Created July 28, 2017 21:32
Fatal Racing / Whiplash game files (BM,DRH,KC,RAW,TRK) decoder
#ifndef UNMANGLE_H
#define UNMANGLE_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
@samunders-core
samunders-core / iface_watchdog.sh
Last active January 29, 2020 23:05
OpenWRT/LEDE procd service to check/reconnect stalled/disconnected wan interface
#!/bin/sh /etc/rc.common
# https://joost.oostdijk.net/articles/service-configuration-with-procd/
# runs until first stall/disconnect of recovery taking longer than 60 seconds
INTERNET_ADDRESS=8.8.8.8
IFACE="${1:-LTE}"
SECONDS=${2:-10}
[ -z "${IFACE}" ] && {
/bin/echo -e "Usage: iface_watchdog <interface> [poll_each_seconds]\nChecks+reconnects stalled/disconnected interface" | /usr/bin/logger -s
exit 1
}
@samunders-core
samunders-core / Dockerfile
Last active November 24, 2019 22:09
Alpine linux-based openra dedicated server container (~ 315MB)
# wget -O - https://gist.github.com/samunders-core/089b081707576c2692ce6c52a411aea2/raw/ |\
# sed -re '/(FROM|MAINTAINER|RUN)/d' -e 's|ENV|export|' -e '$a su -s /bin/sh ${U}' -e '/^EXPOSE/,$d' | /bin/sh
#
# # execute following as ${U}:
# sed -re '1{s|$|\npgrep -f "mono.*OpenRA.Server.exe.*Mod=" \&\& exit 0\ncd '"${B}"'\nexec\\|;p} 1,/while true; do/d; /done/,$d' ${B}/launch-dedicated.sh > ${H}/${U}.sh\
# chmod +x ${H}/${U}.sh && echo "* * * * * ${H}/${U}.sh" | crontab - && exit
FROM alpine:latest
MAINTAINER sam_
#!/usr/bin/awk -f
BEGIN {
ts_patt = "[0-9][0-9]:[0-5][0-9]:[0-5][0-9],[0-9]+"
split("99:59:59,999", limits, ":|,")
from = 1
to = 999999999
delay[hours = 1] = 0
delay[minutes = 2] = 0 # 0-59
delay[seconds = 3] = 0 # 0-59, positive = show subtitle later, negative = show subtitle sooner
@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);
@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 / 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 / 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 / footer_links.lua
Created February 22, 2020 19:12
adds buttons to OpenWRT's GUI footer