Skip to content

Instantly share code, notes, and snippets.

View bonzini's full-sized avatar

Paolo Bonzini bonzini

View GitHub Profile
@bonzini
bonzini / keybase.md
Created March 14, 2018 09:24
Keybase proof for [email protected]

Keybase proof

I hereby claim:

  • I am bonzini on github.
  • I am bonzini (https://keybase.io/bonzini) on keybase.
  • I have a public key ASBpTRbkHp25GSmFkfeNK-hZuRh5CZm81Qb2t1Y4BNz04wo

To claim this, I am signing this object:

-----BEGIN PGP MESSAGE-----
hQEMA4c6sA8rjgLDAQf+MRvlUKJsHKwAdYruf+oiENwLKJc9mwcJcWlOXBpWGZWI
0TsJ21SxJs2JnC1irx09gZDy2rxBhWPI08WJ2WrbvYB9w7Aq7U+sIjFFqjwbUpE7
L6a6GQxwhmC0CRdMEnRujsGQatru0w5E+CQWkqrzJG5OkTxKZFlfXhqvp7qocCZw
jV+btVgG/2XuLYVvSe5V2weYlqyWZVJAZYV6efmCV1482UJTnW1GsDpRdsheyJzp
vik+Jzy/LZCVxKfvi6wcxE/ergXDNs2/+n75z6PWvlxwhnEAZgx2KFv/o+PMUjoO
gj9vwtwOZZ0wYoQi+0/XCfzqudJy1OYLxriIpkSoDNKGAfbqj0TPcqbG73hWYbzg
H4G6gZ287NgwDxyHu228wK2iFskOjqKja550XFy/4si3GIM+BKbFOUM3NL3/4AyP
kpvCVhniLX6ZSKTNRX1SIwKFQSlqWL1e8Epqlt5zpDlfsiCruXCVFUPUXseC+R76
@bonzini
bonzini / tap-to-xunit.pl
Created November 29, 2018 18:08
Convert one or more TAP files to XML, similar to tap2junit but with fewer dependencies
#! /usr/bin/env perl
# Copyright (C) 2011-2013 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@bonzini
bonzini / relay.lua
Last active September 11, 2019 12:06
NodeMCU script to control two relays via MQTT
connected = false
-- GPIO helpers
function blink_led(on, off, times, callback)
if times == 0 then
if type(callback) == "function" then
callback()
end
return
@bonzini
bonzini / jekyll-update.sh
Created September 19, 2019 15:47
Git update hook that deploys a jekyll website on push
#! /bin/sh
# A simple update hook for git that deploys a jekyll website to a web server
# on the remote side.
#
# Author: Paolo Bonzini
source scl_source enable rh-ruby25
# -----------------------------------------------------------------------------
@bonzini
bonzini / mbox_split.py
Last active March 30, 2024 02:40
Split a mailbox into separate patch files, stripping the transfer encoding and minimizing the headers along the way.
#! /usr/bin/env python3
# mbox_split.py
#
# Split a mailbox into separate patch files, stripping the transfer encoding
# and minimizing the headers along the way.
#
# Written by Paolo Bonzini <[email protected]>
import argparse
@bonzini
bonzini / lazy_box.rs
Last active April 15, 2020 17:11
Lazily-initialized Box<T>
//! A crate for things that are
//! 1) Lazily initialized
//! 2) Expensive to create
//! 3) Immutable after creation
//! 4) Used on multiple threads
//! 5) Stored in a Box
//!
//! `LazyBox<T>` is better than `Mutex<Option<Box<T>>>` because after creation accessing
//! `T` does not require any locking, just a single boolean load with
//! `Ordering::Acquire` (which on x86 is just a compiler barrier, not an actual
@bonzini
bonzini / mockup.py
Last active November 18, 2020 09:09
Mockup for fancy "meson test" output
#! /usr/bin/env python3
import asyncio
from collections import namedtuple, OrderedDict
import sys
import os
from typing import NamedTuple
import typing as T
import time
[
{
"key": "shift+alt+right",
"command": "-editor.action.smartSelect.expand",
"when": "editorTextFocus"
},
{
"key": "shift+alt+down",
"command": "-editor.action.insertCursorBelow",
"when": "editorTextFocus"
@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>