Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');
tell application "Google Chrome" | |
set tab_list to every tab in the front window | |
repeat with the_tab in tab_list | |
set the_url to the URL of the_tab | |
tell application "Safari" to open location the_url | |
end repeat | |
end tell |
Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');
function mapValues(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
result[key] = fn(obj[key], key); | |
return result; | |
}, {}); | |
} | |
function pick(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
if (fn(obj[key])) { |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
function makeRequest(url) { | |
fetch(url) | |
.then(response => response.json()) | |
.then(json => it.next(json)) | |
.catch(error => console.error('Somthing shit the bed', error)); | |
} | |
function *syncRequests() { | |
const redditUrl = 'https://www.reddit.com/controversial.json?count=1&limit=2'; | |
const page1 = yield makeRequest(redditUrl); |
npm version patch && git push --follow-tags | |
npm publish |
function* zip(...iterables) { | |
let iterators = iterables.map(i => i[Symbol.iterator]()); | |
while (true) { | |
let entries = iterators.map(i => i.next()); | |
let done = entries.some(entry => entry.done); | |
if (done) break; | |
yield entries.map(e => e.value); | |
} | |
} |