Skip to content

Instantly share code, notes, and snippets.

@farsil
farsil / en.lng
Last active August 11, 2024 15:33
English localization reference for DOSBox Staging 0.82
:DOSBOX_HELP
Usage: %s [OPTION]... [PATH]
PATH If PATH is a directory, it's mounted as C:.
If PATH is a bootable disk image (IMA/IMG), it's booted.
If PATH is a CD-ROM image (CUE/ISO), it's mounted as D:.
If PATH is a DOS executable (BAT/COM/EXE), it's parent
path is mounted as C: and the executable is run. When
the executable exits, DOSBox Staging quits.
@farsil
farsil / tscalc.py
Created June 1, 2022 17:06
Realignment rolls calculator
import sys
from math import floor, ceil, inf, isinf
from dataclasses import dataclass
from argparse import ArgumentParser
@dataclass
class Boundaries:
min: int
max: int
@farsil
farsil / INSTALL.BAS
Created February 7, 2021 11:36
DOS Installer
DIM ProgramName AS STRING
DIM ProgramCommand AS STRING
DIM SetupCommand AS STRING
DIM DestDirectory AS STRING
DIM ArchiveFile AS STRING
' read installation settings from INSTALL.CFG
ConfigFile = FREEFILE
OPEN "INSTALL.CFG" FOR INPUT AS ConfigFile
DO WHILE NOT EOF(ConfigFile)
@farsil
farsil / Program.cs
Created August 22, 2020 11:02
PackTool
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace PackTool
{
@farsil
farsil / category-theory.md
Created August 13, 2020 10:20
Category Theory

Category Theory

Sets and classes

A class in set theory, is a collection of sets that can be unambiguously defined by a property that all of its members share. By this definition, every set is a class, and classes that are also sets are called small classes. Classes that are not sets are called proper classes.

Two example of proper classes are any collection of vector spaces, such as the collection all the sets obtained from the cartesian product of $\mathbb{R}$ with itself ($\mathbb{R}$, $\mathbb{R^2}$, $\mathbb{R^3}$, $\mathbb{R^4}$ and so on), and ordinal numbers, a generalization of natural numbers.

Categories

@farsil
farsil / battery
Created April 27, 2020 15:49
Battery blocklet for regolith-linux
#!/bin/bash
# Battery blocklet for Regolith
# This script was adapted from https://github.com/hastinbe/i3blocks-battery-plus
LABEL_COLOR=${label_color:-$(xrescat i3xrocks.label.color "#7B8394")}
VALUE_FONT=${font:-$(xrescat i3xrocks.value.font "Source Code Pro Medium 13")}
# Get battery status.
#
# Returns:
@farsil
farsil / volume-db
Created March 6, 2020 09:41
Sound Controller
#!/usr/bin/env bash
VALUE_FONT=${font:-$(xrescat i3xrocks.value.font "Source Code Pro Medium 13")}
VALUE_COLOR=$(xrescat i3xrocks.nominal white)
LABEL_COLOR=${label_color:-$(xrescat i3xrocks.label.color "#7B8394")}
read -r DEVICE MIXER <<< "$BLOCK_INSTANCE"
[[ -z "$DEVICE" ]] && DEVICE="default"
[[ -z "$MIXER" ]] && MIXER="Master"
@farsil
farsil / record.py
Created November 17, 2019 21:22
Records in python, the equivalent of a C struct.
#!/usr/bin/env python3
"""Record factory. A record is the equivalent of a C struct."""
import sys
import keyword
class_template = """\
import collections
class {typename}:
@farsil
farsil / pushv.sh
Last active March 31, 2017 14:26
POSIX-compliant function to prepend a path to an environment variable
#!/bin/sh
#
# Usage: pushv VAR PATH
#
# Prepends PATH to the VAR variable. VAR should be a variable name, the
# variable itself should contain a colon-separated list of paths. The function
# sets VAR if previously unset and marks it for exporting. This function does
# nothing if PATH does not exists or if it is already present in VAR.
#
# EXAMPLE
@farsil
farsil / process.py
Last active February 7, 2017 13:52
Template for command-line python script (file processing)
#!/usr/bin/env python3
'Module docstring.'
import argparse as ap
import glob as gl
import sys
def run(paths):
'Runs the algorithm.'
for glob in paths: