Skip to content

Instantly share code, notes, and snippets.

View hartwork's full-sized avatar
🇺🇦

Sebastian Pipping hartwork

🇺🇦
View GitHub Profile
@hartwork
hartwork / timezone_logging_demo.py
Created May 5, 2025 15:18
Demo Python logging with time zone information for field `asctime`
#! /usr/bin/env python3
# Copyright (c) Sebastian Pipping <[email protected]>
#
# Licensed under Zero-Clause BSD
# SPDX-License-Identifier: 0BSD
import datetime
import logging
@hartwork
hartwork / selenium_check_url.py
Last active April 30, 2025 14:29
Check a URL using Selenium
#! /usr/bin/env python3
# Check a URL using headless Selenium
# Copyright (c) 2025 Sebastian Pipping <[email protected]>
#
# Licensed under GNU Affero General Public License v3.0 or later
# SPDX-License-Identifier: AGPL-3.0-or-later
import argparse
import json
import sys
@hartwork
hartwork / demo_libfuzzer_coverage.cxx
Created February 11, 2025 12:55
Demo effectiveness of coverage-guided fuzz testing with libFuzzer (https://llvm.org/docs/LibFuzzer.html#id30)
// Copyright (c) 2025 Sebastian Pipping <[email protected]>
// Licensed under the MIT license
#include <cstdint>
#include <signal.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size >= 1 && Data[0] == 'H') {
if (Size >= 2 && Data[1] == 'e') {
if (Size >= 3 && Data[2] == 'l') {
@hartwork
hartwork / show_libfuzzer_input.cxx
Last active February 11, 2025 12:20
libFuzzer fuzzer that dumps its input to stdout to get a sense of the effect of a given dictionary file (fuzzer argument "-dict=FILE")
// Copyright (c) 2025 Sebastian Pipping <[email protected]>
// Licensed under the MIT license
#include <cctype> // isprint(3)
#include <cstdint>
#include <cstdio> // putchar(3), printf(3)
#include <sys/param.h> // MIN(3)
static const unsigned int MAX_LEN = 30;
#! /usr/bin/env python3
# Copyright (c) 2025 Sebastian Pipping <[email protected]>
# Licensed under the MIT license
import decimal
import math
import sys
from decimal import Decimal
import pylab
@hartwork
hartwork / test_pidgin_plugin_loadable.c
Created September 2, 2024 15:03
Test a Pidgin plug-in file (.dll or .so) for loadability as a GModule (originally made for Lurch in 2022)
// Copyright (c) 2022 Sebastian Pipping <[email protected]>
// Licensed under the GPL v2 or later
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <gmodule.h>
@hartwork
hartwork / copy_pidgin_plugin_dll_closure.sh
Created September 2, 2024 14:56
Copy DLL closure (all direct and indirect dependencies) of a Pidgin plug-in (originally made for Lurch)
#! /usr/bin/env bash
# Copyright (c) 2022 Sebastian Pipping <[email protected]>
# Licensed under the GPL v2 or late
set -e -u -o pipefail
: ${DLL_HOME:?environment variable not set but required}
: ${BUILD_DIR:?environment variable not set but required}
direct_dependencies_of() {
@hartwork
hartwork / 1_percent_loss_gain.py
Created June 8, 2024 16:15
Plot 1% loss/gain per day for one year
# Copyright (c) 2024 Sebastian Pipping <[email protected]>
# Licensed under the MIT license
import math
import pylab
from matplotlib import pyplot
START = 100
DAYS = 365
@hartwork
hartwork / headless.py
Created November 25, 2023 01:08
Allow running e.g. asciinema in headless CI
#! /usr/bin/env python3
# Copyright (c) 2015 by pyte authors and contributors
# Copyright (c) 2023 by Sebastian Pipping <[email protected]>
#
# Licensed under LGPL v3, see pyte's LICENSE file for more details.
#
# Based on pyte's example "capture.py"
# https://raw.githubusercontent.com/selectel/pyte/master/examples/capture.py
import os
@hartwork
hartwork / find_local_orphan_branches.py
Created November 22, 2023 16:41
Finds Git branches that were tracking a remote branch that no longer exists today
# Finds Git branches that were tracking a remote branch that no longer exists today.
# For Python >=3.8, all else is end-of-life.
#
# Copyright (c) 2023 Sebastian Pipping <[email protected]>
# Licensed under GPL v3 or later
import re
from subprocess import check_output
# NOTE: See "man git-check-ref-format" for colon (":") being disallowed in references