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
Set-StrictMode -Version Latest | |
function Test-Property([Parameter(ValueFromPipeline)] $object, [string] $name) { | |
try { $name -cin $object.PSObject.Properties.Name } | |
catch { $false } | |
} | |
$path = '/Users/someone/temp/file.json' | |
$json = $path | Get-Content -Raw | ConvertFrom-Json | |
[bool] $exists = $json.someKey | Test-Property -name 'someOtherKey' |
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
# This code actually doesn't work. | |
$secret = 'B=EBh3glTf523Xj@uLGO]o@kSteLoC@O' | |
$group = 'INTRANETAI-Europe-DEV' | |
$service = 'intranetai-europe-test-dev' | |
$context = New-AzApiManagementContext -ResourceGroupName $group -ServiceName $service | |
$versionSet = New-AzApiManagementApiVersionSet -Context $context -Name 'news' ` | |
-Scheme Header -HeaderName 'x-api-version' ` |
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
# 'hello-wonderful-world' | ConvertTo-PascalCase | |
# outcome: HelloWonderfulWorld | |
function ConvertTo-PascalCase([Parameter(ValueFromPipeline)] [string] $text) { | |
($text -split '-' | ForEach-Object { | |
"$($_.ToCharArray()[0].ToString().ToUpper())$($_.Substring(1))" }) -join '' | |
} |
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
trigger: | |
- none | |
pool: | |
vmImage: 'windows-latest' | |
steps: | |
- powershell: | | |
$value = Select-String -Path 'azure-pipelines.yml' -Pattern "(?<=vmImage:\s').*(?='$)" | |
if ($value -like '*windows*') { |
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
using System; | |
using System.Collections.Immutable; | |
using System.Linq; | |
using ExpressionEngine; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var context = new Context(); |
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 yieldNumbers() : IterableIterator<number> { | |
return generator() | |
function *generator(): IterableIterator<number> { | |
yield 0 | |
yield 1 | |
yield 2 | |
yield 3 | |
} | |
} |
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
// $ tsc factorial.ts && node factorial.js | |
// 3628800 | |
function factorial(num: number) : number { | |
if (num == 0) return 1 | |
else return num * factorial(num - 1) | |
} | |
console.log(factorial(10)) |
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
#!/bin/sh | |
sudo rm -rf /private/var/log/asl/*.asl |
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
using System; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
static class Guard | |
{ | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void AgainstNull(string argumentName, object value) | |
{ | |
if (value == null) throw new ArgumentNullException(argumentName, $"{argumentName} cannot be 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
using System; | |
using System.Runtime.CompilerServices; | |
static class EventHelper | |
{ | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void RaiseEvent(object sender, EventHandler handler, EventArgs args, bool enabled) | |
{ | |
if (enabled && handler != null) { | |
handler(sender, args); |