Skip to content

Instantly share code, notes, and snippets.

View jpouellet's full-sized avatar

Jean-Philippe Ouellet jpouellet

View GitHub Profile
@jpouellet
jpouellet / README.md
Last active June 18, 2018 10:29
OpenBSD kernel testing automation

This assumes you have:

  • a development machine, here called "dev"
  • a device under test, here called "dut"
  • a serial console to dut
  • network access from dut to dev
  • the same arch dev and dut

You may need to change:

  • GENERIC (in dev:.ssh/authorized_keys) to something else, e.g. maybe GENERIC.MP
@jpouellet
jpouellet / openbsd-next.sh
Last active May 1, 2019 11:24
Safely & monotonically fetch OpenBSD snapshots
#/usr/bin/env -i /bin/ksh
set -e
d=$(mktemp -d)
installurl=$(cat /etc/installurl)
ver=snapshots # uname -r
arch=$(machine)
baseurl="$installurl/$ver/$arch"
@jpouellet
jpouellet / mimeapps.list
Created May 12, 2017 00:51
Qubes screenshot helper
[Added Associations]
image/png=qubes-movetovm.desktop;
@jpouellet
jpouellet / qvm-filemanager.pl
Last active June 16, 2019 09:30
Qubes OS: Opens a file manager in the focused VM
#!/usr/bin/env perl
use strict;
use warnings;
sub open_file_manager {
my $vm = shift;
exec {'qvm-run'} ('qvm-run', '--', $vm, 'exec nautilus --new-window --no-desktop </dev/null >/dev/null') or die "qvm-run exec failed\n";
}
@jpouellet
jpouellet / duckhunter2.py
Last active November 14, 2023 20:00
A script to hunt ducks on IRC. Don't mind me...
#!/usr/bin/env python3
from sys import stdin
from random import choice
from time import sleep
duck_tail = "・゜゜・。。・゜゜"
duck = ["\_o< ", "\_O< ", "\_0< ", "\_\u00f6< ", "\_\u00f8< ", "\_\u00f3< "]
duck_noise = ["QUACK!", "FLAP FLAP!", "quack!"]
@jpouellet
jpouellet / jpo.WriteUSB
Created March 31, 2017 22:51
qubes-rpc service to write image to USB stick & return hash of contents actually written
#!/bin/bash
if [ $# -eq 0 ]; then
dev=/dev/sda
else
# Protected by arg-specific qubes-rpc policy.
dev=/dev/"$1"
fi
if ! [ -b "$dev" ]; then
@jpouellet
jpouellet / qvm-port-forward.sh
Last active February 1, 2024 12:50
Forwards a specified port to a specified VM, auto-detecting its NetVM chain. (Qubes OS)
#!/bin/sh
# Inspired by https://gist.github.com/daktak/f887352d564b54f9e529404cc0eb60d5
ip() { qvm-ls --raw-data ip -- "$1"; }
netvm() { qvm-prefs -g -- "$1" netvm; }
forward() {
local from_domain=$1
local to_domain=$2
@jpouellet
jpouellet / qubes-shutdown-focused.sh
Last active December 21, 2016 18:22
Shuts down the focused VM in Qubes
#!/bin/sh
# PROBLEM: Allows the front VM to close its focused window right before
# keystroke delivery, leading to shutting down the VM with the window in
# back. Effective denial of service.
set -e
front=$(xprop -notype -root _NET_ACTIVE_WINDOW | awk '{if (match($0,"^_NET_ACTIVE_WINDOW: window id # (0x[0-9a-f]*), 0x0$",m)){print m[1];} exit 0;}' )
test -n "$front"
#!/usr/bin/python
# -*- encoding: utf8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2015 Marek Marczykowski-Górecki
# <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@jpouellet
jpouellet / iwl-reset.sh
Last active December 10, 2016 00:40
Reload drivers for my intel wireless card automatically if it hangs (on suspend/resume)
#!/bin/sh
lock=/var/run/lock/iwl-reset.lock
fail_msg='iwlwifi 0000:00:00.0: Failed to load firmware chunk!'
do_reset='
echo "Resetting wifi..."
rmmod iwlmvm
rmmod iwlwifi