Skip to content

Instantly share code, notes, and snippets.

View wader's full-sized avatar
🦫

Mattias Wadman wader

🦫
View GitHub Profile
{
"descriptions": [
[
6,
"header",
"GIF89a"
],
[
2,
"width",
$ fq -o line_bytes=16 -o force=true -d mp4 dd format/mp4/testdata/emsg.mp4
│00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f│0123456789abcdef│.{}: format/mp4/testdata/emsg.mp4 (mp4)
│ │ │ boxes[0:1]:
│ │ │ [0]{}: box
0x000│00 00 01 a1 │.... │ size: 417
0x000│ 65 6d 73 67 │ emsg │ type: "emsg" (Event message)
0x000│ 00 │ . │ version: 0
0x000│ 00 00 00 │ ... │ flags: 0
0x000│ 68 74 74 70│ http│ scheme_id_uri: "http://youtube.com/streaming/metadata/segment/1..."
0x010│3a 2f 2f 79 6f 75 74 75 62 65 2e 63 6f 6d 2f 73│://youtube.com/s│
diff --color -r -u 83b858f83b658bd34eca5d8ad4d145f673ae7e5e.orig/src/network/dns_parse.c 83b858f83b658bd34eca5d8ad4d145f673ae7e5e/src/network/dns_parse.c
--- 83b858f83b658bd34eca5d8ad4d145f673ae7e5e.orig/src/network/dns_parse.c 2023-07-18 00:03:38
+++ 83b858f83b658bd34eca5d8ad4d145f673ae7e5e/src/network/dns_parse.c 2023-10-05 13:26:20
@@ -12,7 +12,6 @@
p = r+12;
qdcount = r[4]*256 + r[5];
ancount = r[6]*256 + r[7];
- if (qdcount+ancount > 64) return -1;
while (qdcount--) {
while (p-r < rlen && *p-1U < 127) p++;
// usage:
// cat BK7231T_TuyaConfig_obk8D7EC082.bin | go run tyuaconfig.go > out
package main
import (
"crypto/aes"
"crypto/cipher"
"io"
"log"
@wader
wader / diff.jq
Created August 29, 2023 14:06
json diff with jq
# Usage:
# jq -n -L . 'include "diff"; diff({hello:1}; {hello:2, world: 3})'
# {
# "hello": {
# "a": 1,
# "b": 2
# },
# "world": {
# "b": 3
# }
2023-08-10T18:18:30.5738462Z PASS: encode.exe
2023-08-10T18:18:30.6832172Z PASS: listcap.exe
2023-08-10T18:18:30.7868219Z PASS: names.exe
2023-08-10T18:18:30.8922087Z PASS: simple.exe
2023-08-10T18:18:30.9955500Z PASS: sql.exe
2023-08-10T18:18:31.1000557Z PASS: syntax.exe
2023-08-10T18:18:31.2040511Z PASS: user_property.exe
2023-08-10T18:18:31.3150542Z PASS: callout.exe
2023-08-10T18:18:31.4195018Z PASS: echo.exe
2023-08-10T18:18:31.5218888Z PASS: count.exe
@wader
wader / strconvx.go
Created July 28, 2023 14:12
Optionally strict go ParseInt
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// This is a fork of std/strconv ParseInt/ParseUint with a strict
// option to allow trailing invalid characters.
package strconvx
import (
@wader
wader / mpeg_l3.ksy
Created June 21, 2023 17:34
mpeg layer 3 header plus som test
meta:
id: mpeg_l3
seq:
- id: sync
type: b11
- id: mpeg_version
type: b2
enum: mpeg_version
- id: layer
type: b2
@wader
wader / duration.jq
Last active May 5, 2023 14:45
jq duration helpers
# "01:02:03.45" -> 3723.45
def from_duration:
( reduce (split(":") | reverse[]) as $p (
{m: 1, n: 0};
( .n = .n + ($p | tonumber) * .m
| .m *= 60
)
)
| .n
);
@wader
wader / syslog.jq
Created April 3, 2023 10:08
jq syslog parser
def from_syslog:
( split("\n")
| map(
( capture("^(?<ts>\\w{3}\\s+\\d{1,2} +[\\d:]+) (?<host>\\w+) (?<process>\\w+)\\[(?<pid>\\d+)\\]: (?<message>.*)$")
| .ts |= strptime("%b %d %H:%M:%S")
| .pid |= tonumber
)
)
);