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
// Modify your settings.json to add these. Customize further how you prefer. | |
{ | |
"workbench.editor.highlightModifiedTabs": true, | |
"workbench.editor.tabCloseButton": "off", | |
"workbench.colorCustomizations": { | |
"editor.lineHighlightBackground": "#ffffff06", | |
"editor.foreground": "#acb3db", | |
"selection.background": "#89DDFF", | |
"progressBar.background": "#89DDFF", | |
"textLink.foreground": "#89DDFF", |
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
SCRIPT="security add-trusted-cert -d -r trustAsRoot -p ssl -p basic -k /Library/Keychains/System.keychain "filename.crt"" | |
osascript -e "do shell script \"$SCRIPT\" with administrator privileges" | |
# or you can just run the above SCRIPT command with sudo directly. | |
# This osascript stuff is so that you get a native OS password prompt |
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
// The spec might seem somewhat convoluted but it's because you can actually | |
// use reduce on anything array-like not just arrays. | |
// e.g. Array.prototype.reduce.call('abc', (acc, char) => char + acc); // "cba" | |
function reduce(callback, initialValue) { | |
// In "strict mode" calling this with either null or undefined will make | |
// this === null in either case, as per spec. | |
if (this === null) { | |
throw new TypeError('reduce called on null or undefined'); | |
} |
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
// noprotect | |
console.clear(); | |
const second = 1; | |
const minute = second * 60; | |
const hour = minute * 60; | |
const day = hour * 24; | |
const year = day * 365; | |
const unitValues = [{ |
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 { map, delay } from 'rxjs/operators'; | |
import { TestScheduler } from 'rxjs/testing'; | |
import { Action } from 'redux'; | |
import { Epic, ofType, ActionsObservable, StateObservable } from 'redux-observable'; | |
const scheduler = new TestScheduler((actual, expected) => { | |
if (JSON.stringify(actual) !== JSON.stringify(expected)) { | |
throw new Error(`Failing test | |
actual: ${JSON.stringify(actual, null, 2)} |
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 v8 = require('v8'); | |
const fs = require('fs'); | |
function writeDemo() { | |
const module = new WebAssembly.Module(new Uint8Array([ | |
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00 | |
])); | |
const buffer = v8.serialize(module); | |
fs.writeFileSync('cached-wasm-module.buffer', buffer); | |
} |
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
// WARNING: Completely untested code. it might not work and/or it might have | |
// things that don't work well. Just made for illustrational purposes | |
// redux-observable shines the most with complex async stuff, like WebSockets | |
// but many of us will still use it for more modest things like AJAX requests. | |
// In these cases, there can be a ton of repetitive boilerplate. So this is a | |
// simple example of applying some abstractions and conventions to make it easier. | |
// THAT SAID, since abstractions cause indirection it can make it harder for | |
// someone to come along later and know how something works. Weigh the costs | |
// and remember, this example isn't a suggestion of the actual code you should |
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
function dispatchSwallowedError(e) { | |
window.dispatchEvent(new ErrorEvent('error', { | |
error: e, | |
message: e.message | |
})); | |
console.error(e); | |
} |
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
{ | |
"scripts": { | |
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min", | |
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015", | |
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm", | |
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs", | |
"build:umd": "rollup dist/esm/index.js --format umd --name YourLibrary --sourceMap --output dist/umd/yourlibrary.js", | |
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o yourlibrary.min.js -- yourlibrary.js && gzip yourlibrary.min.js -c > yourlibrary.min.js.gz", | |
} | |
} |
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
let buffer = getWebSocket() | |
.bufferTime(1000); | |
let gate = new BehaviorSubject(true); | |
let batchSize = 50; | |
let batchSizeCounter = 0; | |
let results = gate | |
.switchMap(enabled => enabled ? buffer : Observable.never()) | |
.do(buffer => { |
NewerOlder