Skip to content

Instantly share code, notes, and snippets.

View TylerLeonhardt's full-sized avatar
🌴
Vacation!

Tyler James Leonhardt TylerLeonhardt

🌴
Vacation!
View GitHub Profile
@TylerLeonhardt
TylerLeonhardt / Plotting with Xplot using type accelerators.ipynb
Created February 24, 2020 16:51
Plotting with Xplot using type accelerators
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TylerLeonhardt
TylerLeonhardt / repro.js
Created February 12, 2020 23:46
Works by running `node repro.js` but doesn't work in a VS Code extension
const spawn = require("child_process").spawn;
const msi = spawn("msiexec", ["/i", "C:\\Users\\tyleonha\\Downloads\\PowerShell-7.0.0-rc.2-win-x64.msi"], {
detached: true,
stdio: "ignore",
shell: false,
windowsHide: true,
});
msi.unref();
@TylerLeonhardt
TylerLeonhardt / PowerShellNotebook.ipynb
Last active March 11, 2020 16:46
An example PowerShell Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TylerLeonhardt
TylerLeonhardt / invokePowerShell.py
Created September 12, 2019 05:55
Invoke a PowerShell script in your iTerm2 Status Bar
#!/usr/bin/env python3.7
import iterm2
import asyncio
import subprocess
# Icons are base64-encoded PNGs. The first one is 32x34 and is used for Retina
# displays. The second is 16x32 and is used for non-Retina displays.
ICON2X = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAiCAYAAAA+stv/AAAABGdBTUEAALGPC/xhBQAAAWJJREFUWMPtVzsOgkAQRRIas4UdsTI0FhzDG1BwChrOYW1nTaPewsIL2JDY2HgBKisdk0cyEl2XWcniZ5KXEJiZ99hdZgbP+5udnQBndgG+T8CAMHyjgCFyGpMvCVuCeuE7BnSmkGtpKiIkHPFmTREBISUUhJJQASXupfBpkl+QMzRdhYiJWOFeQjiwZX+GA3w9xNbkUdtzcAvYEaaEOSPYE3JCjDdUuM7xrPabI3YnIedWk58JGcHX+PrwOTMRVpYw8lmLuBkTkUjJA7bnmSA+Y2cikAhI2Z77gnifnYlUIqBAcG6xhTlyFJLgEsGxhYAYOUrTrsa7W4VgZSFAIUel4bmr6by2dyHgEc9dTee1vYsteMTT30Po/DN0Xoicl2Lnzej2CS0II4t2PEIOJSGvJ5m1xUCyeTJZGZM3J5m2I1mkGe9eChCNUZrxrvUqTN74ZzSxLOk/+Gf0MQKMulqv7Qpwm6+awd/XXAAAAABJRU5ErkJggg=="
#region UX config
Import-Module posh-git
if (Get-Module PSReadLine) {
Import-Module oh-my-posh
$ThemeSettings.MyThemesLocation = "~/.config/powershell/oh-my-posh/Themes"
if (Get-Theme | Where-Object Name -eq Sorin-NL) {
Set-Theme Sorin-NL
@TylerLeonhardt
TylerLeonhardt / Update-macOSAppearance.ps1
Created August 8, 2019 07:27
A function to update the macOS appearance to Dark or Light mode!
function Update-macOSAppearance {
param(
[parameter(Mandatory)]
[ValidateSet('Dark', 'Light')]
$Mode
)
$currentMode = defaults read -globalDomain AppleInterfaceStyle
$appleScriptCommand = 'osascript -e ''tell application \"System Events\" to tell appearance preferences to set dark mode to not dark mode'''
if ($Mode -eq 'Light' -and ($currentMode -eq "Dark")) {
@TylerLeonhardt
TylerLeonhardt / Get-Vim.ps1
Last active August 1, 2019 17:37
Helps install vim on Linux without needing sudo (this will build and install vim and its dependency ncurses)
param(
# Version of ncurses to download
[Parameter()]
[string]
$NCursesVersion = '6.1'
)
# Create the directory that we'll add to the path.
if (!(Test-Path ~/usr/local)) {
New-Item ~/usr/local -ItemType Directory -Force | Out-Null
@TylerLeonhardt
TylerLeonhardt / Init.vim
Last active August 1, 2019 17:22
my Init.vim
if has("nvim")
call plug#begin('~/.local/share/nvim/plugged')
else
call plug#begin('~/.vim/plugged')
endif
" set rtp^=/Users/tyler/Code/PowerShell/coc-powershell/
Plug 'vim-airline/vim-airline-themes'
Plug 'bling/vim-airline'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
@TylerLeonhardt
TylerLeonhardt / AzFuncEnvironment.psm1
Last active August 21, 2020 13:15
Helper module that helps emulate the Azure Functions environment in a PowerShell session.
<#
Helper module that helps emulate the Azure Functions environment in a PowerShell session. It do so by:
1. Modifying the PSModulePath
2. Loading Azure Functions DLLs so custom types are available
3. Setting up TypeForwards for the Http*Context types since the Azure Functions runtime does this
Usage:
@TylerLeonhardt
TylerLeonhardt / DefaultBrowser.ps1
Last active June 2, 2021 08:43
Get and Set the default browser on macOS. Also is an example at how to leverage other scripting languages within PowerShell
# NOTE: This still pops a dialog... I can't seem to figure out how to -Force it to not show.
function Set-DefaultBrowser {
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory = $true)]
$BrowserId
)
$pythonScript = @"
from LaunchServices import LSSetDefaultHandlerForURLScheme