Skip to content

Instantly share code, notes, and snippets.

View as's full-sized avatar

as

View GitHub Profile
@as
as / ffmpeg_filters
Created September 22, 2021 20:35
ffmpeg filters
NOTE(as): I found this at the url below, this is a mirror
URL: https://android.googlesource.com/platform/external/ffmpeg/+/refs/heads/upstream-release-3.2/doc/filters.texi
@chapter Filtering Introduction
@c man begin FILTERING INTRODUCTION
Filtering in FFmpeg is enabled through the libavfilter library.
In libavfilter, a filter can have multiple inputs and multiple
@as
as / gist:909b5e97122e4f1ecbeeb5fda4d0bc2a
Created May 13, 2021 23:57
Offline HNS Airdrop Redemption for Github Users
This github gist was recently shared with me: https://gist.github.com/KoryNunn/7d94d7e630881f99e02626b527e6fe15
It contains instructions for redeeming a crypto airdrop for github user who in 2019 had
(1) Around 15+ followers on github
(2) A public key added to their github
It is currently valued at around $2000 USD, and can be sold on a crypto exchange, converted into crypto-currency, etc.
The instructions and airdrop are legitimate, but I have problems trusting third-party code with my private key.
@as
as / ffmpeg.go
Last active January 13, 2021 04:41
ffmpeg magic: piped mp4 output without fragments
func ffmpeg(in io.Reader) (out io.ReadCloser) {
// the command overwrites the output file that "already exists"
// actually, the output file is a reference to ffmpegs own file descriptor #3
c := exec.Command("ffmpeg", "-y", "-i", "-", "-c", "copy", "-f", "mp4", "/proc/self/fd/3")
// standard input, buffered by us
c.Stdin = bufio.NewReader(in)
// create a memory backed temporary file using the MemfdCreate syscall
// the file is managed by the kernel and doesn't need to be deleted
// install the signal handler
sigs, sigdone := make(chan os.Signal, 2), make(chan bool)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
close(sigdone)
}()
// install the workers
teardown := make(chan bool)
// NOTE(as): This is like an unordered Rabin-Karp search. We
// use a simple addition without carry (XOR) to (un)mix the
// probabilistic filter for a substring match.
package main
import (
"fmt"
"strings"
)
@as
as / whitespace.ignoring.strcmp.go
Created November 9, 2019 00:31
whitespace ignoring string comparison (draft)
package main
import "fmt"
func main() {
fmt.Println(cmp("abc", " a db c "))
}
func cmp(a, b string) bool {
if len(a) < len(b) {
@as
as / wifi.sh
Last active September 19, 2019 22:14
WPA Supplicant Template
#!/bin/sh
wpa_supplicant -i wlan0 -D wext -c <(wpa_passphrase $ssid $password) 2>&1 >/var/log/wpa.log
dhclient || dhcpcd
@as
as / noface.sh
Created September 6, 2019 18:56
block facebook, instagram, et. al,
# as 2019.09.06
# generate a list of iptables commands to block
# all ip addresses assigned to facebook via the
# organization's autonomous system number.
whois -h whois.radb.net '!gAS32934' | egrep / | tr ' ' '\n' | awk '{ printf "iptables -I OUTPUT -d %s -j REJECT\n",$1 }'
@as
as / cancel.go
Created March 16, 2019 21:08
Cancellation Done Right
// TODO(as): find a production foss program where this issue exists
//
// This trivial program generates integers and prints them to
// standard output until it reaches 1000 or the context is done.
//
// It contains a fix for a difficult-to-find bug caused in many
// Go programs written by authors at all experience levels.
package main
import (
Christian [03/12/2019 13:31]
I think I see what they’re alluding to though
A “stream” would be the octets corresponding to one single HTTP/2 message
And there can be multiple streams over the same connection
All interwoven and beautiful af
as [03/12/2019 13:32]
it's not a message, it's a connectionette