This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module PSCache | |
# Define fetcher | |
$Fetcher = { | |
# Emulate a potentially slow operation | |
Start-Sleep -Milliseconds (Get-Random -Minimum 15 -Maximum 30) | |
# Return an object corresponding to $_ | |
[pscustomobject]@{ | |
ID = $_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://twitter.com/dfinke/status/1167559940598370304 | |
1..9|%{"{0,9} x 8 + $_ = $(8*($a=1..$_-join'')+$_)"-f$a} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
def expand_alphabet(alphabet, max_width): | |
for width in range(1, max_width+1): | |
for combo in product(alphabet, repeat=width): | |
print(''.join(combo)) | |
def main(): | |
expand_alphabet(['a', 'b', 'c'], 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Subscription xmlns="http://schemas.microsoft.com/2006/03/windows/events/subscription"> | |
<SubscriptionId>EventForwardingPluginIssues</SubscriptionId> | |
<SubscriptionType>SourceInitiated</SubscriptionType> | |
<Description>Operational events from the EventLog-ForwardingPlugin log on clients, used for troubleshooting</Description> | |
<Enabled>true</Enabled> | |
<Uri>http://schemas.microsoft.com/wbem/wsman/1/windows/EventLog</Uri> | |
<ConfigurationMode>MinLatency</ConfigurationMode> | |
<Query><![CDATA[ | |
<QueryList> | |
<Query Id="0" Path="Microsoft-Windows-Forwarding/Operational"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$function:prompt = { | |
return "PS $($executionContext.SessionState.Path.CurrentLocation -replace [regex]::Escape($HOME.Trim('\')),'~')$('>' * ($nestedPromptLevel + 1)) " | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BigIntRange : System.Collections.IEnumerable | |
{ | |
[bigint]$from | |
[bigint]$to | |
[bool]$Descending | |
BigIntRange([bigint]$from,[bigint]$to) | |
{ | |
$this.from = $from |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import windll,c_ushort,byref | |
import platform | |
def is_syswow64_process(): | |
if platform.architecture()[0] != "64bit": | |
# 32-bit OS, no syswow64 handling | |
return False | |
# Ok, 64-bit OS, let's see if the process is 32-bit | |
# Obtain process handle to self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Write-SwiftEvent | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true, Position=0)] | |
[Alias('ID','EID')] | |
[ValidateNotNullOrEmpty()] | |
[ValidateRange(0, 65535)] | |
[int] | |
${EventId}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Compare-Array | |
{ | |
param( | |
[array]$Ref, | |
[array]$Diff | |
) | |
$max = [math]::Max($Ref.Length,$Diff.Length) | |
for($i = 0; $i -lt $max; $i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Compare-Array | |
{ | |
param( | |
[array]$Ref, | |
[array]$Diff | |
) | |
$max = [math]::Max($Ref.Length,$Diff.Length) | |
for($i = 0; $i -lt $max; $i++){ |