Skip to content

Instantly share code, notes, and snippets.

View bonzini's full-sized avatar

Paolo Bonzini bonzini

View GitHub Profile
@bonzini
bonzini / gcd.h
Last active April 14, 2024 08:49
// result for blog post on my machine
// 10.7 Ma/s 93.60 ns/d 4.17 GHz 390.21 c/d 778.90 i/d 24.39 c/b 48.68 i/b 2.00 i/c
// ^^^^^^^^
//
// binary_gcd_paolo_1 wins for #instructions, but is really bad in terms of ipc
// 5.3 Ma/s 189.59 ns/d 4.16 GHz 788.92 c/d 324.72 i/d 49.31 c/b 20.30 i/b 0.41 i/c
// ^^^^^^^^^^
//
// binary_gcd_paolo_2 wins overall on my machine, saving more in #instructions than it loses ipc
// 12.0 Ma/s 82.99 ns/d 4.15 GHz 344.06 c/d 592.35 i/d 21.50 c/b 37.02 i/b 1.72 i/c
@bonzini
bonzini / userChrome.css
Created November 30, 2022 17:42
teaks for a dark(er) thunderbird theme
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#titlebar {
height: 44px;
}
#navigation-toolbox, #tabmail-tabs, #tabmail-arrowscrollbox { /* Outer tab containers */
min-height: 44px !important;
}
@bonzini
bonzini / click.yaml
Last active November 30, 2022 17:44
Home Assistant blueprints
blueprint:
name: Personal Zone Notification
description: Send a notification with a URL to a device when it enters a specific zone.
domain: automation
input:
zone:
name: Zone
description: Zone triggering the notification
selector:
entity:
@bonzini
bonzini / gnome-sendmail.py
Created May 4, 2022 17:53
gnome-sendmail.py
#! /usr/bin/env python3
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Command line access to GNOME Online Accounts mail accounts
#
# Authors:
# Daniel P. Berrange <[email protected]>
# Paolo Bonzini <[email protected]>
@bonzini
bonzini / coro.cc
Last active March 11, 2022 21:39
Simple C++ coroutine runtime
#include "coro.h"
#include <cstdio>
static __thread Coroutine *current;
void Yield::await_suspend(std::coroutine_handle<> parent) const noexcept {
//printf("!!!! top = %p, yielding from %p\n", current->top, parent);
current->top = parent;
}
@bonzini
bonzini / mqtt.py
Last active March 2, 2022 09:32
termostato con zigbee2mqtt
#! /usr/bin/env python3
from collections import defaultdict
import asyncio
import paho.mqtt.client
import json
import weakref
class ActiveSubscription:
def __init__(self, topic, obj, client):
@bonzini
bonzini / patchew-ty
Last active February 25, 2022 14:52
#! /bin/sh
if test $1 = -n; then
ARGS=--dry-run
shift
else
ARGS=--confirm=always
fi
mboxsplit() {
@bonzini
bonzini / hooks
Last active January 2, 2022 16:12
Protecting the initrd with a watchdog
#!/bin/sh
# /etc/initramfs-tools/hooks/sunxi_wdt
set -e
PREREQS=""
prereqs() { echo "$PREREQS"; }
case $1 in
prereqs)
prereqs
exit 0
;;
@bonzini
bonzini / egypt
Last active April 21, 2022 09:34
Improved version of "egypt", with bugfixes and callgraph pruning
#!/usr/bin/perl -w
=head1 NAME
egypt - create call graph from gcc RTL dump
=head1 SYNOPISIS
egypt [--omit function,function,...] [--only function,function,...] [--include-external] [--files] <rtl-file>... | dotty -
egypt [--omit function,function,...] [--only function,function,...] [--include-external] [--files] <rtl-file>... | dot <dot-options>
[
{
"key": "shift+alt+right",
"command": "-editor.action.smartSelect.expand",
"when": "editorTextFocus"
},
{
"key": "shift+alt+down",
"command": "-editor.action.insertCursorBelow",
"when": "editorTextFocus"