Skip to content

Instantly share code, notes, and snippets.

View reillysiemens's full-sized avatar
🦀
cargo install coffee

Reilly Tucker Siemens reillysiemens

🦀
cargo install coffee
View GitHub Profile
@reillysiemens
reillysiemens / Dockerfile
Last active September 29, 2021 10:05
I was wrong and Alex was right.
FROM python:latest
WORKDIR /test
ADD ./app.py /test
RUN pip install flask psycopg2-binary pytest
CMD ["pytest", "app.py"]
@reillysiemens
reillysiemens / bitmask_battleship.rs
Created March 3, 2021 11:07
Battleship, but it's an int.
//! # Bitmask Battleship
//!
//! The ship sections and their status are maintained in a 17-bit mapping. A
//! zero bit means the section is OK and a one means the section has been hit.
//!
//! ```text,ignore
//! 1
//! 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
//! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//! | C | b | c | s | d |
@reillysiemens
reillysiemens / cards.rs
Created August 11, 2019 06:59
Pretty Rust Cards
use std::fmt;
use std::str;
#[derive(Debug)]
pub enum Rank {
Ace,
Two,
Three,
Four,
Five,
@reillysiemens
reillysiemens / signing-vbox-kernel-modules.md
Last active March 26, 2024 06:20
Signing VirtualBox Kernel Modules

Signing VirtualBox Kernel Modules

These are the steps I followed enable VirtualBox on my laptop without disabling UEFI Secure Boot. They're nearly identical to the process described on [Øyvind Stegard's blog][blog], save for a few key details. The images here are borrowed from the [Systemtap UEFI Secure Boot Wiki][systemtap].

  1. Install the VirtualBox package (this might be different for your platform).
    src='https://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo'
@reillysiemens
reillysiemens / instructions.md
Last active December 28, 2018 05:27
Create a Windows 10 USB image from Fedora 29

Instructions

The URL https://git.io/this-time-for-real-tho links to the win10-usb.sh script below. It created something bootable from my Fedora 29 workstation.

Try to run

curl -L https://git.io/this-time-for-real-tho | sh

and if that doesn't work try explicitly setting an environment variable for the location of the .iso file

@reillysiemens
reillysiemens / README.md
Created December 19, 2018 23:03
Python Typing Optional String Callback

The Python here works just fine, but mypy doesn't like it...

example.py:14: error: Argument 1 to "callback" has incompatible type "Optional[str]"; expected "str"

The if url is None: conditional should prevent the url in the else block from ever being None, but maybe it doesn't work like that? Or I'm just wrong...

@reillysiemens
reillysiemens / README.md
Created December 19, 2018 05:54
Python Typing Protocol Default Class

This is perfectly fine Python. It outputs

Opening...
Opening...
1337
Closing...

when run, but Mypy complains...

example.py:29: error: Incompatible default for argument "cls" (default has type "Type[Concrete]", argument has type "SupportsOpenClose")
@reillysiemens
reillysiemens / callback.py
Created December 18, 2018 22:06
Python Callback Type Annotation
def fn(
url: str,
state: State,
payload_type: PayloadType,
verify: bool = True,
method: Callable[..., Response] = requests.post,
) -> None:
"""
Given a function with the above signature, how can the type of
``method`` be made more specific?
#!/usr/bin/env python3.6
# Copyright © 2018, Reilly Tucker Siemens <reilly@tuckersiemens.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@reillysiemens
reillysiemens / minecraft-backup.sh
Created January 21, 2018 01:07
Minecraft Backup
#!/bin/sh
: ${MINECRAFT_WORLD="survival"}
src="/srv/${MINECRAFT_WORLD}/world"
dst="/var/games/minecraft/${MINECRAFT_WORLD}.txz"
send_command() {
world=$1
cmd=$2