Skip to content

Instantly share code, notes, and snippets.

View wader's full-sized avatar
🦫

Mattias Wadman wader

🦫
View GitHub Profile
@wader
wader / Makefile
Last active February 1, 2021 13:24
make automatic variables
# https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html
b/%.dep1:
mkdir -p b
touch "$@"
b/%.dep2:
mkdir -p b
touch "$@"
# gnuplot < file.plot > file.svg
$data << EOD
# index 0
1 2
2 2
3 3
# two blank new index 1
(echo "HTTP/1.1 200" ; echo "Accept-Ranges: bytes" ; echo ; dd if=file bs=1 count=80000) | nc -l -p 8080
@wader
wader / gist:1ec5eae9ed967e7e1826553b0abaec22
Last active August 26, 2023 07:37
ffmpeg video retranscode
docker run --rm --user=$UID:$GROUPS -v "$PWD:$PWD" -w "$PWD" --entrypoint=ffmpeg mwader/ydls -i "$i" -c:a copy -c:v h264 -c:s mov_text -vf yadif=deint=interlaced,format=yuv420p -map 0:a -map 0:v:0 -map 0:s? -movflags +faststart out.mp4
put paths in list
for i in $(cat list) ; do docker run --rm --user=$UID:$GROUPS -v "$PWD:$PWD" -w "$PWD" --entrypoint=ffmpeg mwader/ydls -y -i "$i" -c:a copy -c:v h264 -c:s mov_text -vf yadif=deint=interlaced,format=yuv420p -map 0:a -map 0:v:0 -map 0:s? -movflags +faststart $i.x264.mp4 ; done
@wader
wader / gist:fc7a20db438f0ae3ad869590720567e8
Last active January 22, 2021 11:16
gcc -mcpu=native debug
See what gcc thinks is native: gcc -Q -mcpu=native --help=target
How native guess works for ARM:
https://github.com/gcc-mirror/gcc/blob/34a6c43487caf3a2a0ec9c7c79c526d116abc8b9/gcc/config/arm/driver-arm.c
https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/config/arm/arm-cpus.in
@wader
wader / gist:7cc54fc89d93e4c8b26893098444d556
Created January 6, 2021 16:22
macos notification when command is done
alias nag="osascript -e \"display notification \\\"Finished with exit code \$?\\\"\""
Usage:
./command_that_takes_time ; nag
@wader
wader / ffl.go
Last active January 18, 2021 14:01
golang get "file.go:func:line" vs code snippet
package main
import (
"fmt"
"path/filepath"
"runtime"
)
func FFL() string {
pc, f, l, _ := runtime.Caller(1)
// Package naivediff generates a unified diff between two texts wih the same amount of lines
// WARNING: Is naive because it assumes source and destination text have the same number of lines.
// Should only be used to make changes to lines, not add or delete lines.
package naivediff
import (
"fmt"
"strings"
)
@wader
wader / gist:03e856976352490426f8944f0ac33b9a
Last active January 27, 2021 00:29
quick go logger writing to file
in program:
func init() {
if lf := os.Getenv("LOGFILE"); lf != "" {
log.SetOutput(func() io.Writer { f, _ := os.Create(lf); return f }())
}
}
or
@wader
wader / calc.sh
Created December 28, 2020 12:35
cli calculator with readline, history, decimal, hex, octal, binary and ascii output
# requires rlwrap and iprint
# brew install rlwrap iprint
# apt-get install rlwrap iprint
rlwrap -C calc sh -c '(test $# -gt 0 && echo $* || cat) | while read l ; do n=$(echo $(($l))) && i $n ; done' --
# as bash alias
alias c="rlwrap -C calc sh -c '(test \$# -gt 0 && echo \$* || cat) | while read l ; do n=\$(echo \$((\$l))) && i \$n ; done' --"