Skip to content

Instantly share code, notes, and snippets.

View DerMitch's full-sized avatar

Michael Mayr DerMitch

View GitHub Profile
@DerMitch
DerMitch / enumfield.py
Created April 21, 2021 12:38
Python Serde EnumField
from serde import fields, Model
from serde.exceptions import ValidationError
class EnumField(fields.Field):
"""
A field that can hold the value of an `enum.Enum`.
Args:
type: the concrete `Enum` this field can hold.
**kwargs: keyword arguments for the `Field` constructor.
@DerMitch
DerMitch / make_ipxe_uefi_usb.md
Created February 5, 2018 14:13 — forked from AdrianKoshka/make_ipxe_uefi_usb.md
Making a UEFI bootable iPXE USB drive

Making a UEFI bootable iPXE USB drive

Build the UEFI executable for iPXE

# First we'll clone iPXE
$ git clone git://git.ipxe.org/ipxe.git
# Go into the src directory of the cloned git repo
$ cd ipxe/src
# Compile the UEFI iPXE executable
@DerMitch
DerMitch / autoexec.cfg
Created July 11, 2016 19:05
TF2 Config
// Null-cancelling movement script
// (prevents you from pressing two opposing directions, which causes you to stop moving)
alias +mfwd "-back;+forward;alias checkfwd +forward"
alias +mback "-forward;+back;alias checkback +back"
alias +mleft "-moveright;+moveleft;alias checkleft +moveleft"
alias +mright "-moveleft;+moveright;alias checkright +moveright"
alias -mfwd "-forward;checkback;alias checkfwd none"
alias -mback "-back;checkfwd;alias checkback none"
alias -mleft "-moveleft;checkright;alias checkleft none"
@DerMitch
DerMitch / hidreader.py
Created August 19, 2014 15:37
Experiment: Read raw keys from an USB number pad
# See this for creating a udev rule to avoid the need to be root:
# https://peterkieser.com/2013/07/30/accessing-usb-devices-as-non-root-writing-udev-rules-the-easy-way/
# SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1241", ATTRS{idProduct}=="1503", GROUP="mitch", MODE="0660"
keymap = {
42: 'BACKSPACE',
83: 'NUMLOCK',
84: '/',
85: '*',
@DerMitch
DerMitch / newyear.py
Created December 31, 2013 23:28
2013 vs 2014
>>> datetime(2013, 12, 31, 23, 59, 59).strftime('%s')
'1388530799'
>>> datetime(2014, 1, 1, 0, 0, 0).strftime('%s')
'1388530800'
>>> # such change
>>> # much second
>>> # cool
@DerMitch
DerMitch / autoreload_supervisor.sh
Created October 31, 2013 15:33
auto-reload supervisord config on changes
#!/bin/sh
# auto-reload supervisor config on a config file change
# Licensed under Public Domain
# apt-get install inotify-tools
while true; do
inotifywait --quiet --recursive --event create,close_write /etc/supervisor/
supervisorctl reread
supervisorctl update
@DerMitch
DerMitch / bot.js
Created October 5, 2013 09:00
Gather and hut-building "bot" for A dark room (http://adarkroom.doublespeakgames.com/)
if ( window.AG ) {
window.AG.reset();
delete window.AG;
}
var AutoGame = function() {
this.gather_btn = $('#gatherButton');
this.traps_btn = $('#trapsButton');
this.buildtrap_btn = $('#build_trap');
this.buildhut_btn = $('#build_hut');