Skip to content

Instantly share code, notes, and snippets.

@meseta
meseta / skgm-cloud-init.sh
Last active December 28, 2023 05:44
Initialization script for a quick SKGM-controlled server on DigitalOcean, Ubuntu 22.04
#!/bin/bash
apt-get update
apt-get install --no-install-recommends --yes \
curl \
ca-certificates \
gpg \
gpg-agent \
dirmngr
@meseta
meseta / buffer_compress_gzip.gml
Last active December 23, 2023 07:16
GML gzip compression, making use of the built-in deflate compression with buffer_compress
/** Compresses a buffer using gzip (deflate)
* @param {Id.Buffer} _buffer The buffer to compress
* @param {Real} _offset the offset in buffer to start compressing
* @param {Real} _size the number of bytes to compress
* @return {ID.Buffer}
*/
function buffer_compress_gzip(_buffer, _offset, _size) {
// Pre-calculated CRC table
static _crc_table = undefined;
if (is_undefined(_crc_table)) {
@meseta
meseta / gamemaker-builder-cloud-init.sh
Last active December 27, 2023 13:18
Initialization script for a quick GameMaker linux builder on DigitalOcean, Ubuntu 20.04
#!/bin/bash
echo "deb http://security.ubuntu.com/ubuntu xenial-security main" > /etc/apt/sources.list.d/xenial-security.list
apt-get update
apt-get install --no-install-recommends --yes \
curl \
gnupg \
ca-certificates \
build-essential \
@meseta
meseta / MaxHeap.gml
Last active December 15, 2023 21:43
GML MaxHeap implementation
/** A max-heap implementation (i.e. priority queue). value-priority pairs can be inserted into the heap, which wil
* efficiently maintain sort order, and the maximum priorty value can be queried at any time
* @author Meseta https://meseta.dev
*/
function MaxHeap() constructor {
/* @ignore */ self.__values = []; // Heap-ordered storage. array of value/priority pairs, the zerth index is maintained to be highest priority
/* @ignore */ self.__length = 0;
/** Returns how many elements are in the heap
* @return {Real}
@meseta
meseta / MinHeap.gml
Last active December 15, 2023 21:44
GML MinHeap implementation
/** A min-heap implementation (i.e. priority queue). value-priority pairs can be inserted into the heap, which wil
* efficiently maintain sort order, and the minimum priorty value can be queried at any time
* @author Meseta https://meseta.dev
*/
function MinHeap() constructor {
/* @ignore */ self.__values = []; // Heap-ordered storage. array of value/priority pairs, the zerth index is maintained to be lowest priority
/* @ignore */ self.__length = 0;
/** Returns how many elements are in the heap
* @return {Real}
@meseta
meseta / Logger.gml
Last active December 23, 2023 22:40
GML Structured Logger
/** A logger instance that can be used for writing log messages
* @param {String} _name The logger's name. This will appear in any log messages produced by this logger
* @param {Struct} _bound_values Optional struct of bound values which will be included in all log messages produced by this logger
* @param {Struct.Logger} _root_logger The loot logger instance that is this logger's parent
* @author Meseta https://meseta.dev
*/
function Logger(_name="logger", _bound_values=undefined, _root_logger=undefined) constructor {
/* @ignore */ self.__name = _name;
/* @ignore */ self.__bound_values = (is_struct(_bound_values) ? _bound_values : {});
/* @ignore */ self.__file_handle = -1;
@meseta
meseta / quora_dump_parser.py
Last active June 16, 2021 21:53
Converts quora dumps that you can request Quora to send you (multiple zip files) into parsed json and markdown
""" Converts quora dumps that you can request Quora to send you (multiple zip files) into parsed json and markdown
To use:
1. install dateparser, beautifulsoup4, markdownify
2. copy the zips you've received to ./data, make sure to keep only the ones containing answers (some will
contain comments, blog posts, and other metadata)
3. run this script
4. see ./output folder
License (MIT):
Copyright 2021 Yuan Gao