Skip to content

Instantly share code, notes, and snippets.

View MawKKe's full-sized avatar

Markus H MawKKe

View GitHub Profile
@MawKKe
MawKKe / argsparse.py
Created July 7, 2015 23:19
Testing out python's argparse
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# Markus Holmström (MawKKe) ekkwam@gmail.com
# 2015-07-08
#
# Testing out python's argparse
import argparse
import sys
from itertools import product
@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 / fizzbuzz.c
Last active June 29, 2019 22:41
Unconditional fizzbuzz
//
// Unconditional FizzBuzz
//
// Author: Markus (MawKKe) ekkwam@gmail.com | 2017-01-11
//
// Compile:
// gcc -std=c99 -Wall -Wextra -pedantic fizzbuzz.c -o fizzbuzz
//
#include <stdio.h>
@MawKKe
MawKKe / jolla-sms.sql
Created February 16, 2016 17:27
Query Jolla's commhistory.db for SMS's
/*
jolla-sms.sql - Query Jolla's commhistory.db for SMS's.
- Shows sent/received from last 2 months, oldest to newest.
- Messages are printed with newlines replaced by spaces.
---
Usage:
@MawKKe
MawKKe / smsread.py
Last active June 6, 2020 23:37
Python CLI program to show (unread) SMS's on Jolla/Sailfish OS
#!/usr/bin/env python3
#
# Author: Markus (MawKKe) ekkwam@gmail.com | 2016-01-27 02:52
#
# ---
# CLI program to show (unread) SMS's on Jolla/Sailfish OS
#
# Reads directly form an sqlite3 database, so standard Python libraries suffice.
#
# The database file is typically located in ~/.local/share/commhistory/commhistory.db
@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 / 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 / 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 / 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