Skip to content

Instantly share code, notes, and snippets.

@disco0
disco0 / scut.styl
Created May 16, 2021 10:54 — forked from armornick/scut.styl
Translation of Scut to Stylus (https://davidtheclark.github.io/scut/)
/*
* Scut, a collection of Sass utilities
* to ease and improve our implementations of common style-code patterns.
* v1.1.2
* Docs at http://davidtheclark.github.io/scut
*
* Translated for Stylus by armornick
*/
scut-clearfix() {
// Extend in a media query
// =============================================================================
// Mixins
// -----------------------------------------------------------------------------
clearfix()
&:before,
&:after
content: ' '
display: tablet
@disco0
disco0 / ScopeTree.ts
Last active May 15, 2021 17:59 — forked from bradkovach/ScopeTree.ts
Tree with namespaces
interface IScopeNodeIndex<T> {
[path: string]: ScopeNode<T>
}
export class ScopeNode<T> {
constructor(
public value: T,
public children: IScopeNodeIndex<T> = {}
) {
@disco0
disco0 / mic-toggle.applescript
Created May 14, 2021 06:26 — forked from na0x2c6/mic-toggle.applescript
Mic mute toggle script on Mac
-- refs: https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ReadandWriteFiles.html
-- refs: https://medium.com/macoclock/how-in-the-bleep-do-i-mute-my-mic-anywhere-on-macos-d2fa1185b13
on writeTextToFile(theText, theFile, overwriteExistingContent)
try
set theFile to theFile as string
set theOpenedFile to open for access file theFile with write permission
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
@disco0
disco0 / WinFormExtensions.cs
Created April 26, 2021 10:29 — forked from MatthewKing/WinFormExtensions.cs
Extension methods for classes in the System.Windows.Forms namespace.
// Copyright Matthew King 2012-2015.
// Distributed under the Boost Software License, Version 1.0.
// (See http://www.boost.org/LICENSE_1_0.txt)
using System;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
@disco0
disco0 / PSReadLineMetaInfoKeyHandler.ps1
Created April 26, 2021 10:20 — forked from mklement0/PSReadLineMetaInfoKeyHandler.ps1
PowerShell sample code that demonstrates a PSReadLine key handler that display meta-information about the command being typed in real time.
<#
License: MIT
Author: Michael Klement <[email protected]>
#>
$printableAsciiRangeChars = [char[]] (0x20..0x7f) # 0x7f seemingly acts like Backspace.
$printableAsciiRangeChars + 'Delete' + 'Enter' + 'Escape' | ForEach-Object {
@disco0
disco0 / You Need To Implement Non-Generic.md
Created April 26, 2021 09:19 — forked from NoCheroot/You Need To Implement Non-Generic.md
Implementing IEnumerator<T> in PowerShell

In order to implement IEnumerator<T> you have to explicitly implement the Current member for IEnumerator<T> and IEnumerator ... but PowerShell won't let you have two different implementations of the same property, nor will it let you explicitly implement an interface member. So we do one at a time, like this:

First, make a non-generic IEnumerator, but implemented with the type you want in the end:

    class __Generator : System.Collections.IEnumerator {
        [int]$Actual = 0

        [object]get_Current() {
            return $this.Actual
@disco0
disco0 / index.js
Created April 19, 2021 05:22 — forked from nihonjinrxs/index.js
segment & concat with ffmpeg via node + fessonia
/* original command:
ffmpeg -i video.mp4 -filter_complex "[0:v]trim=1:2,setpts=PTS-STARTPTS[v0]; [0:a]atrim=1:2,asetpts=PTS-STARTPTS[a0]; [0:v]trim=120:125,setpts=PTS-STARTPTS[v1]; [0:a]atrim=120:125,asetpts=PTS-STARTPTS[a1]; [v0][a0][v1][a1]concat=n=2:v=1:a=1[out]" -map "[out]" output.mp4
*/
/*
Rewrite using Fessonia library in node.js
Get Fessonia: https://www.npmjs.com/package/@tedconf/fessonia
Fessonia Docs: https://tedconf.github.io/fessonia/
*/
@disco0
disco0 / xclip
Last active June 22, 2023 05:46
xclip-wsl - Windows clipboard xclip for WSL distributions.
#!/usr/bin/env zsh
###
### xclip(-wsl)
###
### Drop in xclip substitute for interacting with the Windows clipboard from
### WSL environment. Attempts to resolve various Windows clipboard interfaces
### on $PATH in order of performance, falling back to powershell executables'
### Get-Clipboard and Set-Clipboard (with priority to pwsh.exe)—
###
function Get-ArgumentCompleter {
<#
.SYNOPSIS
Get custom argument completers registered in the current session.
.DESCRIPTION
Get custom argument completers registered in the current session.
By default Get-ArgumentCompleter lists all of the completers registered in the session.
.EXAMPLE
Get-ArgumentCompleter