Skip to content

Instantly share code, notes, and snippets.

View KillyMXI's full-sized avatar

KillyMXI KillyMXI

View GitHub Profile
@KillyMXI
KillyMXI / terminal-color-check.ps1
Created June 11, 2017 13:09
Terminal colors table (PowerShell)
$cs = @("Black","White","Gray","DarkGray","Red","DarkRed","Green","DarkGreen","Blue","DarkBlue","Cyan","DarkCyan","Magenta","DarkMagenta","Yellow","DarkYellow")
foreach ($tc in $cs) {
foreach ($bc in $cs) {
write-host " 123 " -foregroundcolor $tc -backgroundcolor $bc -noNewLine
}
write-host
}
@KillyMXI
KillyMXI / recentmost-example.ps1
Last active September 22, 2017 11:37
Get N most recent (or by any other value function) files without sorting entire list.
function InsertSorted($array, $item, $maxn, [scriptblock]$valueFunction) {
$a = $valueFunction.InvokeReturnAsIs($item);
$j = for($i = 0; $i -lt $array.Count; $i++) {
$b = $valueFunction.InvokeReturnAsIs($array[$i]);
if ($a -lt $b) { $i; break }
}
if($j -eq $null) {
return ($array[0..($array.Count-1)] + $item)[-$maxn..-1];
} elseif($j -eq 0) {
if($array.Count -lt $maxn) {
@KillyMXI
KillyMXI / unicodeNorm.hs
Created November 18, 2017 19:21
Haskell Unicode normalization
import Data.Text.Normalize
import qualified Data.Text as T
import GHC.IO.Encoding
import System.Win32.Console
procString :: (T.Text -> T.Text) -> String -> String
procString f = T.unpack . f . T.pack
testStr = "😀éé"
@KillyMXI
KillyMXI / index.html
Last active January 14, 2018 14:31
Mouse scroll emulation test
<!DOCTYPE html>
<html>
<head>
<title>Mouse scroll emulation test</title>
<link href="style.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.16/p5.js"></script>
<script src="pointerlock.js"></script><!-- https://github.com/IceCreamYou/PointerLock.js -->
<script src="sketch.js"></script>
</head>
@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
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 / graphemeCountExample.hs
Last active April 16, 2020 07:41
Haskell grapheme cluster examples
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 / 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 / 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
{