Skip to content

Instantly share code, notes, and snippets.

@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 Aug 7, 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');
}
View bitfield-reactivity.js
/** @type {?Scope} */
let curr_scope = null;
/**
* @param {boolean} [detached]
* @returns {Scope}
*/
export function scope (detached) {
let instance = new Scope(detached);
return instance;
@intrnl
intrnl / _velvet-don.js
Last active May 23, 2022
Velvet document object notation
View _velvet-don.js
let SVG_NS = 'http://www.w3.org/2000/svg';
let ELEMENT_BRANCH = 1;
let ELEMENT_CE_BRANCH = 2; // separate branch for `is`
let ELEMENT_PLACEHOLDER_BRANCH = 3; // creates `x` element
let ATTRIBUTE_LEAF = 4;
let ATTRIBUTE_BOOLEAN_LEAF = 5;
let TEXT_LEAF = 6;
let WHITESPACE_LEAF = 7; // the same as TEXT_NODE but only one space
let MARKER_LEAF = 8; // the same as TEXT_NODE but no content
@intrnl
intrnl / _raceAllSettled.js
Last active May 13, 2022
Race promises into settled values with concurrency limit
View _raceAllSettled.js
async function* raceAllSettled (iterable, concurrency = 4) {
const executing = new Set();
const consume = async () => {
const value = await Promise.race(executing);
executing.delete(value.promise);
delete value.promise;
return value;