Skip to content

Instantly share code, notes, and snippets.

@TerrorBite
TerrorBite / bashttpd.sh
Last active February 5, 2021 11:37
A webserver… written as a shell script. This is a terrible idea. MIT license
#!/bin/bash
# Let's write a webserver in Bash because haha why not
# Copyright (c) 2017-2020 TerrorBite <terrorbite@lethargiclion.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
from typing import Dict, Any, Type, TypeVar, Optional, Sequence, Union
from contextlib import contextmanager
T = TypeVar
class NamedConstantMeta(type):
def __init__(cls, *args, **kwargs):
super().__init__(*args, **kwargs)
#: This class attribute will be the dict mapping constant names to their constants.
/*
Piston Elevator Controller
A Space Engineers script by TerrorBite
(Not just for elevators! Can be used any time that you want a piston to move to a
certain preset length and then turn off.)
WARNING: You may experience some lag while the piston is moving (especially after running
the game for a long time). This is unavoidable and is a result of the Program Block being
run repeatedly and rapidly by a Timer Block in order to monitor the piston. I have taken
@TerrorBite
TerrorBite / gw2.py
Created December 15, 2016 09:07
This file was a work in progress
import struct
import crc32c
import errno
import gw2util
# Headers
gw2_header1 = struct.Struct("<B3sIII")
gw2_header2 = struct.Struct("<IIQII")
# GW1 header
@TerrorBite
TerrorBite / ircbotframe.py
Last active February 20, 2023 05:21
Python IRC chat bridge for Vanilla Minecraft
import socket
import threading
import re
import time
class ircOutputBuffer:
# Delays consecutive messages by at least 1 second.
# This prevents the bot spamming the IRC server.
def __init__(self, irc):
self.waiting = False
@TerrorBite
TerrorBite / assembler.py
Created April 22, 2012 15:43
DCPU-16 Assembler written in Python
import struct, re, argparse
# This regex matches lines that look vaguely like assembly code
re_prelim = re.compile(r'(?:[A-Z]{3}|[a-z]{3})\s')
# This regex is used to parse the data from a line of assembly code
re_line = re.compile(
r'^(?:\S+\s+)?(?P<instr>[A-Z]{3}|[a-z]{3})\s+(?P<arga>[A-Za-z0-9_\[\]+]+)\s*(?:,\s*(?P<argb>[A-Za-z0-9_\[\]+]+))?'
)
@TerrorBite
TerrorBite / X-Clacks-Overhead.conf
Last active December 24, 2023 02:48
GNU Terry Pratchett
# The Hour of the Dead was when men died. And when a man died, they sent him
# home by clacks.
#
# Moist's mouth dropped open. 'Huh?'
#
# 'That's what they call it,' said Harry. 'Not lit'rally, o' course. But they
# send his name from one end of the Trunk to the other, ending up at the tower
# nearest his home.'
#