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
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; |
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; | |
public static class ArrayEnumerableExtensions | |
{ | |
public static IEnumerable<T> AsEnumerable<T>(this Array array) | |
{ | |
if (array is null) | |
throw new ArgumentNullException(nameof(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
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T]; | |
export function getPropertyNames<T>(defaultInstance: T): NonFunctionPropertyNames<T>[] { | |
const memberNames = Object.getOwnPropertyNames(defaultInstance); // get all members of the instance | |
const propertyNames = memberNames.filter(x => typeof (defaultInstance as any)[x] != "function"); // filter out functions | |
return propertyNames as NonFunctionPropertyNames<T>[]; // cast as array of string union of non-function properties (ideally would be a string typed tuple but can't be done yet) | |
} | |
export function createFromObject<T>(constructor: { new(): T }, parameters: Partial<T>): T { | |
const newInstance = new constructor(); |
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 { Subscription } from "rxjs"; | |
export class Subscriptions { | |
private readonly subscriptions = new Array<Subscription>(); | |
push(subscription: Subscription): void { | |
this.subscriptions.push(subscription); | |
} | |
unsubscribeAll(): void { |
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 { HostBinding, OnDestroy, OnInit } from '@angular/core'; | |
import { MediaObserver } from '@angular/flex-layout'; | |
import { Subscription } from 'rxjs'; | |
/** | |
* If you inherit (extend) your component from this class, the host element of your component will have a class added to it with the media query alias. | |
* For example... | |
* | |
* <app-search-bar class="some-class" _nghost-c5 ...> | |
* |
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 { strict as assert } from 'assert'; | |
/** | |
* This class supports retrieving a class type name at run-time. It requires TypeScript decorators. | |
* Usage: Register the typename with `@TypeName.decorate(...)` | |
* | |
* @TypeName.decorate("Foo") | |
* class Foo { | |
* readonly text: string = "text"; | |
* } |
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
export class QueryablePromise<T> implements Promise<T> { | |
private readonly promise: Promise<T>; | |
private _isPending: boolean = true; | |
private _isRejected: boolean = false; | |
private _isFulfilled: boolean = false; | |
public get isPending(): boolean { return this._isPending; }; | |
public get isRejected(): boolean { return this._isRejected; }; | |
public get isFulfilled(): boolean { return this._isFulfilled; }; |
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 { Component, OnInit, OnDestroy, Inject, Renderer2 } from '@angular/core'; | |
import { Subscription } from 'rxjs'; | |
import { MediaObserver } from '@angular/flex-layout'; | |
import { DOCUMENT } from '@angular/common'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'] | |
}) |