Skip to content

Instantly share code, notes, and snippets.

View MarkTiedemann's full-sized avatar

Mark Tiedemann MarkTiedemann

View GitHub Profile
function DataAppender(array = new Uint8Array(8)) {
let length = array.length;
let offset = 0;
let view = new DataView(array.buffer);
const textEncoder = new TextEncoder();
const grow = () => {
length = array.length * 2;
@MarkTiedemann
MarkTiedemann / toJson.kt
Created April 11, 2024 21:43
Kotlin toJson Extensions
private fun convertToJson(v: Any?): String {
return when (v) {
is String -> v.toJson()
is Boolean -> v.toJson()
is Number -> v.toJson()
is Array<*> -> v.toJson()
is Collection<*> -> v.toJson()
is Map<*, *> -> v.toJson()
else -> v?.toJson() ?: "null"
}
// Ported from https://github.com/deoxxa/proquint
const encodeConsonants = "bdfghjklmnprstvz".split("");
const encodeVowels = "aiou".split("");
const decodeConsonants = Object.fromEntries(encodeConsonants.map((x, i) => [x, i]));
const decodeVowels = Object.fromEntries(encodeVowels.map((x, i) => [x, i]));
export function encode(array: Uint16Array) {
const view = new DataView(array.buffer);
const bits = [];
<!DOCTYPE html>
<script>
customElements.define("x-input", class extends HTMLElement {
static formAssociated = true;
#input;
#internals;
constructor() {
super();
this.#input = document.createElement("input");
@MarkTiedemann
MarkTiedemann / ds.cmd
Last active March 9, 2023 22:50
Direct Strike Leaderboard API
@echo off
setlocal enabledelayedexpansion
if not exist %~dp0timeit.exe (
curl -Lo %~dp0timeit.exe https://github.com/MarkTiedemann/rktools2k3/raw/master/timeit.exe
)
if not exist %~dp0jq.exe (
curl -Lo %~dp0jq.exe https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe
)
@echo off
setlocal
:: Example for using the JGit CLI on Windows
:: Downloaded from https://gist.github.com/MarkTiedemann/4a91db19983867fa1cd0c72f496ead2e
:: d(irectory) p(ath) of argument 0 (the current batch file)
set "basedir=%~dp0"
:: Remove trailing slash
set "basedir=%basedir:~0,-1%"
const rawString = Symbol();
export interface RawString {
[rawString]: string;
};
export function raw(str: string): Readonly<RawString> {
const obj: RawString = Object.create(null);
obj[rawString] = str;
return Object.freeze(obj);
CSS Diner: https://flukeout.github.io/
Flexbox Froggy: https://flexboxfroggy.com/
Grid Garden: https://cssgridgarden.com/
@echo off
if not exist bun (
curl -LO https://github.com/oven-sh/bun/releases/download/bun-v0.1.2/bun-linux-x64.zip
tar xf bun-linux-x64.zip
move bun-linux-x64\bun bun
rd bun-linux-x64
del bun-linux-x64.zip
)
/// <reference no-default-lib="true"/>
interface ActiveXObject {
new (s: "Scripting.FileSystemObject"): FileSystemObject;
}
declare var ActiveXObject: ActiveXObject;
/**
* Provides access to a computer's file system.