Skip to content

Instantly share code, notes, and snippets.

View sayotte's full-sized avatar

sayotte

  • United States, east coast
View GitHub Profile
package network
var uoHuffmanTree = [][]int{
/*node*/ /*leaf0 leaf1*/
/* 0*/
{2, 1},
/* 1*/
{4, 3},
/* 2*/
{0, 5},
@sayotte
sayotte / uo-compression-roundtrip.cs
Created December 28, 2022 22:10
data -> ServUO compression -> ClassicUO decompression round-trip is broken?
using System;
public class Program
{
// THIS IS TAKEN FROM SERVUO: https://github.com/ServUO/ServUO/blob/05cdc8780ecd81a6abca0f5f14097c8e6bc4860f/Server/Network/Compression.cs
internal static class ServUOCompressor {
private static readonly int[] _huffmanTable = new int[514]
{
0x2, 0x000, 0x5, 0x01F, 0x6, 0x022, 0x7, 0x034, 0x7, 0x075, 0x6, 0x028, 0x6, 0x03B, 0x7, 0x032, 0x8, 0x0E0, 0x8,
0x062, 0x7, 0x056, 0x8, 0x079, 0x9, 0x19D, 0x8, 0x097, 0x6, 0x02A, 0x7, 0x057, 0x8, 0x071, 0x8, 0x05B, 0x9, 0x1CC,
@sayotte
sayotte / calc-uo-dmg.sh
Created August 15, 2022 18:42
UORenaissance weapon damage calculations
#!/bin/bash
IFS=$'\n'
# Written in bash because I was in a hurry.
# Note that "dc" is a reverse-polish notation calculator.
#
# For the following, consider this example line:
# Magic Wand| 0 2d3 (2-6) 35 31-70 Mace *
for line in $(cat uo-dmg-table.txt); do
# weap="Magic Wand"
#!/usr/bin/python3
from collections import namedtuple
# Input is a CSV with these columns:
# name: string, Discord name
# availability: integer, scale of 3 (active daily) to 0 (borderline no-show)
# region: string, one of apac, est, eu, pst
# impact: integer, scale of 3 (effective, deadly callers) to 0 (non-pvper)
# I've kept the name in the first column for readability, but ordering of the
@sayotte
sayotte / setup-uor-ubuntu-20.04.sh
Created January 3, 2022 17:54
Setup UORenaissance on Ubuntu 20.04
#!/bin/bash
### Tested on Ubuntu 20.04 on 03 January 2022
# Purge Ubuntu-provided wine packages
sudo apt remove -y wine wine32 wine64 winetricks libwine
sudo apt autoremove -y
# Setup WineHQ apt repo
sudo dpkg --add-architecture i386
@sayotte
sayotte / 0-toposort.go
Last active July 10, 2021 21:25
Topological sorting example
package main
import "fmt"
func prepWorkAreaFunction(){ fmt.Println("prepping work area")}
func getBreadFunction(){ fmt.Println("getting bread")}
func addPBFunction(){ fmt.Println("adding peanut-butter")}
func addJellyFunction(){ fmt.Println("adding jelly")}
func combineSlicesFunction(){ fmt.Println("combining bread slices to form sandwich")}
@sayotte
sayotte / nil-interface.go
Created January 30, 2019 16:29
Nil-assignment gotcha
package main
import (
"fmt"
)
type Fooer interface {
Foo()
}
diff --git a/internal/dna/service.go b/internal/dna/service.go
index a23237a..9a58af8 100644
--- a/internal/dna/service.go
+++ b/internal/dna/service.go
@@ -6,6 +6,7 @@ import (
"strings"
"github.com/pkg/errors"
+ "regexp"
)
@sayotte
sayotte / charon.log
Created May 11, 2017 21:54
swanctl working, but unloads key on startup
00[LIB] loaded plugins: charon-systemd charon-systemd sha1 pem pkcs1 x509 revocation constraints pubkey openssl random nonce kernel-netlink socket-default updown vici
00[JOB] spawning 16 worker threads
00[DMN] executing start script 'creds' (/usr/local/sbin/swanctl --load-creds)
13[CFG] loaded RSA private key
00[DMN] creds: loaded rsa key from '/usr/local/etc/swanctl/rsa/serverKey.pem'
00[DMN] executing start script 'conns' (/usr/local/sbin/swanctl --load-conns)
16[CFG] added vici connection: pseudoprivate
16[CFG] installing 'pseudoprivatechild'
00[DMN] conns: loaded connection 'pseudoprivate'
00[DMN] conns: successfully loaded 1 connections, 0 unloaded
@sayotte
sayotte / certs-and-keys.log
Last active May 11, 2017 13:26
strongswan/swanctl config failing to load certs
$ find /usr/local/etc/swanctl/ -type f
/usr/local/etc/swanctl/x509/lb2Cert.der
/usr/local/etc/swanctl/rsa/lb2Key.der
/usr/local/etc/swanctl/swanctl.conf
/usr/local/etc/swanctl/x509ca/caCert.der