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 static string HexDump(byte[] bytes) | |
{ | |
using (var s = new MemoryStream(bytes)) | |
return HexDump(s); | |
} | |
public static string HexDump(Stream s) | |
{ | |
var result = new StringBuilder(); | |
var buf = new byte[16]; |
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
<Query Kind="Program" /> | |
void Main() | |
{ | |
Console.WriteLine("## firstAction + secondAction ##"); | |
Action<string> firstAction = x => Console.WriteLine($"firstAction({x})"); | |
Action<string> secondAction = x => Console.WriteLine($"secondAction({x})"); | |
(firstAction + secondAction)("derp"); | |
Console.WriteLine(); |
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
<Query Kind="Program"> | |
<Namespace>System.Threading.Tasks</Namespace> | |
</Query> | |
async Task Main() | |
{ | |
_lastLog = DateTime.Now; | |
using (var defaultWatcher = new FileSystemWatcher()) | |
{ | |
defaultWatcher.Dump("default FileSystemWatcher"); |
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
<Query Kind="Statements" /> | |
ThreadPool.GetAvailableThreads(out int availableWorkerThreads, out int availableCompletionPortThreads); | |
ThreadPool.GetMaxThreads(out int maxWorkerThreads, out int maxCompletionPortThreads); | |
new[] { | |
new { Name = "Available", WorkerThreads = availableWorkerThreads, CompletionPortThreads = availableCompletionPortThreads }, | |
new { Name = "Max", WorkerThreads = maxWorkerThreads, CompletionPortThreads = maxCompletionPortThreads }, | |
}.Dump(); |
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
<Query Kind="Statements"> | |
<Reference><RuntimeDirectory>\System.Security.dll</Reference> | |
<Namespace>System.Security.Cryptography</Namespace> | |
</Query> | |
var scope = DataProtectionScope.CurrentUser; | |
var data = Encoding.UTF8.GetBytes("hello, world (privately)"); | |
var encrypted = ProtectedData.Protect(data, null, scope); |
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 d(str) { | |
console.log(hexdump(decode(str))); | |
} | |
function decode(base64) { | |
base64 = base64 || ''; | |
return atob(base64.replace(/_/g, '/').replace(/-/g, '+')); | |
} | |
function hexdump(buffer, blockSize) { |
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 Get-WebFile { | |
param( | |
[Parameter(Mandatory=$true)] | |
$Uri, | |
[string] $OutFile, | |
[string] $Hash, | |
[string] $HashAlgorithm = 'SHA256' | |
) | |
if (-not $OutFile) { |
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
<Query Kind="Program"> | |
<Reference><RuntimeDirectory>\Microsoft.JScript.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Configuration.Install.dll</Reference> | |
<Reference><RuntimeDirectory>\System.Management.dll</Reference> | |
<NuGetReference>Newtonsoft.Json</NuGetReference> | |
<Namespace>Newtonsoft.Json</Namespace> | |
<Namespace>System.Management</Namespace> | |
</Query> | |
void Main() |
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
<Query Kind="Program" /> | |
delegate void SomeDelegate(); | |
static SomeDelegate emptyHandler = delegate {}; | |
event SomeDelegate DefaultSubscriber = () => Console.WriteLine("DefaultSubscriber was called"); | |
event SomeDelegate SubscriberAddedThenRemoved = emptyHandler; | |
event SomeDelegate DefaultSubscriberWithSubscriberAddedthenRemoved = () => Console.WriteLine("DefaultSubscriberWithSubscriberAddedthenRemoved was called"); | |
event SomeDelegate EmptySubscriber = delegate { }; |
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
<Query Kind="Program"> | |
<NuGetReference>WindowsAzure.ServiceBus</NuGetReference> | |
<Namespace>Microsoft.ServiceBus</Namespace> | |
<Namespace>System.Threading.Tasks</Namespace> | |
<Namespace>Microsoft.ServiceBus.Messaging</Namespace> | |
<Namespace>System.Runtime.Serialization</Namespace> | |
</Query> | |
async Task Main() | |
{ |