Skip to content

Instantly share code, notes, and snippets.

View MawKKe's full-sized avatar

Markus H MawKKe

View GitHub Profile
@MawKKe
MawKKe / fix-telegram-stuck-draft-message.md
Last active May 7, 2024 19:21
Fix Telegram stuck draft message

Problem with Telegram and stuck Draft message

2024-05-06: I was using telegram to send a message in one of the group chats I'm in.

2024-05-07: I noticed that a copy of my sent message was left as draft in the same chat (which is indicated by a red Draft: prefix in the chat list). If I opened the chat group, the draft message would indeed be entered in the message preparation box.

However, I could not erase the draft message; if I tried, it would simply return in a few seconds. I tried several times.

I noticed I could erase parts of the draft or add more. All those changes would be reflected between my phone and laptop.

@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)
#
@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 / 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 / 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 / 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 / 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) markus@mawkke.fi
@MawKKe
MawKKe / googletest-wtf.md
Last active December 28, 2021 19:56
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) ekkwam@gmail.com
set -eu
PNAME="$(basename ${0})"
# OpenSSH default checksum type as of 2021-07
E=sha256
@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