const docRef = await db.collection('foo').add({})
console.log(docRef.id)
This file contains hidden or 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 foo = { | |
| bar: { | |
| baz: 2 | |
| } | |
| } | |
| let foo2 = modify(foo, () => {}) | |
| console.assert(foo === foo2) |
This file contains hidden or 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 objectMap () { | |
| return Object.defineProperty(Object.create(null), Symbol.iterator, { | |
| configurable: true, // This descriptor is inspired by Map.prototype[Symbol.iterator] | |
| writable: true, | |
| value: function* () { | |
| for (const key in this) { | |
| yield [key, this[key]] | |
| } | |
| } | |
| }) |
This file contains hidden or 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 uid = () => [...crypto.getRandomValues(new Uint8Array(16))] | |
| .map(x => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.charAt(x % 62)) | |
| .join('') |
This file contains hidden or 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
| var respond = function () { | |
| var responders = [] | |
| var post | |
| addEventListener('DOMContentLoaded', domContentLoaded) | |
| addEventListener('hashchange', hashchange) | |
| addEventListener('submit', submit) | |
| function domContentLoaded () { | |
| removeEventListener('DOMContentLoaded', domContentLoaded) |
This file contains hidden or 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 trimText (text) { | |
| text = text | |
| .replace(/^\r?\n/, '') | |
| .replace(/\r?\n[ \t]*$/, '') | |
| var indent = text.match(/^[ \t]*/gm) | |
| .reduce(function (result, indent) { | |
| if (result === null) { | |
| return indent | |
| } | |
| return result.length < indent.length ? result : indent |
This file contains hidden or 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
| https://tinybin.glitch.me/#NoIgqgdgLgllA2BTAJiANABk9gjGkAPMjAG4B8AOhAATUEAOlNtdAhtQBYBOiAZgLwUQAK1YlWAZwDGXGPSgAuIWQAyAewDmMCAQD0rJrT2MqRjjlWbte84bq81XALZ2jJ5izrxWAI0TxqBy5BEA41CShlAAlwxT1vP3hXFgIfLmSjbXoAVyhqKABPekQQqEQAD0iQahhkELCIoWoIVicSoQaq5ONu908jBP9AxxDsiUQuZTBxrgV4338MujSlgizc-KL2kDLKptrRmaaWtsOJ5VMU3T6Um88CQYCgkPpJCQB3R2RlAAU3z64yDmukeqxWl3u6zyhWKL3+X32dSErwkHwR1RO2xRaMBFw8dGuvTBuSgaggli0Ol0PhJZO6hMueiCLioemI5CorPZdgY3XY3D4IVE4mksnkShAFOs+mSughbE4PAEQmFkhkckUyk6egMjIZzAItgAIqwoL5JIgJDYLIy7gqBcqRGI1WLNZKAHKId7UE1mnwWnV8xWClXO0UaiVkACi5UQUlyiGoAEVshMCoH5QR+UqhWH1eLlABJJz0RxQDP4rPBx2q8MFyUx0tccsyvU3Ah+pDUHxfCYhHB4+5QDiIVjIVZQdLyoccMju1qIPTDpZGZcAQSksDJS9n04Jk-pw9H48zUB7yAKE6n+KHJ5v-SrDtzIvzbrIyFN5vGFf6Vygd9-VcAMAoxsxDJ0X1dSMo2IFtdXve4wJrPMoOUI1-EQMof0ApdgPuXQD0zAjz0vPVO0QJg2VIJguWo20gyfUNIIjZR1EpbDaDlSskOfF0WMlbVWwNfUzAsT1vV9L9F10WxGWZIk9weBYnhGIRMWUec2mBUFFPBe81ggHJoS2UoKiqGokRAdSMQXEJrPpO1eV02lyXEn1P39b9qRchyeV0eTWV0blOR0YKDUcnimL4+spSpeDPC4xDq14us30E+KCXbWwYzjBNk1TLh0xkm0DQCys7QGZThmCIQAEcCoKZQUzTbTl |
This file contains hidden or 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 java.util.ArrayList; | |
| import java.util.concurrent.atomic.AtomicInteger; | |
| class Example { | |
| static Promise sleep(final int duration) { | |
| return new Promise(new Executor() { | |
| void execute(final Handler handler) { | |
| new Thread(new Runnable() { | |
| public void run() { |
This file contains hidden or 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 java.util.Arrays; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| public final class Tsv { | |
| private Tsv() { | |
| } | |
| public static String stringify(List<List<String>> rows) { |
This file contains hidden or 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
| <?php | |
| // Converts element#id.class.more-class to XPath | |
| function css_selector_to_xpath($selector) { | |
| if (preg_match('/ | |
| (?P<tag>(?:\*|[a-z0-9_-]+)?) | |
| (?P<id>(?:\#[a-z0-9_-]+)?) | |
| (?P<classes>(?:\.[a-z0-9_-]+)*) | |
| /ix', $selector, $matches)) { | |
| $xpath = ''; |