Skip to content

Instantly share code, notes, and snippets.

View jpouellet's full-sized avatar

Jean-Philippe Ouellet jpouellet

View GitHub Profile
@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 / zbell.sh
Last active November 24, 2023 10:49
Makes Zsh print a bell when long-running commands finish. I use this in combination with i3 and throw big compile jobs (or whatever it may be) into another workspace to get a nice visual notification (workspace indicator turns red) when it's done so I don't need to waste time regularly checking on it.
#!/usr/bin/env zsh
# This script prints a bell character when a command finishes
# if it has been running for longer than $zbell_duration seconds.
# If there are programs that you know run long that you don't
# want to bell after, then add them to $zbell_ignore.
#
# This script uses only zsh builtins so its fast, there's no needless
# forking, and its only dependency is zsh and its standard modules
#
@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 / qubes-wifi-toggle.sh
Last active February 19, 2023 19:25
Enable/disable WIFI in Qubes via keyboard shortcut
#!/bin/sh
exec qvm-run sys-net '[ X"$(nmcli radio wifi)" = Xdisabled ] && x=on || x=off; nmcli radio wifi $x'
@jpouellet
jpouellet / dhcpd.py
Last active August 8, 2022 14:31
Tiny PXE boot server for specific mac address w/ no side effects. (No DHCPNAKs to other hosts.)
#!/usr/bin/env python
import argparse
import struct
import logging
logging.getLogger('scapy').setLevel(logging.WARNING)
from scapy.all import *
def packMAC(s):
@jpouellet
jpouellet / lmod_autocompletion.bash
Last active April 7, 2022 00:33
Bash autocompletion plugin for TACC's module system
#!/bin/bash
# Bash autocompletion module for TACC's lmod
# http://www.tacc.utexas.edu/tacc-projects/mclay/lmod
# Written by Jean-Philippe Ouellet <jpo@vt.edu> at ARC
# http://www.arc.vt.edu/
# Try to intelligently narrow the completion suggestions
@jpouellet
jpouellet / manuf.sh
Created July 5, 2016 03:41
Offline lookup of MAC address / vendor pairs using Wireshark OUI database.
#!/bin/sh
db_source='https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf'
z=$(basename -- "$0")
if [ -z "$MANUFDB" ]; then
MANUFDB=~/.cache/manuf.db
fi
db=$MANUFDB
@jpouellet
jpouellet / qubes-install-spotify.sh
Created October 11, 2016 17:55
Set up Spotify in a debian-based Qubes VM
#!/bin/sh
set -e
url='https://repository-origin.spotify.com/pool/non-free/s/spotify-client/'
d=$(mktemp -d)
echo "Fetching index..."
wget -q -O "$d/index" "$url"
@jpouellet
jpouellet / zeroconf-guide.md
Last active March 3, 2021 09:58
Python ZeroConf guide for ECE-4564

Python ZeroConf guide, by Jean-Philippe Ouellet, for VT ECE-4564

Installing pybonjour

We want to install [pybonjour][pybonjour]. [pybonjour]: https://code.google.com/p/pybonjour/

Unfortunately it isn't easily installable with pip or the like, so we must build it ourselves.

Dependencies

@jpouellet
jpouellet / qvm-terminal.pl
Last active October 31, 2020 08:01
Opens a terminal in the front-most Qubes VM.
#!/usr/bin/env perl
use strict;
use warnings;
sub dom0_term {
(exec 'xfce4-terminal') or (exec 'xterm') or die "dom0 terminal exec failed\n";
}
sub domU_term {