Skip to content

Instantly share code, notes, and snippets.

View MawKKe's full-sized avatar

Markus H MawKKe

View GitHub Profile
@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) <markus@mawkke.fi>
# 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 / 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 April 13, 2024 08:19
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 / float-indexing.py
Last active April 26, 2024 10:18
Are you tired of plain old integer-based indexing? Use floats instead!
"""
Are you tired of plain old integer-based indexing?
Use floats instead!
"""
# Author: Markus H (MawKKe) 2024-04 https://github.com/MawKKe
import math
import typing as t
@MawKKe
MawKKe / cryptsetup-with-luks2-and-integrity-demo.sh
Last active April 29, 2024 21:19
dm-crypt + dm-integrity + dm-raid = awesome!
#!/usr/bin/env bash
#
# Author: Markus (MawKKe) ekkwam@gmail.com
# Date: 2018-03-19
#
#
# What?
#
# Linux dm-crypt + dm-integrity + dm-raid (RAID1)
#