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.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Text.RegularExpressions; | |
public static class AutoPropertyExtensions { | |
const String Prefix = "<"; | |
const String Suffix = ">k__BackingField"; | |
private static String GetBackingFieldName(String propertyName) => $"{Prefix}{propertyName}{Suffix}"; |
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
#pragma once | |
#if defined(_WIN32) | |
# include <Windows.h> | |
#elif defined(__APPLE__) || defined(LINUX) | |
# include <sys/mman.h> | |
#endif | |
#include <optional> | |
#include "result.hpp" |
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.Generic; | |
using System.Diagnostics; | |
using System.Diagnostics.CodeAnalysis; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
public static class InterfaceImplementor |
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.Threading; | |
static class AsyncProgram | |
{ | |
private static readonly CancellationTokenSource cts = new CancellationTokenSource(); | |
public static CancellationToken CancellationToken => cts.Token; | |
static AsyncProgram() | |
{ |
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) { |
NewerOlder