Skip to content

Instantly share code, notes, and snippets.

View mshroyer's full-sized avatar

Mark Shroyer mshroyer

View GitHub Profile
"""
Make a Python .pth file so external Pythons can use QGIS's packages and extensions
"""
import os
from pathlib import Path
import sys
if sys.platform == "win32":
import win32api
#!/bin/sh
# Updates a replica of the ds1 dataset.
#
# Ideally we'd use bookmarks instead of snapshots to track the starting point
# of incremental sends, but OpenZFS 2.0.0 doesn't support sending multiple
# datasets from the same bookmark (and I don't feel like rewriting all of the
# functionality of zfs send -R).
#
# Usage: update_ds1_replica <dest_pool>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define REPORT_BLOCKS 1024
#define BLOCK_SIZE 65536
#define SUB_BLOCK_SIZE 8192
% doas ./bdcmp /dev/zvol/tank/ds1/backup/pump-vol-a /dev/zvol/tank/ds1/backup/pump-vol-b
block number: 16384000
Total blocks counted: 16384000
Differing blocks: 78727 # 64k blocks; total size ~4.8 GB
Differing sub-blocks: 421058 # 8k sub-blocks; total size ~3.2 GB
pilgrim# zfs list -o space tank/ds1/backup/pump-vol
NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD
tank/ds1/backup/pump-vol 8.41T 1.38T 186G 259G 966G 0B
pilgrim# zfs list -t snapshot -r tank/ds1/backup/pump-vol
NAME USED AVAIL REFER MOUNTPOINT
\# [...]
tank/ds1/backup/pump-vol@autosnap_2022-03-15_00:00:00_daily 20.4G - 255G -
tank/ds1/backup/pump-vol@autosnap_2022-03-16_00:00:00_daily 18.0G - 256G -
tank/ds1/backup/pump-vol@autosnap_2022-03-17_00:00:00_daily 24.3G - 256G -
@mshroyer
mshroyer / firewall.sh
Last active March 28, 2021 19:21
iptables firewall script for buildserv
#!/bin/sh
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: iptables firewall
# Description: Custom iptables firewall
@mshroyer
mshroyer / gdb-select-window.el
Created November 24, 2012 21:31
Keyboard navigation between emacs gdb windows
;; For the consistency of gdb-select-window's calling convention...
(defun gdb-comint-buffer-name ()
(buffer-name gud-comint-buffer))
(defun gdb-source-buffer-name ()
(buffer-name (window-buffer gdb-source-window)))
(defun gdb-select-window (header)
"Switch directly to the specified GDB window.
Moves the cursor to the requested window, switching between
`gdb-many-windows' \"tabs\" if necessary in order to get there.

Keybase proof

I hereby claim:

  • I am mshroyer on github.
  • I am mshroyer (https://keybase.io/mshroyer) on keybase.
  • I have a public key ASA2h00MxaCBoqlksCoSazZI054vW-doxongnIjItzytfAo

To claim this, I am signing this object:

#!/bin/sh
# From Arch Linux wiki
#xmodmap -e "pointer = 1 8 3 4 5 6 7 2 9 10 11 12 13"
# Based on https://help.ubuntu.com/community/Logitech_Marblemouse_USB, but
# with modifications to the button map and inverted axes for scrolling.
xinput set-button-map "Logitech USB Trackball" 1 8 3 4 5 6 7 2 9
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Button" 8 8
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation" 8 1
#include "ti86asm.inc"
; ===========================
; Emblem 86 version 1.1 gamma
; ===========================
; Mark's new label
; This is an 86 assembly program that allows users to draw a custom emblem for
; their calculators (on-calc) and install it in a user-interrupt routine so that
; it will be constantly present in the upper-right corners of their screens.