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
[ | |
{ | |
"avatar": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/Commodore_Grace_M._Hopper%2C_USN_%28covered%29.jpg/192px-Commodore_Grace_M._Hopper%2C_USN_%28covered%29.jpg", | |
"name": "Grace Hopper", | |
"user_id": 1906, | |
"status": "Life was simple before World War II. After that, we had systems." | |
}, | |
{ | |
"avatar": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Alan_Turing_Aged_16.jpg/176px-Alan_Turing_Aged_16.jpg", | |
"name": "Alan Turing", |
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
# Create new directory and jump inside it | |
# USAGE: md <new directory name> | |
function md() { | |
mkdir "$1" | |
cd "$1" | |
} | |
# Modify and re-source your .bashrc | |
function bashrc() { | |
nano ~/.bashrc; |
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 FIGURE_WITH_LAZY = /<img\s+.*lazy=.*>/g; | |
const addLazy = (token) => { | |
if (token.type === 'image') { | |
if (!token.attrs) { | |
token.attrs = []; | |
} | |
token.attrs.push(['loading', 'lazy']); | |
} else if ( | |
token.type === 'html_block' && |
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
/** | |
* Simplified `splice` implementation that doesn't handle all the different use cases for `start`. | |
* | |
* Deleting items in-place without using `splice` is hard. Here's the plan: | |
* 1. Create an array (`deletedItems`) of items which the user WANTS to remove from the array. | |
* 2. Create an array (`reinsertedItems`) of all items that come AFTER the deleted items. | |
* 3. Truncate the whole array to everything UP TO `start`. | |
* 4. Insert any new items provided by the user. | |
* 5. Reinsert everything in `reinsertedItems`. | |
* 6. Return `deletedItems`. |
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
:root { | |
--twitch-gray: rgb(173, 173, 184); | |
--twitch-light: rgb(239, 239, 241); | |
--twitch-dark-background: rgb(24, 24, 27); | |
--twitch-purple: rgb(180, 84, 255); | |
} | |
body { | |
background-color: var(--twitch-light); | |
} |
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
/** | |
* Determines whether a given number is "odious" (its binary expansion has an odd number of ones) | |
* @param {number} num non-negative integer to test odiousness of | |
* @returns {boolean} whether `num` is odious | |
*/ | |
function isOdious(num) { | |
let numberOf1Bits = 0; | |
// Binary expansions represent numbers as sums of powers of 2 | |
// So we need to find how many powers of 2 can be subtracted from `num` |
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 el() { | |
mkdir "$1" | |
cd "$1" | |
git init | |
mkdir -p src/_data/ | |
mkdir src/_includes/ | |
# Populate .gitignore | |
echo "# Node" >> .gitignore |
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
/** | |
* Take an array of phrases and return a list of anagram groups | |
* @param {string[]} phrases list of strings which may or may not be anagrams of other strings in the same list | |
* @returns {string[][]} a list of arrays of strings, where every string in an inner array is an anagram of the others | |
*/ | |
function groupAnagrams(phrases) { | |
/** @type {Object<string, string[]>} */ | |
const anagramGroups = {}; | |
// Create a map of anagram groups |
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
/** | |
* @type {Object<String, String[]>} | |
*/ | |
const keypad = { | |
'2': ['a', 'b', 'c'], | |
'3': ['d', 'e', 'f'], | |
'4': ['g', 'h', 'i'], | |
'5': ['j', 'k', 'l'], | |
'6': ['m', 'n', 'o'], | |
'7': ['p', 'q', 'r', 's'], |
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
/** | |
* @typedef {object} Point | |
* @property {string} name | |
* @property {string[]} connections | |
*/ | |
/** @type {Point[]} */ | |
const listOfPoints = [ | |
{ name: 'A', connections: ['B', 'C'] }, | |
{ name: 'B', connections: ['A', 'E'] }, |
OlderNewer