Skip to content

Instantly share code, notes, and snippets.

Avatar

KillyMXI KillyMXI

View GitHub Profile
View issue-reproduction-2.ts
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; }
View bin_vis_exerpt.js
// #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 / 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/
View Next.QTTabBarCommand
<?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 / Shuffle-Groups.ps1
Created April 29, 2021 15:23
Shuffle groups in an AIMP playlist ("*.aimppl4") while preserving the order inside groups.
View Shuffle-Groups.ps1
<#
.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
View README.md

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 / GeoInfoService.cs
Last active March 28, 2021 13:13
GetGeoInfoEx C# example
View GeoInfoService.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
namespace GeoInfoService
{
public static class GeoInfoService
{
View index.html
<!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
View index.html
<!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 / graphemeCountExample.hs
Last active April 16, 2020 07:41
Haskell grapheme cluster examples
View graphemeCountExample.hs
import Data.Text.ICU
import qualified Data.Text as T
graphemeClustersCount :: LocaleName -> T.Text -> Int
graphemeClustersCount loc = length . breaks (breakCharacter loc)
testStr = "😀éé"
main :: IO ()
main = print $ graphemeClustersCount Current $ T.pack $ testStr
@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.
View Next.QTTabBarCommand
<?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">