This file contains 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
Show hidden characters
[ | |
{ "keys": ["tab"], "command": "unbound", "context": | |
[ | |
{ "key": "has_next_field", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["tab"], "command": "insert_best_completion", "args": {"default": "\t", "exact": true} }, | |
{ "keys": ["tab"], "command": "insert_best_completion", "args": {"default": "\t", "exact": false}, | |
"context": | |
[ |
This file contains 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
export const compose: (...funcs) => (value: any) => any = | |
(...funcs) => value => funcs.reduce((value, func) => value !== undefined ? func(value) : undefined, value); |
This file contains 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
<html> | |
<head> | |
<title>Client</title> | |
<script> | |
function openWindow() { | |
window.open('http://service/auth.html', '_blank', "toolbar=0,location=0,menubar=0,height=600,width=400"); | |
window.addEventListener('message', function(message) { | |
document.write('Authorized with token: ' + message.data.token); | |
}); | |
} |
This file contains 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
// [1, 3, 3, 1] => [[1, 3], [3, 3], [3, 1]] | |
const pairs = ([head, ...tail]) => tail.map((item, i) => i === 0 ? [head, item] : [tail[i - 1], item]); | |
// [1, 3, 3, 1] => [1, 4, 6, 4, 1] | |
const next = numbers => [1, ...pairs(numbers).reduce((carry, pair) => [...carry, pair[0] + pair[1]], []), 1]; | |
// 5 => <5 rows of pascal triangle> | |
const pascal = (n, carry = [[1]]) => n > 1 ? pascal(n - 1, [next(carry[0]), ...carry]) : carry.reverse(); |
This file contains 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 {BehaviorSubject, Observable} from 'rxjs'; | |
@Injectable() | |
export class LocalStorage implements ILocalStorage { | |
protected subjects: {[key: string]: BehaviorSubject<any>} = {}; | |
select(key: string, defaultValue: any = null): Observable<any> { | |
if (this.subjects.hasOwnProperty(key)) { |
This file contains 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 {Component, ViewEncapsulation, Directive, Input, ContentChild, Renderer2, ElementRef} from "@angular/core"; | |
@Directive({ | |
selector: "input,select,textarea" | |
}) | |
export class FormInputDirective { | |
} | |
@Directive({ |
This file contains 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 itertools | |
import random | |
import nltk | |
def shuffled(language, term): | |
# while part of speech tag is not a punctuation mark | |
while term[1] not in [".", ","]: | |
yield term[0] |
This file contains 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 xtry = (xtry, xcatch, xfinally) => { | |
try {return xtry()} catch (e) {return xcatch && xcatch()} finally {xfinally && xfinally()} | |
} | |
// undefined | |
xtry(() => {throw new Error}) | |
// default | |
xtry(() => {throw new Error}, () => "default") |
This file contains 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
from random import random | |
from scipy import mean | |
from math import log, pow | |
import matplotlib.pyplot as plt | |
def simulate_single(n): | |
sample = [random() - 0.5 for _ in range(n)] |
This file contains 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 express = require("express"); | |
const compression = require("compression"); | |
const url = require("url"); | |
const path = require("path"); | |
const PORT = 4200; | |
// resolve pathname whether it is a static file or rewrite it to index.html (default start page for all pages) | |
const getFilename = (req) => { | |
const pathname = url.parse(req.url).pathname; |
OlderNewer