Skip to content

Instantly share code, notes, and snippets.

View guhou's full-sized avatar

Gus guhou

View GitHub Profile
View Cache`1.cs
using System;
using System.Collections.Generic;
public class Cache<K, V> where V : class
private readonly Dictionary<K, WeakReference<V>> _data;
public Cache()
_data = new Dictionary<K, WeakReference<V>>();
guhou /
Last active September 3, 2015 06:16 — forked from anonymous/
A brain-dump/introduction to Lists in C#

An introduction to generic Lists in C#

In this article I present an introduction to generic List types in the C# language. I assume an audience familiar with the principles of structured programming, including parameters, arrays and procedures, but with little experience with object-oriented programming. I will motivate an example for an encapsulated collection class, and then introduce generics as a means to improve our collection.

View gist:c43abfbd9780059615384bb617224591
### Keybase proof
I hereby claim:
* I am guhou on github.
* I am guhou ( on keybase.
* I have a public key ASAZNEe0DRKu9xFDlHFgr6TGZPyE9zmMdBt86gMWZixpUQo
To claim this, I am signing this object:
guhou / sequence.ts
Created March 6, 2020 06:12
What is the name of this `unSequence` function?
View sequence.ts
export function sequence<T>(
map: Map<string, Promise<T>>
): Promise<Map<string, T>> {
return Promise.all(
Array.from(map, ([key, promisedValue]) =>
promisedValue.then<[string, T]>(value => [key, value])
).then((entries) => new Map(entries));