Skip to content

Instantly share code, notes, and snippets.

stream {
###
### Setup
###
# connection-limiting
limit_conn_zone $binary_remote_addr zone=addr:10m;
limit_conn_log_level warn;
limit_conn addr 1;
@aschuhardt
aschuhardt / StreamExtensions.cs
Last active July 21, 2023 23:34
An implementation of the PROXY-protocol (version 2) for .NET/C# Stream objects
/*
Copyright 2023 by Addison Schuhardt
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@aschuhardt
aschuhardt / transform_tilesets.ps1
Created May 9, 2023 23:08
A Powershell script that transforms a set of 128x96px tiles by converting black and magenta to transparent, then adding extra spacing between each tile
# I'm an ImageMagick newbie and don't know/care enough to make this performant
# I made this for working with this isometric walls pack: https://screamingbrainstudios.itch.io/isowallpack
foreach ($name in Get-ChildItem -Recurse -Filter *.png | ForEach-Object FullName) {
# convert magenta and black to transparent
mogrify -transparent "rgb(255,0,255)" $name;
mogrify -transparent "rgb(0,0,0)" $name;
# add 64px of spacing along the X-axis, and 32px along the Y-axis
convert $name -background None `
@aschuhardt
aschuhardt / blocklist.json
Last active December 19, 2022 02:54
Mastodon Blocklist
[
{
"domain": "pleroma.rareome.ga",
"reasons": [
"security-risk",
"hate speech",
"abuse"
]
},
{
@aschuhardt
aschuhardt / pattern.h
Last active May 30, 2023 08:28
Playdate pattern definitions in a single-header C library
/*
* This is a collection of Playdate patterns compiled into a header-only library
* for use in C SDK projects.
*
* The pattern definitions listed here are copied directly from Ivan Sergeev's
* 'gfxp' library, which can be found here: https://github.com/ivansergeev/gfxp
*
*
* USAGE:
*
@aschuhardt
aschuhardt / kill_ftb.sh
Created September 23, 2020 20:05
script to kill a minecraft server that was launched with launch_ftb.sh
if [ ! -f /tmp/ftb-session-name ]; then
echo "No session found! Was the server launched?"
exit 1
fi
command_prefix="screen -S $session_name -p 0 -X stuff "
crontab_file="/tmp/.cronjobs-$(date '+%s')"
session_name="$(cat /tmp/ftb-session-name)"
# dump existing cron jobs to file
@aschuhardt
aschuhardt / launch_ftb.sh
Created September 23, 2020 20:04
script to set up automatic reboots for minecraft server in a screen session
launch_dir="$HOME/rev3"
launch_script="$launch_dir/LaunchServer.sh"
session_name="ftb-server-$(date '+%s')"
command_prefix="screen -S $session_name -p 0 -X stuff"
crontab_file="/tmp/.cronjobs-$(date '+%s')"
echo "Launch directory: $launch_dir"
echo "Launch script: $launch_script"
echo "Session name: $session_name"
@aschuhardt
aschuhardt / ElasticBuffer.cs
Created April 26, 2020 05:28
A resizable buffer object that exposes its underlying array. This is handy for buffering vertex data directly from where it's stored in memory (i.e. without the additional copy operation that calling List<T>.ToArray() implies).
/// <summary>
/// A resizable buffer object with its underlying array exposed
/// </summary>
public class ElasticBuffer<T> : ICollection<T>
{
private int _capacity = 1, _count = 0;
private T[] _buffer;
public ElasticBuffer()
{
@aschuhardt
aschuhardt / Program.cs
Created February 23, 2018 16:50
Creates wavy text using Reddit's markup.
using System;
using System.Linq;
using System.Text;
namespace WavyText
{
class Program
{
private enum Direction
{
extern crate discord;
extern crate time;
extern crate rand;
use discord::{Discord, State};
use discord::model::{Event, Member};
use std::env;
use time::{SteadyTime, Duration};
use rand::Rng;