Skip to content

Instantly share code, notes, and snippets.

@gesslar
gesslar / sid.js
Created May 2, 2024 19:19 — forked from Krizzzn/sid.js
Convert binary buffer object SID to string
/*
# Convert binary encoded object SID to a string
# (eg. S-1-5-21-1004336348-1177238915-682003330-512)
#
# SID format: https://technet.microsoft.com/en-us/library/cc962011.aspx
#
# ldapjs `searchEntry` has attribute `raw` that holds the raw
# values, including the `objectSid` buffer when one exists. Pass that
# buffer to get the string representation that can then be easily
# used in LDAP search filters, for example.
@gesslar
gesslar / sid.js
Created May 2, 2024 19:19 — forked from Krizzzn/sid.js
Convert binary buffer object SID to string
/*
# Convert binary encoded object SID to a string
# (eg. S-1-5-21-1004336348-1177238915-682003330-512)
#
# SID format: https://technet.microsoft.com/en-us/library/cc962011.aspx
#
# ldapjs `searchEntry` has attribute `raw` that holds the raw
# values, including the `objectSid` buffer when one exists. Pass that
# buffer to get the string representation that can then be easily
# used in LDAP search filters, for example.
@gesslar
gesslar / parse_response_intro.c
Last active December 24, 2023 21:13
takes the response from a remote server and parses it into a mapping
/*
Takes:
HTTP/1.1 400 Bad Request
Server: cloudflare
Date: Sun, 24 Dec 2023 20:51:56 GMT
Content-Type: text/html
Content-Length: 155
Connection: close
CF-RAY: -
@gesslar
gesslar / palindrome.js
Last active July 27, 2023 06:05
Detects palindromes!
// Skippable characters are spaces and punctuation and symbols
const skippable = char => char.match(/[\s\p{P}\p{S}]/u)
// Tests for numeric characters
const numeric = char => char.match(/\d/u)
// The whole meaty sandwich
const is_palindrome = word => {
// Grab the length of the word(s)
const len = word.length
// /cmds/race/_units.c
// Short description of this file and its purpose.
//
// Created: 2013/08/31: Gesslar
// Last Change: 2013/08/31: Gesslar
//
// 2013/08/31: Gesslar - Created
inherit STD_CMD ;
@gesslar
gesslar / admium_chest.c
Last active January 12, 2023 00:34
Sample menu-chest using loot table from Calinvar
// /d/thrace/mforest/sanguine/obj/chest.c
// Treasure chest for Wrathful Beast
//
// Created: 2023/01/11: Gesslar
// Last Change: 2023/01/11: Gesslar
//
// 2023/01/11: Gesslar - Created
#include <colors.h>
@gesslar
gesslar / diminish.c
Created January 1, 2023 03:07
Diminishing returns
float diminishing_returns(mixed val, mixed scale) {
float mult, trinum;
if(val < 0) return -diminishing_returns(-val, scale);
mult = val / to_float(scale);
trinum = (sqrt(8.0 * mult + 1.0) - 1.0) / 2.0;
return trinum * scale;
}
@gesslar
gesslar / wrap.c
Created November 4, 2022 18:53
Wrapping with colour codes and stuff
#define WRAP_DEFAULT_WIDTH 79
#define WRAP_DEFAULT_INDENT 0
#define IWRAP_DEFAULT_WIDTH 79
#define IWRAP_DEFAULT_INDENT 5
private string perform_wrap(string str, int wrapAt, int indent)
{
string *parts = explode(str, " ");
mapping running = ([ "length" : 0 ]);
#!/usr/bin/perl -pi
# Example usage:
# find mudlib -name "*.c" -print | xargs /path/to/this/script
# gesslar@LIAM:/frogdice/thresh/lib/d/sable/houses$ find . -name "*.c" -print | xargs /frogdice/thresh/scripts/house_update.pl
# update base room
if (/inherit\s+"\/d\/sable\/houses\/room_inherit"\s*;/) {
s-/d/sable/houses/room_inherit-/std/houses/rooms/room_inherit-;
@gesslar
gesslar / ColourList.js
Created August 20, 2022 23:00
Array of elements containing colour codes in order from 0-255, including Threshold, XTerm FG, XTerm BG, and Hex
const colorList = [
// Primary 3-bit [8 colors]. Unique representation!
[ "z00", "\e[38;5;0m", "\e[48;5;0m", "000000"],
[ "z01", "\e[38;5;1m", "\e[48;5;1m", "800000"],
[ "z02", "\e[38;5;2m", "\e[48;5;2m", "008000"],
[ "z03", "\e[38;5;3m", "\e[48;5;3m", "808000"],
[ "z04", "\e[38;5;4m", "\e[48;5;4m", "000080"],
[ "z05", "\e[38;5;5m", "\e[48;5;5m", "800080"],
[ "z06", "\e[38;5;6m", "\e[48;5;6m", "008080"],
[ "z07", "\e[38;5;7m", "\e[48;5;7m", "c0c0c0"],