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 class Extensions | |
{ | |
public static ExpandoObject WithAutoCorrect(this ExpandoObject eo) | |
{ | |
(eo as INotifyPropertyChanged).PropertyChanged += Handler; | |
return eo; | |
static void Handler(object sender, PropertyChangedEventArgs e) | |
{ | |
var dict = (IDictionary<String, Object>)sender; |
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.Concurrent; | |
using System.Collections.Generic; | |
using System.Diagnostics.CodeAnalysis; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
public static class DictionaryObjectExtensions | |
{ |
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.Diagnostics; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
namespace StrupHash | |
{ | |
class Program | |
{ | |
static unsafe void Main(string[] args) |
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 MapWrapper implements Map<string, any> { | |
constructor(readonly object: any) {} | |
clear(): void { | |
for (let key of this.keys()) | |
delete this.object[key]; | |
} | |
delete(key: string): boolean { | |
if (!this.has(key)) | |
return false; |
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 { sign } from "tweetnacl" | |
import { decodeUTF8 } from "tweetnacl-util"; | |
export class Crypto { | |
private constructor() {} | |
static generateKeys(): CryptoKeyPair { | |
const naclKeyPair = sign.keyPair(); | |
return new CryptoKeyPair(naclKeyPair.publicKey, naclKeyPair.secretKey); | |
} |
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 * getAllKeyValuePairs(o: any, key: string): IterableIterator<[string, string]> { | |
if (o instanceof Map) { | |
for (let element of o.entries()) | |
yield * getAllKeyValuePairs(element[1], `${key}.get("${element[0]}")`); | |
} | |
else if (o instanceof Date) { | |
for (let languageCode of ['en', 'fr']) | |
yield * getAllKeyValuePairs(o.toLocaleString(languageCode), `${key}.toLocaleString("${languageCode}")`); | |
} | |
else if (o instanceof Array) { |
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 class Extensions | |
{ | |
public static Rune[] ToArray(this SpanUtf8BytesRuneEnumerator enumerator) | |
{ | |
Span<Rune> runes = stackalloc Rune[enumerator.remaining.Length]; | |
var i = 0; | |
foreach (var utf8BytesRune in enumerator) | |
runes[i++] = utf8BytesRune; | |
var result = new Rune[i]; | |
runes.Slice(0, i).CopyTo(result); |
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; | |
using System.Threading; | |
/// <summary> | |
/// Provides a way to cancel awaited tasks when the user presses Ctrl+C. | |
/// </summary> | |
public static class ProgramCancellation | |
{ | |
private static readonly CancellationTokenSource Cts = new(); |
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
sudo apt install -y libicu63, libssl1.1 | |
curl -o dotnet3pre7 https://download.visualstudio.microsoft.com/download/pr/11d6ec80-4d7f-4100-8a54-809ed30b203e/1c0267225b22437aca9fdfe04160d1d5/dotnet-sdk-3.0.100-preview7-012821-linux-arm.tar.gz | |
mkdir -p /opt/dotnet && tar zxf dotnet3pre7 -C /opt/dotnet | |
if ! grep -q 'export DOTNET_ROOT=/opt/dotnet' ~/.bash_profile; then echo "export DOTNET_ROOT=/opt/dotnet" >> ~/.bash_profile; fi | |
sudo ln -s /opt/dotnet/dotnet /usr/bin/dotnet |
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
<#@ template debug="false" hostspecific="false" language="C#" #> | |
<#@ assembly name="System.Core" #> | |
<#@ import namespace="System.Linq" #> | |
<#@ import namespace="System.Text" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ output extension=".cs" #> | |
<# var maxDimensions = 32; #> | |
using System; | |
using System.Collections.Generic; |