Skip to content

Instantly share code, notes, and snippets.

View teppeis's full-sized avatar

Teppei Sato teppeis

View GitHub Profile
// taze: Set from //third_party/javascript/node_modules/typescript:es2015.collection
import * as fs from 'fs'; // from //third_party/javascript/typings/node
import * as ts from 'typescript';
function load(fileName: string, names: Set<string>) {
const text = fs.readFileSync(fileName, 'utf8');
const sf = ts.createSourceFile(fileName, text, ts.ScriptTarget.ES5, true);
sf.forEachChild((node) => {
switch (node.kind) {
@teppeis
teppeis / README.md
Created March 15, 2018 03:41 — forked from prog893/README.md
ECS Container Instance scale-in protector
@teppeis
teppeis / coverage.js
Created February 27, 2018 00:02 — forked from ebidel/coverage.js
CSS/JS code coverage during lifecycle of page load
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*
* Shows how to use Puppeeteer's code coverage API to measure CSS/JS coverage across
* different points of time during loading. Great for determining if a lazy loading strategy
* is paying off or working correctly.
*
* Install:
* npm i puppeteer chalk cli-table
@teppeis
teppeis / closure.d.ts
Created November 13, 2017 15:57 — forked from orian/closure.d.ts
A Google Closure Library DefinitelyTyped typings
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_eventsource.js
//!! Processing provides [goog.labs.userAgent.engine] from input closure-library/closure/goog/labs/useragent/engine.js
//!! Processing provides [goog.html.TrustedResourceUrl] from input closure-library/closure/goog/html/trustedresourceurl.js
//!! Processing provides [goog.events.EventId] from input closure-library/closure/goog/events/eventid.js
//!! Processing provides [goog.html.SafeUrl] from input closure-library/closure/goog/html/safeurl.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/intl.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_pointerlock.js
//!! Processing provides [goog.dom.vendor] from input closure-library/closure/goog/dom/vendor.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/w3c_vibration.js
//!! Processing provides [] from input tools/closure-compiler/externs/browser/webkit_notifications.js
@teppeis
teppeis / safari-nomodule.js
Last active September 18, 2017 05:04 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.:
* <script nomodule>alert('no modules');</script>.
*
* This workaround is possible because Safari supports the non-standard 'beforeload' event.
* This allows us to trap the module and nomodule load.
var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}