Skip to content

Instantly share code, notes, and snippets.

/**
* 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;
@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
@sccolbert
sccolbert / initialization.cpp
Last active September 21, 2020 01:20
Initialization
#include <iostream>
class Foo {
public:
Foo() {
std::cout << this->getValue();
}
@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
interface ICommandRegistry {
commandAdded: ISignal<ICommandRegistry, string>;
commandRemoved: ISignal<ICommandRegistry, string>;
commandChanged: ISignal<ICommandRegistry, string>;
keyboardLayoutChanged: ISignal<ICommandRegistry, void>;
interface ISlot<T, U> {
(sender: T, args: U): void;
}
class Signal<T, U> {
connect(slot: ISlot<T, U>): void {
}
interface ISignal {
_ISignalStructuralProperty: void;
}
interface ISignal1<T1> {
_ISignal1StructuralPropertyT1: T1;
}
collections
-----------
phosphor-arrays
phosphor-queue
phosphor-sectionlist
core
----
phosphor-disposable
phosphor-messaging
Ss-MacBook-Pro:phosphorjs Chris$ mkdir foo
Ss-MacBook-Pro:phosphorjs Chris$ cd foo
Ss-MacBook-Pro:foo Chris$ git clone https://github.com/phosphorjs/phosphor-gridpanel.git
Cloning into 'phosphor-gridpanel'...
remote: Counting objects: 87, done.
remote: Compressing objects: 100% (58/58), done.
remote: Total 87 (delta 20), reused 87 (delta 20), pack-reused 0
Unpacking objects: 100% (87/87), done.
Checking connectivity... done.
Ss-MacBook-Pro:foo Chris$ cd phosphor-gridpanel/
Ss-MacBook-Pro:phosphorjs Chris$ mkdir foo
Ss-MacBook-Pro:phosphorjs Chris$ cd foo
Ss-MacBook-Pro:foo Chris$ npm install phosphor-gridpanel
|
> phosphor-widget@0.9.9 postinstall /Users/Chris/Development/phosphorjs/foo/node_modules/phosphor-gridpanel/node_modules/phosphor-widget
> npm dedupe
> phosphor-gridpanel@0.9.0 postinstall /Users/Chris/Development/phosphorjs/foo/node_modules/phosphor-gridpanel
> npm dedupe