Skip to content

Instantly share code, notes, and snippets.

Seth Silesky silesky

Block or report user

Report or block silesky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:fe9e63236a69cd1fc928eddc4216d590

Experiment in the Typescript Playground.

This extends these (somewhat obvious) rules. All projects should contain the following properties in their tsconfig.json: // tsconfig.json {    "strict": true,   "forceConsitentCasingInFileNames": true,

@silesky
silesky / GoogleMap.js
Last active Jan 12, 2018
React custom Google Maps component
View GoogleMap.js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { iconYouAreHere, iconPin } from 'icons';
import styles from './styles.css';
const loadScript = src => {
const ref = global.document.getElementsByTagName('script')[0];
const script = global.document.createElement('script');
script.src = src;
View multipleFilters.js
/**
* Use multiple filters on an array of object
* @param {Object[]} arr - the array to filter
* example:
* [
* {fruit: 'apple', count: 1, id: 123},
* {fruit: 'pear', count: 4, id: 234},
* {fruit: 'orange', count: 4, id: 456}
* ]
* @param {Object.<Array>} filters - an object with the filter criteria as the property names
@silesky
silesky / blog_fake_asyncify.js
Last active Oct 10, 2017
blog_fake_asyncify
View blog_fake_asyncify.js
const timer = asyncify(() => {
promiseTimeout(1000) // pseudo-code
promiseTimeout(2000)
promiseTimeout(3000)
})
@silesky
silesky / blog_async_setT2.js
Last active Oct 27, 2017
blog_async_setT2
View blog_async_setT2.js
setTimeout(() => console.log('hi'), 1000)
setTimeout(() => console.log('hi'), 2000)
setTimeout(() => console.log('hi'), 3000)
@silesky
silesky / blog_async_promisetimeout.js
Last active Oct 10, 2017
blog_async_promisetimeout
View blog_async_promisetimeout.js
const timer = asyncify(function* () {
yield promiseTimeout(1000)
yield promiseTimeout(2000)
yield promiseTimeout(3000)
})
@silesky
silesky / blog_async_final.js
Last active Oct 10, 2017
blog_async_final
View blog_async_final.js
const timer = async() => {
await promiseTimeout(1000)
await promiseTimeout(2000)
await promiseTimeout(3000)
}
View blog_fetch.js
const data = fetch(‘http://foo.com/api/') // gets skipped
console.log(data) //... [[PromiseValue]]: undefined}
View blog_settimeout.js
let x;
const reassignX = () => x = 5;
setTimeout(reassignX, 1000); // no waiting, this gets 'skipped'
console.log(x) // undefined! -- gets run before ^ is done.
@silesky
silesky / blog_generator.js
Last active Oct 10, 2017
blog_generator.js
View blog_generator.js
function* gen() { // new * syntax for declaring generator functions.
yield 1 // yield says 'output the value and stop'.
yield 2
}
// we use our generator to create an 'iterator': an object with a .next method.
const myIterator = gen()
// every time .next gets called, it returns an object that looks like: {value: ..., done: ...}
myIterator.next() //=> {value: 1, done: false}
myIterator.next() //=> {value: 2, done: false}
You can’t perform that action at this time.