Skip to content

Instantly share code, notes, and snippets.

View camusicjunkie's full-sized avatar
🎯
Focusing

John Steele camusicjunkie

🎯
Focusing
View GitHub Profile
@akimboyko
akimboyko / gist:4258647
Created December 11, 2012 13:41
PowerShell exception re-throwing sample
Write-Host 'throw'
try
{
try
{
throw "exception"
}
catch
{
@nohwnd
nohwnd / Uninstall-Pester.ps1
Last active July 5, 2024 03:59
Remove built-in version of Pester 3 (or -All) from Windows 10 Program Files and Program Files (x86).
#Requires -RunAsAdministrator
function Uninstall-Pester ([switch]$All) {
if ([IntPtr]::Size * 8 -ne 64) { throw "Run this script from 64bit PowerShell." }
#Requires -RunAsAdministrator
$pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)})) {
$path = "$programFiles\WindowsPowerShell\Modules\Pester"
if ($null -ne $programFiles -and (Test-Path $path)) {
if ($All) {
@JM1
JM1 / Ansible_Roles_with_OS-specific_Defaults.md
Last active October 9, 2024 08:03
Ansible Roles with OS-specific defaults

Ansible Roles with OS-specific Defaults

This Ansible guide discusses several approaches on how to set different role default variables based / depending on the host operating system aka ansible_distribution / ansible_facts.distribution or other variables. For example, a role variable image_uri should point to the latest cloud image for the host. For CentOS 8 or Red Hat Enterprise Linux (RHEL) 8 the default value should be:

@nicolonsky
nicolonsky / Invoke-BinarySearch.ps1
Created November 2, 2020 13:20
Binary Search Algorithm written in PowerShell
#Binary search algorithm with O(logn) complexity written in PowerShell
function Invoke-BinarySearch {
[CmdletBinding()]
[OutputType([int])]
param (
# Array which contains value to search, needs to be sorted
[Parameter(Mandatory)]
[int[]]
$Numbers,