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
param( [ScriptBlock] $scriptBlock ) | |
<# | |
.SYNOPSIS | |
Impersonates a user and executes a script block as that user. This is an interactive script | |
and a window will open in order to securely capture credentials. | |
.EXAMPLE | |
Use-Impersonation.ps1 {Get-ChildItem 'C:\' | Foreach { Write-Host $_.Name }} | |
This writes the contents of 'C:\' impersonating the user that is entered. | |
#> | |
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 Enable-FusionLog { | |
param($logPath = "C:\Temp\Fusion") | |
if(!(Test-Path $logPath)) { | |
New-Item -ItemType Directory -Path $logPath | |
} | |
$fusionRoot = "HKLM:Software\Microsoft\Fusion" | |
function Set-FusionKey($name, $value, $type) { | |
if(!(Test-Path (Join-Path $fusionRoot $name))) { | |
(New-ItemProperty $fusionRoot -name $name -propertyType $type -ErrorAction Stop) | Out-Null |
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
namespace MatrixMultiplication | |
{ | |
public static class Jagged | |
{ | |
public static double[][] Multiply( int N ) | |
{ | |
var C = new double[N][]; | |
var A = new double[N][]; | |
var B = new double[N][]; | |
Util.Initialize( N, A, B, C ); |
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 =~ { | |
param([regex]$regex, [switch]$debug, [switch]$caseSensitive) | |
process { | |
$matches = $null | |
$mached = $false | |
if($caseSensitive) { | |
$matched = $_ -cmatch $regex | |
} else { | |
$matched = $_ -match $regex | |
} |
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
idavis$ brew link openssl --force | |
Warning: Refusing to link: openssl | |
Linking keg-only OpenSSL means you may end up linking against the insecure, | |
deprecated system version while using the headers from the Homebrew version. | |
Instead, pass the full include/library paths to your compiler e.g.: | |
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib | |
============================================================================= | |
============================================================================= |
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
# APL Rank | |
filter ⍴⍴ { | |
param( | |
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$false)] $ω | |
) | |
process { | |
if($ω -is [system.array]){ | |
$ω.rank | |
} else{ | |
"⍬" |
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
public class Foo { | |
public void Bar() { | |
if(IsBaz()) { | |
Console.WriteLine("CRAP"); | |
} else { | |
Console.WriteLine("W00T"); | |
} | |
} | |
public bool IsBaz() { |
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
$foo = @{ | |
Message = "This is a pre-recorded message" | |
} | |
$foo.say = { | |
param([string]$message) | |
$speaker = new-object -com SAPI.SpVoice | |
($speaker.Speak($message, 1)) | out-null | |
} |
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
> git clone git@github.com:idavis/fubumvc.git | |
Cloning into 'fubumvc'... | |
remote: Counting objects: 57191, done. | |
remote: Compressing objects: 100% (11208/11208), done. | |
remote: Total 57191 (delta 45719), reused 56278 (delta 44979) | |
Receiving objects: 100% (57191/57191), 61.02 MiB | 327 KiB/s, done. | |
Resolving deltas: 100% (45719/45719), done. | |
> cd .\fubumvc | |
[master]> ls |
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
filter Fizz-Buzz { | |
process { | |
$output = switch($_) { | |
{$_ % 3 -eq 0} {"Fizz"} | |
{$_ % 5 -eq 0} {"Buzz"} | |
default {$_} | |
} | |
$output -join "" | |
} | |
} |
NewerOlder