Skip to content

Instantly share code, notes, and snippets.

View MrAntix's full-sized avatar
🏠
Working from home

Anthony Johnston MrAntix

🏠
Working from home
View GitHub Profile
@MrAntix
MrAntix / entities.ts
Created February 9, 2018 16:16
Some base classes for immutable entities in type script
export module Guid {
export function newGuid(): string {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g,
c => {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
@MrAntix
MrAntix / Changes.cs
Created March 7, 2018 14:09
Apply changes to a list with a serializable list of add/updates and removes
public class Changes<T>
{
public Changes(
IEnumerable<T> toAddOrUpdate = null,
IEnumerable<T> toRemove = null)
{
ToAddOrUpdate = toAddOrUpdate?.ToImmutableArray() ?? ImmutableArray<T>.Empty;
ToRemove = toRemove?.ToImmutableArray() ?? ImmutableArray<T>.Empty;
}

Keybase proof

I hereby claim:

  • I am mrantix on github.
  • I am mrantix (https://keybase.io/mrantix) on keybase.
  • I have a public key ASBQIl4hmgX25PyYRe25edFEzqNmJOEuBwgnLDrXnvggago

To claim this, I am signing this object:

export const PROMISE_SINGLETON_REJECTION_REASON = 'rejected by successor';
/**
* Creates a context where by only the last called promise is resolved
* Previous ones would be rejected
*
* @example
*
* const context = createPromiseSingletonContext<string>();
* const someApiCall = (result: string) => new Promise<string>(resolve => {
@MrAntix
MrAntix / Booking-Sequence.md
Last active December 9, 2023 17:11
Booking Sequence
sequenceDiagram
    participant Customer
    participant Database
    participant Book_Handler as Book Handler
    participant Room
    participant Booked_Handler as Booked Handler
    participant Email_Service as Email Service

    Customer->>Database: Search available rooms
@MrAntix
MrAntix / provideSign.ts
Last active August 3, 2024 21:23
A signing provider function written in typesript
/**
* A reusable signing function using the token passed to a provider
*
* @param data data to sign
* @returns Base64 signature
*/
export type TokenSign = (data: string) => Promise<string>;
/*
* Constants for signing