Skip to content

Instantly share code, notes, and snippets.

View oising's full-sized avatar
🐢
Taking it easy

Oisin Grehan oising

🐢
Taking it easy
View GitHub Profile
@oising
oising / base_test.ps1
Created August 25, 2023 19:33 — forked from Luiz-Monad/base_test.ps1
how-to-normalize-a-path-in-powershell
# Clear-Host
Import-Module Pester
# New-Item -ItemType Directory 'a/b' -Force -ErrorAction Ignore
# New-Item -ItemType Directory 'c' -Force -ErrorAction Ignore
# New-SmbShare -Name "Shared" -Path "./shared" -FullAccess "Everyone"
$ErrorActionPreference = 'Stop'
$PesterPreference = [PesterConfiguration]::Default
$PesterPreference.Output.StackTraceVerbosity = 'None'
@oising
oising / wpf.ps1
Created January 21, 2022 16:57
Demonstrate using a nested dispatcher frame to avoid blocking powershell thread (wpf)
# demonstrate using a nested dispatcher frame to avoid blocking powershell thread
# this way you can have full "floating" windows manageable interactively in MTA mode (default) powershell
# Oisin/x0n - feb 9, 2009
Set-StrictMode -Version latest
$ps = [powershell]::create()
$rs = [runspacefactory]::createrunspace()
$rs.ApartmentState = "STA"
@oising
oising / TaskJob.cs
Created June 1, 2021 22:59 — forked from Stroniax/TaskJob.cs
A PowerShell Job wrapper for System.Threading.Tasks.Task to bridge the gap between asynchronous operations in C# and PowerShell.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading;
using System.Threading.Tasks;
namespace Casion.PowerShell
{
/// <summary>
@oising
oising / start-vsdevshell.ps1
Created September 13, 2019 21:23
Allow "Developer Powershell for VS 2019" environment to be bootstrapped within powershell core / pwsh
[cmdletbinding()]
param([switch]$Preview)
# vswhere will reliably locate visual studio installations
if (!(gcm vswhere)) {
# https://chocolatey.org/
if (gcm choco) {
choco install vswhere -y
}
else {
Verifying that +oising is my blockchain ID. https://onename.com/oising
@oising
oising / CodeBlockWithTimeout.cs
Created September 6, 2012 23:16
Sample cancellation of ThreadAbortException with Thread.ResetAbort
internal class CodeBlockWithTimeout<TResult>
{
private readonly Func<TResult> _block;
private readonly string _name;
private CodeBlockWithTimeout(Func<TResult> block, string name)
{
this._block = block;
_name = name;