Skip to content

Instantly share code, notes, and snippets.

View dmoerner's full-sized avatar

Daniel Moerner dmoerner

View GitHub Profile
@dmoerner
dmoerner / main.py
Created August 30, 2024 12:40
Toy implementation of "grep -E" written in Python. I worked on this as part of a challenge from codecrafters.io.
# mygrep: Implementation inspired by https://app.codecrafters.io/courses/grep.
# Includes support for grep -E functions:
# - ^: Start of string anchor
# - $: End of string anchor
# - \w, \d: Character classes
# - []: Character groups
# - *, +: Matching certain numbers of times
# - .: Wildcard
# - |: Alternation
# - (), \{digit}: Backreferences, including nested backreferences
@dmoerner
dmoerner / dmenu-vm-internet
Created March 25, 2021 12:56
Use dmenu to launch browsers by VM
#!/bin/sh
# Inspired by Holger Levsen's 2017 DebConf talk.
result="$(qvm-ls --no-spinner --raw-data --fields NAME,NETVM | egrep 'sys-whonix|sys-firewall|mirage-firewall' | awk -F '|' '{print $1}' | grep -v -e mirage-firewall -e sys-whonix | dmenu -fn "Monospace-12")"
[[ -n "$result" ]] || exit
if [[ "$result" == f33m-net-dvm ]]; then
#qvm-run -q -a --service --dispvm=$result -- qubes.StartApp+org.qutebrowser.qutebrowser
@dmoerner
dmoerner / dmenu-vm-terminal
Created July 11, 2020 03:11
Smartly open a terminal in any VM on Qubes
#!/bin/sh
# Inspired by Holger Levsen's 2017 DebConf talk.
result="$(qvm-ls --no-spinner --raw-data --fields NAME | dmenu)"
[[ -n "$result" ]] || exit
if [[ "$result" == "dom0" ]]; then
xterm