Skip to content

Instantly share code, notes, and snippets.

@afh
afh / fontdemo.py
Created March 9, 2026 13:24 — forked from dbader/fontdemo.py
For my Raspberry Pi internet radio project I needed a way to render text suitable for a low resolution monochrome LCD. This article describes how to render 1-bit text using FreeType and Python. See http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Needs freetype-py>=1.0
# For more info see:
# http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
# The MIT License (MIT)
#
# Copyright (c) 2013 Daniel Bader (http://dbader.org)
@afh
afh / badgemagic.py
Last active March 9, 2026 12:22 — forked from dlech/badgemagic.py
Python script to program Fossia BadgeMagic using Bluetooth.
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 David Lechner <dlechner@baylibre.com>
#
# /// script
# dependencies = [
# "bleak",
# ]
# ///
# https://gist.github.com/dlech/24e71cd18ef46ec0c3ad94ffa0fef49a
@afh
afh / tmux_italic.md
Created November 30, 2019 19:23 — forked from gyribeiro/tmux_italic.md
enable italic font on tmux
Moved to https://docs.google.com/document/d/17KfV_c0DI6ZSMQiBfYylxqt0VU8XAvjHQsyNh0tDK3I/edit#heading=h.sudttarnig9w
#!/bin/sh
led_status='/sys/class/leds/chip:white:status'
trigger=''
case $1 in
on) trigger='default-on' ;;
off) trigger='none' ;;
beat) trigger='heartbeat' ;;
charge) trigger='axp20x-usb-online' ;;
blink) trigger='timer'
@afh
afh / ledger_boost_159.patch
Created September 15, 2015 13:40
Patch to workaround compile issues when using boost 1.59
diff --git a/src/system.hh.in b/src/system.hh.in
index 8de27ad..c6654cb 100644
--- a/src/system.hh.in
+++ b/src/system.hh.in
@@ -253,6 +253,17 @@ typedef std::ostream::pos_type ostream_pos_type;
#include <boost/iterator/indirect_iterator.hpp>
+#if BOOST_VERSION == 105900
+// Fix for https://github.com/boostorg/python/issues/39
@afh
afh / sample_estimate.ledger
Created April 24, 2015 08:25
Project estimates using ledger
--decimal-comma
--time-colon
--sort=date
C 1d = 8h
D € 00.000,00
define rate=€70
define discount=0%
define vat=19%
@afh
afh / gist:a0927debfe89c0491afe
Last active August 29, 2015 14:12
nix ledger build
fetching path ‘/nix/store/aa8184zja11630nayzgdpjyc4skmlz7c-expat-2.1.0’...
*** Downloading ‘http://zalora-public-nix-cache.s3-website-ap-southeast-1.amazonaws.com/aa8184zja11630nayzgdpjyc4skmlz7c.nar’ to ‘/nix/store/aa8184zja11630nayzgdpjyc4skmlz7c-expat-2.1.0’...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to zalora-public-nix-cache.s3-website-ap-southeast-1.amazonaws.com port 80: Connection refused
/nix/store/ni1rbgsw9jv5iijj1igwp423j7vr30v7-xz-5.0.7/bin/xz: (stdin): File format not recognized
error: unexpected end-of-file
download of ‘http://zalora-public-nix-cache.s3-website-ap-southeast-1.amazonaws.com/aa8184zja11630nayzgdpjyc4skmlz7c.nar’ failed: No such file or directory
could not download ‘/nix/store/aa8184zja11630nayzgdpjyc4skmlz7c-expat-2.1.0’ from any binary cache
# -*- coding: utf-8 -*-
import unittest
from ledger import *
class JournalTestCase(unittest.TestCase):
def _tearDown(self):
pass # session.close_journal_files()
diff --git a/src/filters.cc b/src/filters.cc
index bdc2983..d24188f 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -983,7 +983,7 @@ void interval_posts::flush()
sort_posts_by_date());
// Determine the beginning interval by using the earliest post
- if (all_posts.front() &&
+ if (all_posts.size() > 0 && all_posts.front() &&