Skip to content

Instantly share code, notes, and snippets.

View KillyMXI's full-sized avatar

KillyMXI KillyMXI

View GitHub Profile
@KillyMXI
KillyMXI / index.html
Created October 8, 2020 11:04
Matrix (2D-array) transpose (http://jsbench.github.io/#87799f981586ca50fa03a337a905f779) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Matrix (2D-array) transpose</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>longest string</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@KillyMXI
KillyMXI / README.md
Created April 25, 2021 15:37
Node.js map/for performance benchmark comparison

Comparison of different way to map an array in Node.js

  • Properly used map is quite good;

  • Badly used for_i can be absolutely horrible;

  • A custom map-like function is on par with bare for_i;

  • Not all for_i loops are equally optimized;

@KillyMXI
KillyMXI / Shuffle-Groups.ps1
Created April 29, 2021 15:23
Shuffle groups in an AIMP playlist ("*.aimppl4") while preserving the order inside groups.
<#
.SYNOPSIS
Shuffle groups in an AIMP playlist ("*.aimppl4")
while preserving the order inside groups.
.PARAMETER inputPath
Input file to be shuffled ("*.aimppl4").
#>
// #region DIGRAMS ===============================================================================
function computeDigramColors(
/** @type { Uint8Array } */ uint8Array,
paletteKind = 'p5_lerp',
blendingMiddlePoint = 0.5
) {
const digramStats = Array.from({ length: 65536 }, () => ({
count: 0, // digram occurrences
offsetAcc: 0.0 // accumulator to compute average position
import { expectAssignable, expectType } from 'tsd';
type Some<T> = { _some: true, value: T };
type None = { _some: false };
type Option<T> = Some<T> | None;
type GetSome<T,R> = (input: T) => Some<R>;
type GetOption<T,R> = (input: T) => Option<R>;
function isSome<T>(option: Option<T>): option is Some<T> { return option._some; }
@KillyMXI
KillyMXI / README.md
Last active April 3, 2024 19:53
Obsidian live-preview list threading and highlight