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 duplicate = arr => { | |
const ordered = Array(arr.length).fill(false) | |
for (let i = 0; i < arr.length; i++) { | |
const element = arr[i] | |
if (ordered[element]) | |
return element | |
ordered[element] = true | |
} | |
} |
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 newId = length => | |
[...Array(length)].map(_i => (~~(Math.random() * 36)).toString(36)).join('') | |
function newId(length) { | |
return [...Array(length)].map(_i => (~~(Math.random() * 36)).toString(36)).join('') | |
} |
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
# Before copying, replace GITHUB_USERNAME shown below with your GitHub username | |
# Copy this into your .bash_profile found in ~/ | |
# When you're inside of a git repo, call "backup" without any arguments to back up the current git repo | |
# Even when you are outside of a git repo, call "backup REPO_NAME", for example "backup typescript" | |
function backup() { | |
if [ -z "$1" ] | |
then | |
cloneUrl=$(git config --get remote.origin.url) | |
else |
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 __internal_VALID_ELEMENT_ID_CHARACTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' | |
const __internal_ELEMENT_ID_LENGTH = 36 | |
let __internal_elements = () => [] | |
const __internal_generateElementId = () => | |
[...Array(__internal_ELEMENT_ID_LENGTH)] | |
.map(() => | |
__internal_VALID_ELEMENT_ID_CHARACTERS.charAt( | |
Math.floor(Math.random() * __internal_VALID_ELEMENT_ID_CHARACTERS.length) |
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
/* | |
* - Access a collection | |
* store.collection('users') | |
* | |
* - Access a document | |
* store.collection('users').document('abc') | |
* store.document('users/abc') | |
* | |
* - Get all the documents in a collection | |
* store.collection('users').documents() // Forced to reload documents |