Skip to content

Instantly share code, notes, and snippets.

View KillyMXI's full-sized avatar

KillyMXI KillyMXI

View GitHub Profile
@KillyMXI
KillyMXI / README.md
Last active April 3, 2024 19:53
Obsidian live-preview list threading and highlight
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; }
// #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
@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").
#>
@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;

<!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 / 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>
@KillyMXI
KillyMXI / GeoInfoService.cs
Last active March 28, 2021 13:13
GetGeoInfoEx C# example
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
namespace GeoInfoService
{
public static class GeoInfoService
{
@KillyMXI
KillyMXI / Next.QTTabBarCommand
Created December 20, 2018 12:00
A pair of buttons for [QTTabBar](http://qttabbar.wikidot.com/) to navigate between folders within one common parent folder.
<?xml version="1.0" encoding="utf-8"?>
<CommandButtonInfo>
<MetaData>
<DateCreated>2016-03-24T15:45:16.0981452+03:00</DateCreated>
<Author>MXI</Author>
<Contact>http://mxii.eu.org/</Contact>
<Description>Navigate to the next folder within common parent folder.</Description>
<Version>1.0</Version>
</MetaData>
<CommandButton Type="File" SubType="Normal" PersistentID="20753363">
@KillyMXI
KillyMXI / Next.QTTabBarCommand
Last active August 8, 2021 03:51
A pair of buttons for QTTabBar (http://qttabbar.wikidot.com/) to navigate between folders within one common parent folder. More about this: http://mxii.eu.org/2018/12/22/next-folder-previous-folder-navigation-in-explorer-with-qttabbar/
<?xml version="1.0" encoding="utf-8"?>
<CommandButtonInfo>
<MetaData>
<DateCreated>2016-03-24T15:45:16.0981452+03:00</DateCreated>
<Author>MXI</Author>
<Contact>http://mxii.eu.org/</Contact>
<Description>Navigate to the next folder within common parent folder.</Description>
<Version>1.0</Version>
</MetaData>
<CommandButton Type="File" SubType="Normal" PersistentID="20753363">