Skip to content

Instantly share code, notes, and snippets.

View batch-fetch.js
import { stableStringify } from '@intrnl/stable-stringify';
const defaultKey = () => {};
const defaultId = (x) => x.id;
export const createBatchedFetch = (options) => {
const {
fetch,
limit = 100,
View fast-uuidv4.js
let map;
function generateUUID () {
const buf = crypto.getRandomValues(new Uint8Array(16));
buf[6] = (buf[6] & 0x0f) | 0x40;
buf[8] = (buf[8] & 0x3f) | 0x80;
if (!map) {
map = [];
View middleware-runner.js
import http from 'node:http';
export function createRunner (middlewares) {
/**
* @param {http.IncomingMessage} request
* @param {http.ServerResponse} response
* @param {(error?: any) => void} done
*/
return function runner (request, response, done = createFinalHandler(request, response)) {
let idx = 0;
@intrnl
intrnl / _readme.md
Last active Jul 31, 2022
Create exclusion list for PSO2 NGS Global
View _readme.md

Creates an exclusion list to only download the NGS version for PSO2 Global.

You can't use this on a mainline version of Legendary just yet, pull request is still pending

@intrnl
intrnl / bench.mjs
Last active Jul 24, 2022
HTML escape function #bench
View bench.mjs
import { run, bench, group } from 'https://esm.sh/mitata';
function escape (value) {
const str = '' + value;
const res = str.replace(/[&<]/g, (char) => '&#' + char.charCodeAt(0) + ';');
return res;
}
View log-update.js
import * as tty from 'node:tty';
const isTTY = tty.isatty(1) && process.env.TERM !== 'dumb' && !('CI' in process.env);
export function createLogger (options = {}) {
let { text = '', interval = 50, stream = process.stdout, hideCursor = false } = options;
let rows = 0;
let timer;
@intrnl
intrnl / pso2-casefolding-guide.md
Last active Sep 18, 2022
A guide to make Phantasy Star Online 2: New Genesis run faster on Linux.
View pso2-casefolding-guide.md

PSO2 on Linux casefolding guide

Note
This guide is primarily written for the Global Steam version of the game, however it should apply more or less the same with other versions, including the Japanese version in case it starts allowing Linux gameplay as well. (JP currently does not have an up-to-date version of GameGuard anticheat).

I do not hold any liability for what happens if you mess up, be warned.
I would recommend reading through the entire guide even if certain parts may not apply to you.

PSO2 has a unique structure where each assets are contained in their own tiny files, mostly ranging around 3-4 KiB in size, and would even try to load assets that may potentially exist even if it's guaranteed to not exist, in turn this adds quite the considerable overhead for Wine to try to load these files off disk.

View x-target.js
/**
* @param {HTMLElement} node
* @param {string} target
* @returns {?HTMLElement}
*/
export function query (node, target) {
if (node.matches(`[x-target~='this.${target}']`)) {
return node;
}
@intrnl
intrnl / jsx2dom.js
Created Jun 18, 2022
JSX to DOM nodes
View jsx2dom.js
export function h (type, props, ...children) {
if (typeof type === 'function') {
if (props === null) {
props = {};
}
if (children.length > 0) {
props.children = children;
}
@intrnl
intrnl / firefox-fallback-font.css
Last active Jun 15, 2022
Fuck you Firefox for relying on fontconfig substitutions
View firefox-fallback-font.css
/* PostScript fonts */
@font-face {
font-family: 'Helvetica';
src: local('sans-serif');
}
@font-face {
font-family: 'Helvetica Narrow';
src: local('sans-serif');
}