Skip to content

Instantly share code, notes, and snippets.

View instance-id's full-sized avatar

instance.id instance-id

View GitHub Profile
@instance-id
instance-id / RemoveGitString.ps1
Last active April 13, 2021 03:16
Search for and remove all directories that match a string from git tracking (Powershell on Linux host)
[CmdletBinding()]
param (
[Parameter()][String]$path = $HOME
)
$jobs = @()
$directories = @()
try {
Import-Module PoshRSJob
@instance-id
instance-id / Runspace_Module_Import.ps1
Last active April 13, 2021 18:23
Runspace testing. Probably best not to use it yet, though.
<#
.NOTES
=======================================================
Version: v0.1.00
Created: 04/11/2021
Platform: Linux/Windows
PSVersion: 7.2.4
=======================================================
.DESCRIPTION
Imports modules in separate runspace and returns them to main session
@instance-id
instance-id / Get-MostRecentPatchTuesday.ps1
Created April 8, 2021 23:08
Return the most recent 'Patch Tuesday' date in YYYY-MM-DD format
#region --------------------------------------- Get-PatchTuesday
# --- Modified from: https://github.com/tsrob50/Get-PatchTuesday
# --------------------------------------------------------------
Function Get-PatchTuesday {
[CmdletBinding()]
Param
(
[Parameter(position = 0)]
[ValidateSet('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')]
[String]$weekDay = 'Tuesday',
@instance-id
instance-id / UpdateRepos.ps1
Last active March 27, 2021 03:58
Auto pull all git repos that reside within a parent directory. (For those of us who are repo hoarders).
#!/usr/bin/env pwsh
<#
.NOTES
===========================================================
Created on: 03/26/2021
Created by: instance.id
Platform: Linux/Windows
Filename: updaterepos.ps1
PSVersion: 7.2-preview4
@instance-id
instance-id / profile.ps1
Created March 22, 2021 22:44
PowerShell $PROFILE
$env:PYTHONIOENCODING = 'utf-8'
Set-Alias Edit "C:\Users\$($env:UserName)\AppData\Local\Programs\Microsoft VS Code Insiders\Code - Insiders.exe"
# -------------------------------------------------------------- Functions
function move-the-cursor([int]$x, [int] $y) { $Host.UI.RawUI.CursorPosition = New-Object System.Management.Automation.Host.Coordinates $x , $y; $Host.UI.Write('Hello') }
function RunAsAdmin { Start-Process -Verb RunAs (Get-Process -Id $PID).Path }
function Update-PowerShell { Update-PowershellCore -UsePackageManagement 'Yes' -DownloadDirectory "$HOME\Downloads" }
function ListFoldersByDate { dir | Sort-Object -Property LastWriteTime }
function ChocoUpdate { & choco update all }
function ChocoList { & choco list --local-only }
@instance-id
instance-id / clone.ps1
Created March 16, 2021 03:56
A Linux PowerShell script to clone a GitHub repo and then go to that directory. Because I wanted to, that's why.
#!/usr/bin/env pwsh
# -- Either make sure clone.ps1 is on your path,
# -- or use the full path in the alias
# -- You can then setup the following Alias
# -- alias clone='f() { cd $(clone.ps1 $1) };f'
# -- Usage: ~ » clone github.com/instance-id/desiredrepo
Param (
@instance-id
instance-id / powershell_snippets.ps1
Last active August 3, 2022 20:24
PowerShell Snippets I don't want to forget.
# -- String aggregation from an array of PSObject ---------------------------------
# -- Takes an Array: -------------------------------
$array = @("string1","string2","string3","string4","string5")
[Func[string, string, string]]$aggregator = { param ($first, $next) $first + "${next}, "; };
$output = [System.Linq.Enumerable]::Aggregate([string[]]$array, [string]::Empty, $aggregator);
# -- Produces a string: ----------------------------
Write-Host $output
# -- $_> string1, string2, string3, string4, string5
@instance-id
instance-id / firefoxdeveloperedition.desktop
Created February 26, 2021 22:06
Linux Firefox Developers Edition - Stacked taskbar icon (So that opened windows stack under the actual launcher icon when favorited)
# In /usr/share/applications/ create a file named 'firefoxdeveloperedition.desktop' and put the following in it (If you installed it somewhere other than /opt/firefox/firefox - change the line Exec=/opt/firefox/firefox to reflect this change)
[Desktop Entry]
Version=1.0
Name=Firefox Developer Edition
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=/opt/firefox/firefox
Terminal=false
@instance-id
instance-id / TextProcessor.cs
Created December 8, 2020 05:19
Threaded text processor
// -- Found : https://stackoverflow.com/a/32276788/5821692 ----
// -- User : displayName -------------------------------------
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Threading.Tasks;
namespace ConsoleApplication
{
@instance-id
instance-id / unitytool.ps1
Last active October 3, 2022 18:32
Launch unity project by name (automatically in correct editor version). Automatically fix Unity: "Failed to load layout window" issue. Create new project from CLI. Add packages / assets to project before launch
#!/usr/bin/env pwsh
<#
.NOTES
============================================================
Last Edit: 5/29/2021
Created by: instance.id (https://github.com/instance-id)
Platform: Windows/Linux
Filename: unitytool.ps1
PSVersion: Last tested with 7.2-preview5