This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Trie { | |
| constructor() { | |
| this.n = 0; | |
| this.children = {}; | |
| } | |
| add(s) { | |
| if (s === '') { | |
| this.n++; | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const timeToComputeConcurrently = ( | |
| costOfThreadSpawn = 0.001, | |
| costOfComputation = 0.5, | |
| nJobs = 8, | |
| cpuCount = 4 | |
| ) => { | |
| const timeToComputeNthJob = nth => | |
| (nth + 1) * costOfThreadSpawn + | |
| costOfComputation + | |
| (nth >= cpuCount ? timeToComputeNthJob(nth - cpuCount) : 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "swagger": "2.0", | |
| "info": { | |
| "title": "NLP", | |
| "description": "Natural Language Processing API.", | |
| "contact": { | |
| "name": "API Support", | |
| "url": "http://www.swagger.io/support", | |
| "email": "[email protected]" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as rxjs from 'rxjs'; | |
| import * as op from 'rxjs/operators'; | |
| function post(s) { | |
| return rxjs.of(s) | |
| .pipe(op.delay(500), | |
| op.tap(s => console.log('server received "' + s + '"')), | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| p { | |
| font-family: Alegreya, serif; | |
| box-sizing: border-box; | |
| } | |
| button, input[type=button] { | |
| padding: 5px 8px; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Standard Library | |
| from functools import lru_cache | |
| from math import sqrt | |
| from typing import List, Optional, Tuple | |
| KB: Tuple[Tuple, Tuple, Tuple, Tuple, Tuple] = ( | |
| (('`', '¬'), ('1', '!'), ("2", '"'), ('3', '£'), ('4', '$'), ('5', '%'), ('6', '^'), ('7', '&'), ('8', '*'), ('9', '('), ('0', ')'), ('-', '_'), ('=', '+')), | |
| (('\t',), ("",), ("q", 'Q'), ("w", 'W'), ("e", 'E'), ("r", 'R'), ("t", 'T'), ("y", 'Y'), ("u", 'U'), ("i", 'I'), ("o", 'O'), ("p", 'P'), ('[', '{'), (']', '}'), ('\n',)), | |
| (("",), ("",), ('a', 'A'), ('s', 'S'), ("d", 'D'), ("f", 'F'), ("g", 'G'), ("h", 'H'), ("j", 'J'), ("k", 'K'), ("l", 'L'), (';', ':'), ("'", '@'), ('#', '~')), | |
| (('',), ('\\', '|'), ("z", 'Z'), ("x", 'X'), ("c", 'C'), ("v", 'V'), ("b", 'B'), ("n", 'N'), ("m", 'M'), (',', '<'), ('.', '>'), ('/', '?')), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # ------------------------------------------------------------ | |
| # YOUR WORKSPACE | |
| # ------------------------------------------------------------ | |
| # GLOBAL VARIABLES (CANNOT BE DELETED) | |
| # ------------------------------------------------------------ | |
| # You are free to add / modify the values of these globals. | |
| # However, you cannot delete them as core functions depend on them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(duration_as_u128, extern_prelude)] | |
| #![warn(bad_style, rust_2018_idioms, nonstandard_style)] | |
| #![deny(future_incompatible)] | |
| use std::collections::VecDeque; | |
| fn measure_time(n: u128, f: fn(u128) -> ()) -> u128 { | |
| let start = std::time::SystemTime::now(); | |
| f(n); | |
| let end = std::time::SystemTime::now(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Optional; | |
| import java.util.function.Predicate; | |
| import java.util.logging.Logger; | |
| enum Heuristic {TRANSPOSE, MOVE_TO_FRONT} | |
| class Metadata<E> { | |
| SelfOrgList<E> hd, lst; | |
| Heuristic heuristic = Heuristic.MOVE_TO_FRONT; | |
| int len; |
NewerOlder