Skip to content

Instantly share code, notes, and snippets.

@bgilbert
bgilbert / qemu-run.sh
Last active January 5, 2023 19:44
Wrapper for running QEMU with some common options
#!/bin/bash
set -euo pipefail
tpm=0
mem=2048
port=2222
tftpboot=
args=(-accel kvm -cpu host -object rng-random,filename=/dev/urandom,id=rng0)
while [ $# -ge 1 ]; do
@bgilbert
bgilbert / decompile.py
Last active December 7, 2021 06:53
Debug tool for unwrapping data URLs in Ignition configs
#!/usr/bin/python
import gzip
import json
import sys
from urllib.request import urlopen
import yaml
class literal(str):
pass
@bgilbert
bgilbert / contextmanager.md
Last active July 19, 2023 10:12
Python context managers

Context managers

In Python, a context manager is an object that can be used in a with statement. Here's a context manager that reports the total wall-clock time spent inside a with block:

import time

class Timer(object):
    def __init__(self, msg):
        self._msg = msg
@bgilbert
bgilbert / README.md
Last active December 31, 2015 07:39
Script to delete the label image from an Aperio SVS file

Moved

This script has moved.

@bgilbert
bgilbert / readme.c
Created March 27, 2012 23:12
readme
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/fs.h>
#include <linux/fiemap.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@bgilbert
bgilbert / check-position-map-low-byte.py
Created February 19, 2012 00:00
Script to dump histogram of low bytes of Mirax position map coordinates
#!/usr/bin/python
#
# OpenSlide, a library for reading whole slide image files
#
# Copyright (c) 2007-2012 Carnegie Mellon University
# Copyright (c) 2011 Google, Inc.
# All rights reserved.
#
# OpenSlide is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as