Skip to content

Instantly share code, notes, and snippets.

@baryluk
baryluk / 3da240b059b1710b47d8774b27dc84bd05fb409c.patch
Created November 30, 2022 01:57
Demangle D programming language symbol names in Valgrind
commit 3da240b059b1710b47d8774b27dc84bd05fb409c (HEAD -> master)
Author: Witold Baryluk <[email protected]>
Date: Wed Nov 30 02:56:29 2022 +0100
Demangle D programming language (dlang) symbol names
diff --git a/coregrind/m_demangle/demangle.c b/coregrind/m_demangle/demangle.c
index 3fd7cb75f..a4031dc8a 100644
--- a/coregrind/m_demangle/demangle.c
+++ b/coregrind/m_demangle/demangle.c
@baryluk
baryluk / plan9-run.sh
Last active April 10, 2024 19:56
Plan 9 in qemu / 9front in qemu
#!/bin/bash
wget -c https://9front.org/iso/9front-9442.0e66f87316e571f7edf5274369ec69a5905507aa.amd64.iso.gz
gunzip -k 9front-9442.0e66f87316e571f7edf5274369ec69a5905507aa.amd64.iso.gz
if ! [ -f plan9.raw ]; then
qemu-img create plan9.raw 10G
fi
exec qemu-system-x86_64 -enable-kvm \
-smp $(nproc) \
-m $((8*1024)) \
@baryluk
baryluk / dd_bcd.py
Last active March 27, 2023 18:55
Double dabble algorithm demo in Python
#!/usr/bin/env python3
# MIT License, Witold Baryluk, 2022
# double dabble algorithm for convering binary numbers to decimal notation.
# This is program is not for speed, but just for ilustration and education.
# It works, and could be starting point to trying to understand
# how it works, and implement it for example on a microcontroller without
# division.
@baryluk
baryluk / config.boot
Created September 23, 2022 22:14 — forked from fatred/config.boot
Fiber7-X VyOS Config
set firewall all-ping 'enable'
set firewall broadcast-ping 'disable'
set firewall config-trap 'disable'
set firewall group network-group inside-nets network '192.168.99.0/24'
set firewall group network-group inside-nets network '10.31.74.0/28'
set firewall ipv6-receive-redirects 'disable'
set firewall ipv6-src-route 'disable'
set firewall ip-src-route 'disable'
set firewall log-martians 'enable'
set firewall receive-redirects 'disable'
@baryluk
baryluk / library_dependencies.py
Last active March 3, 2024 00:38
Graph binary / library / dynamic library / shared object / so / ELF files, dependencies as a graph
#!/usr/bin/env python3
# Copyright: Witold Baryluk, 2019-2024. MIT license
# This small program takes one parameter, a binary (or library), and outputs
# a dependency graph. This is done recursively for all subdependencies.
# Some common dependencies are ignored like this ones to glibc basic libraries.
# The ones related to stdc++ / gcc are not ignored (otherwise the graph would be very dense).
#
# To generate and render dependency graph in one go, use something like this:
@baryluk
baryluk / prefix_suffix_compress.py
Last active July 26, 2022 11:29
Common prefix, suffix and two-sided compression
def common_prefix(strings):
def _iter():
for z in zip(*strings):
if z.count(z[0]) == len(z): # check all elements in `z` are the same
yield z[0]
else:
return
return "".join(_iter())
@baryluk
baryluk / library_dependencies.sh
Last active September 4, 2022 17:39
Graph binary / library / dynamic library / shared object / so / ELF files, dependencies as a graph
#!/bin/bash
# NOTE: Deprecated. Use https://gist.github.com/baryluk/09cbabb215351117b32aee994e5619a0 instead
# This small program takes one parameter, a binary (or library), and outputs
# a dependency graph. This is done recursively for all subdependencies.
# Some common dependencies are ignored like this ones to glibc basic libraries.
# The ones related to stdc++ / gcc are not ignored.
# After script is done execute this command to generate dependency graph:
#
@baryluk
baryluk / amdvlk-build.sh
Last active October 29, 2023 18:20
amdvlk portable non-root
#!/bin/bash
set -e
set -x
# TODO(baryluk): Standard depencies required: cmake, ninja, repo, git, gcc/g++, wayland-client, libxcb, libxml2, python3, perl, llvm
# Optional: valgrind, go, ocaml.
# I think the llvm actually doesn't need to be installed, because it is a part of downloaded and patched repo.
@baryluk
baryluk / squashfs.txt
Created July 24, 2020 08:38
squashfs compression tests using mksquashfs - xz, gzip, zstd, lz4, lz4hc, lzo
Just a quick test of squashfs compression ratio using different settings.
I am looking for relatively good and fast compression, that also is quick to decompress.
I don't care about ultimate end size exactly tho.
Input (a Debian testing live build with 6240 installed packages):
$ sudo du -bs ./chroot
26566785410 ./chroot # 26.6GB
$
@baryluk
baryluk / sizes_d_binary.txt
Last active December 5, 2020 12:22
Minimal betterC (D programming language) example
#!/bin/sh
# Comparing minimal practical (no assembler used, C library used) binaries
# for various languages and compilers.
# Mainly to test D programming language mode called betterC
time g++-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniCPP.cpp -o miniCPP_gcc
time gcc-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniC.c -o miniC_gcc
time clang++-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniCPP.cpp -o miniCPP_clang
time clang-10 -Os -g0 -fno-exceptions -fomit-frame-pointer miniC.c -o miniC_clang