Skip to content

Instantly share code, notes, and snippets.

interface ICommandRegistry {
commandAdded: ISignal<ICommandRegistry, string>;
commandRemoved: ISignal<ICommandRegistry, string>;
commandChanged: ISignal<ICommandRegistry, string>;
keyboardLayoutChanged: ISignal<ICommandRegistry, void>;
@sccolbert
sccolbert / uniqueid.js
Created September 20, 2020 20:29
Unique ID Generator
/**
* A function which takes no arguments and returns a unique string ID.
*
* Requirements:
* - The id must be unique for the current process only
* - The id should avoid hashing collisions when used as a key in a map
* - The function must not create global variables
* - The value of `Math.random()` cannot be assumed to be unique
* - The browser `Crypto` object may not be used
@sccolbert
sccolbert / initialization.cpp
Last active September 21, 2020 01:20
Initialization
#include <iostream>
class Foo {
public:
Foo() {
std::cout << this->getValue();
}
@sccolbert
sccolbert / typedmap.py
Last active February 9, 2021 14:33
Typed Map
class TypedMap:
""" A class which implements a typed map.
"""
def __init__(key_type, value_type):
pass
# Implement the methods required
# for the functionality demonstrated
/**
* A generator function which maps a function across an iterable of values.
*/
function map(fn, items) { // Add typings to the function definition
// Implement the body of the function
}
interface HasLength {
length: number;