2015-10-21
- jennifer
 - martym
 
| const config: CodegenConfig = { | |
| // @ts-ignore TypeScript describes this as a string, but it also supports a | |
| // function. | |
| schema: { | |
| [CONTENTFUL_URI]: { | |
| customFetch: initCustomFetch({ | |
| accessToken: CONTENTFUL_MANAGEMENT_ACCESS_TOKEN, | |
| spaceId: CONTENTFUL_SPACE_ID, | |
| environmentId: CONTENTFUL_ENVIRONMENT, | |
| }), | 
| <rmp-mock-video-controller> | |
| <rmp-muted-toggle ?muted=${boolean('muted', true)}> | |
| <rmp-mute-button id="story.mute" slot="mute-button"> | |
| <icon-mute fill></icon-mute> | |
| </rmp-mute-button> | |
| <rmp-unmute-button id="story.unmute" slot="unmute-button"> | |
| <icon-volume fill></icon-volume> | |
| </rmp-unmute-button> | |
| </rmp-muted-toggle> | |
| </rmp-mock-video-controller> | 
| export type Callback<T> = (value: T) => void; | |
| export type Unsubscribe = () => void; | |
| export default class Callbacks<T> { | |
| private callbacks = new Set<Callback<T>>(); | |
| subscribe(callback: Callback<T>): Unsubscribe { | |
| this.callbacks.add(callback); | |
| return () => this.unsubscribe(callback); | |
| } | 
| <html> | |
| <head> | |
| <title>sleep.js</title> | |
| </head> | |
| <body> | |
| <h1>sleep.js</h1> | |
| <script src="sleep.js"></script> | 
| type Timestamp = number; | |
| type Callback = (error: Error | null, timestamp: Timestamp) => void; | |
| /** | |
| * The default number of milliseconds beyond the expected time of execution to | |
| * wait before assuming failure. | |
| */ | |
| const THRESHOLD = 10000; | |
| /** | 
| const Events = new Map(); | |
| function startEvent() { | |
| return { | |
| start: Date.now(), | |
| end: null, | |
| }; | |
| } | |
| function endEvent(event) { | 
| // Found at https://www.glassdoor.com/Interview/Reddit-Senior-Software-Engineer-Interview-Questions-EI_IE796358.0,6_KO7,31.htm | |
| // # a list of strings.Each string is a management / report relationship. | |
| // # | |
| // # EXAMPLE INPUT: | |
| // # | |
| // #[ | |
| // # 'B,E,F', | |
| // # 'A,B,C,D', | |
| // # 'D,G,I', | 
| function reduceRot13Cipher(map, c, i, abc) { | |
| const off = 13; | |
| const len = abc.length; | |
| const j = (i + off) % len; | |
| map[c] = abc[j]; | |
| return map; | |
| } | |
| const rot13 = (() => { | |
| const abc = 'abcdefghijklmnopqrstuvwxyz'; | 
| function buildList(values) { | |
| return values.reduceRight((next, value) => ({ value, next }), null); | |
| } | |
| function getValues(node) { | |
| const values = []; | |
| while (node) { | |
| values.push(node.value); | |
| node = node.next; | |
| } |