Skip to content

Instantly share code, notes, and snippets.

View KillyMXI's full-sized avatar

KillyMXI KillyMXI

View GitHub Profile
@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 / 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 / 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 / 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 / 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) {
function Invoke-Parallel {
<#
.SYNOPSIS
Function to control parallel processing using runspaces
.DESCRIPTION
Function to control parallel processing using runspaces
Note that each runspace will not have access to variables and commands loaded in your session or in other runspaces by default.
This behaviour can be changed with parameters.