Skip to content

Instantly share code, notes, and snippets.

@DominoPivot
DominoPivot / mao.py
Last active November 4, 2018 07:23
spymao - 0h Game Jam 2018 entry
import random
deck = None
hand = None
def speak(message="", penalty=""):
maxlen = max(len(message), len(penalty))
# pad both parts even
@DominoPivot
DominoPivot / minimal-html5-template.html
Last active October 23, 2020 03:45
Minimalist HTML5 page template
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Template Site</title>
<header>
<a href="/">Template Site</a>
</header>
@DominoPivot
DominoPivot / .gitconfig
Last active August 19, 2022 16:49
Useful git aliases
[alias]
# Deletes branches that are gone from remote
gone = "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs -r git branch -D; }; f"
@DominoPivot
DominoPivot / multiline-regular-expressions.js
Last active August 19, 2022 16:56
Parse regular expressions with comments and whitespace
// Tag which parses a multiline regexp pattern into a RegExp object, removing whitespace and comments
export function mrx (strings) {
if (strings.length !== 1) {
throw Error("mrx cannot process template strings with arguments.")
};
// capture pattern and flags from a string in format `/pattern/flags`
const captureRx = /^\s*\/(.*)\/([a-z]*)\s*$/si;
const match = captureRx.exec(strings.raw[0]);
if (match === null) {
@DominoPivot
DominoPivot / cipher-helper.js
Last active August 19, 2022 16:58
Monoalphabetic Substitution Cipher Helper
// A tool to help you create or solve monoalphabetic substitution ciphers.
// This code is left to the public domain.
//
// Run this in a Node interactive session or web browser console.
// Start by creating a machine instance with m = machine(message);
// Call m.replace() to progressively replace each letter with a new one.
// Use lowercase for your original message and uppercase for the
// substituted letters so you and the code can tell them apart.
// m.frequency will give you the fequency of each letter in the message.
@DominoPivot
DominoPivot / codep.sh
Created September 2, 2022 06:29
Script that lets you be very lazy when it comes to creating/reopening a project in VS Code.
#!/bin/sh
if [ "$#" -ne 1 ]; then
cat <<- EOF
Usage: $0 PROJECT
Creates the ~/workspace/PROJECT directory if it doesn't exist and opens it in VS Code.
EOF
exit 1
fi