Skip to content

Instantly share code, notes, and snippets.

View MawKKe's full-sized avatar

Markus H MawKKe

View GitHub Profile
@MawKKe
MawKKe / 2024-02-05-atoms.md
Last active February 5, 2024 21:28
Atoms? It was already like that when I found it...

Background

Most programming languages have basic types such as booleans, bytes, shorts, integers, floating point numbers, strings, lists, etc. If you squint your eyes a bit, you'll notice all of these are just a bunch of bytes with varying sizes and shapes.

Strings (arrays) are (possibly unbounded) sequence of bytes. Integers and floating point types are often represented as fixed number of bytes or bits. Booleans semantically means "one bit", but often are implemented as a single byte (for performance reasons).

Now, think how many different values or states can each of these represent. Well, obviously the answer if 2**(number of bits in the type), duh!

  • Strings (arrays) can encode billions, trillions, gazillions ... of different states.
  • Integers can represent quite many, but considerably less (~4 billion for 32 bits)
@MawKKe
MawKKe / cmake-cxx-mold-linking-howto.md
Last active February 4, 2025 19:11
How to try out the new "mold" linker with your CMake C/C++ project

How to try out the new mold linker with your CMake C/C++ project

Here is a quick how-to if you want to try out the new (supposedly fast) C/C++ linker https://github.com/rui314/mold

In this document I used Ubuntu-22.04 docker container with

  • GCC version 11.2.0
  • Clang version 14.0.0

1. Install mold :

@MawKKe
MawKKe / golang-help-wrapper.sh
Last active April 13, 2022 15:16
A utility/wrapper script for launching go (golang) help topics | SEE ALSO https://github.com/MawKKe/golang-help-wrapper
#!/usr/bin/env sh
# A utility/wrapper script for launching go (golang) help topics
# Author: Markus H (MawKKe) <[email protected]>
# What is this?
# -------------
# It annoys me greatly that none of the go subcommands have a help switch (-h
# or --help), requiring me to use "go help <subcommand>" instead. This is just
@MawKKe
MawKKe / brightness.sh
Last active January 26, 2022 19:39
Ubuntu + i3-wm laptop display brightness control - a helper script that does not require sudo/root privileges
#!/usr/bin/env bash
set -eu
# Helper script for controlling laptop screen brightness WITHOUT sudo/root privileges.
#
# Tested on Lenovo Thinkpad x240 running Ubuntu 18.04.
#
# Author: Markus H (MawKKe) [email protected]
@MawKKe
MawKKe / googletest-wtf.md
Last active December 26, 2024 16:53
CMake + googletest problem - resulting executable does nothing?

I ran into a stupid problem with C++ and googletest.

I set up a C++ project with CMake, and included googletest for writing tests. As usual, I created a library, and respecive test executable:

add_library(mylib mylib.cc)
...
add_executable(test-mylib test-mylib.cc)
...

target_link_libraries(test-mylib mylib gtest gtest_main)

@MawKKe
MawKKe / ssh-key-fingerprints
Last active October 2, 2021 15:53
List OpenSSH key fingeprints of all private keys found under ~/.ssh/
#!/usr/bin/env sh
# Author: Markus H (MawKKe) [email protected]
set -eu
PNAME="$(basename ${0})"
# OpenSSH default checksum type as of 2021-07
E=sha256
@MawKKe
MawKKe / ublock-filter.txt
Last active November 17, 2018 22:54
uBlock cosmetic rule for startpage.com (2018-11-18)
# Around mid November of 2018, Startpage.com updated it's visual look.
# Among other things, they changed the behaviour of the header block which
# contains the search bar and button. The header now follows you as you scroll.
# I don't know what kind of idiot thought that was a good idea.
# To get rid of this behaviour add the following line into your uBlock "My Filters" list:
startpage.com##.header--content:style(position: relative !important)
@MawKKe
MawKKe / linux-fs-namespace-workaround.txt
Created September 13, 2018 18:17
Not enough space on /tmp for Matlab install? No problem.
Problem scenario:
------------------
1) stupid Matlab installer wants to download several gigabytes into your /tmp directory.
2) You don't have "several gigabytes" available on your root partition (where /tmp is). The installer warns you and/or fails.
3) You DO have available disk space, but on some other disk/partition/wherever.
Solution:
----------
Run the command inside Linux filesystem namespace. For example:
@MawKKe
MawKKe / split_ffmpeg.py
Last active August 7, 2021 21:50
MOVED TO: https://github.com/MawKKe/audiobook-split-ffmpeg | Split audio file with ffmpeg based on chapter metadata
#!/usr/bin/env python3
import sys
import os
import re
import subprocess as sub
import argparse
import tempfile
import json
from concurrent.futures import ThreadPoolExecutor, as_completed
@MawKKe
MawKKe / cryptsetup-with-luks2-and-integrity-demo.sh
Last active May 9, 2025 14:16
dm-crypt + dm-integrity + dm-raid = awesome!
#!/usr/bin/env bash
#
# Author: Markus (MawKKe) [email protected]
# Date: 2018-03-19
#
#
# What?
#
# Linux dm-crypt + dm-integrity + dm-raid (RAID1)
#