Skip to content

Instantly share code, notes, and snippets.

@disco0
disco0 / wsl2-network.ps1
Created April 5, 2021 10:14 — forked from daehahn/wsl2-network.ps1
WSL 2 TCP NETWORK FORWARDING
# WSL2 network port forwarding script v1
# for enable script, 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' in Powershell,
# for delete exist rules and ports use 'delete' as parameter, for show ports use 'list' as parameter.
# written by Daehyuk Ahn, Aug-1-2020
# Display all portproxy information
If ($Args[0] -eq "list") {
netsh interface portproxy show v4tov4;
exit;
}
@disco0
disco0 / clip
Last active March 27, 2021 19:50 — forked from vor0nwe/clip
clip: WSL zsh script to both read and write to the Windows Clipboard
#!/usr/bin/env zsh
# Drop in xclip replacement for WSL
builtin emulate zsh -L
zparseopts -E -D -- {-help,h}=OPT_HELP {i,-in}=OPT_IN {o,-o}=OPT_OUT
local cmd=${0}
function xclip-help()
@disco0
disco0 / DisplayManager.cs
Created March 25, 2021 09:54 — forked from emoacht/DisplayManager.cs
Manage display devices.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
public static class DisplayManager
{
@disco0
disco0 / README.md
Last active February 4, 2021 08:54
Boilerplate for zsh completion scripts

Preview:

@disco0
disco0 / About Split-WtTab.md
Created January 25, 2021 07:40 — forked from Jaykul/About Split-WtTab.md
I wrote all of this just to get Split-WTTab

I've been using Windows Terminal since the source code was released, and now that we have support for split panes, I wanted a way to easily create a tab with three panes (one for each version of PowerShell I want to test against).

Unfortunately, there's no support for opening tabs from the command-line yet, nor is there any support yet for specifying which profile to use in a new split terminal. There are open issues for those features, but although I've done a PR or two for it, I didn't think it would be an easy thing to pull together, but I knew that new tabs use the default profile.

Switching the default profile and then creating a new split with the hotkeys works great,

@disco0
disco0 / Show-JsonTreeView.ps1
Created January 18, 2021 05:50 — forked from matthewoestreich/Show-JsonTreeView.ps1
Displays JSON Data in TreeView
function Show-JsonTreeView {
param (
[Parameter(Mandatory)]
$Json
)
function Show-jsonTreeView_psf {
#----------------------------------------------
@disco0
disco0 / calc.styl
Last active December 29, 2020 07:07
Stylus - CSS Calc function wrapper
/**
* Builds css calc function expression literal for css property value.
* Gives ability to drop in variables at the cost of escaping operators, or
* get both with format string
*/
calc()
unless length(arguments) > 0
error('Calc wrapper requires at least one syntax element in `arguments`.')
@disco0
disco0 / opera.d.ts
Last active October 14, 2022 17:34
TypeScript - window.opera typings
// Type definitions for Opera Browser `opera` global object
// Because why not
// Definitions by: disk0 <https://github.com/disco0>
// This definition is based on various external documentation pages online
// https://web.archive.org/save/http://www.howtocreate.co.uk/operaStuff/operaObject.html
/**
* Opera browser specific global `opera` object.
*/
declare interface OperaObject
@disco0
disco0 / Console-TemplateLiteralFormatSpecifiers.ts
Last active December 21, 2020 11:52 — forked from joaomilho/log.ts
A printf with dependant types in TypeScript, similar to Idris (https://gist.github.com/chrisdone/672efcd784528b7d0b7e17ad9c115292)
///<reference lib="dom"/>
//#region Implementation
type FieldType<Field> =
's' extends Field ? string :
'f' extends Field ? number :
'i' extends Field ? number :
'd' extends Field ? number :
'o' extends Field ? HTMLElement :
// Don't ask about this one. I have no idea what this magic is.
// Copied from https://github.com/microsoft/TypeScript/issues/13298#issuecomment-724542300.
type UnionToIntersection<U> =
(U extends any ? (arg: U) => any : never) extends (arg: infer I) => void
? I
: never;
// Continuation of above.
type UnionToTuple<T> =
UnionToIntersection<(T extends any ? (t: T) => T : never)> extends (_: any) => infer W