I started using this switch(true) { ... } pattern after reading this tweet in 2019.
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
| ~/Projects/test-eleventy-plugin-sass $ yarn add -D @11ty/eleventy eleventy-plugin-sass | |
| yarn add v1.22.4 | |
| info No lockfile found. | |
| [1/4] 🔍 Resolving packages... | |
| warning @11ty/eleventy > browser-sync > socket.io > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) | |
| warning @11ty/eleventy > browser-sync > socket.io > engine.io > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) | |
| warning @11ty/eleventy > browser-sync > socket.io > socket.io-parser > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/iss |
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
| @mixin set($name) { | |
| %#{$name} { | |
| @content; | |
| } | |
| } | |
| @mixin get($name) { | |
| @extend %#{$name}; | |
| } |
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 applySpaces(textElements) { | |
| const tweetText = [...textElements]; | |
| tweetText.map((text,i,arr) => { | |
| if (!text.length) { | |
| const lastText = arr[i-1]; | |
| arr[i-1] = `${lastText} `; | |
| } | |
| return text; |
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
| export function capitalize(str) { | |
| return str.replace(/(^|\s)[a-z]/g, capturedText => capturedText.toUpperCase()); | |
| } |
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 React from "react"; | |
| const persistedCache = {}; | |
| function usePersistedCache(key,initial) { | |
| persistedCache[key] = persistedCache[key] || initial; | |
| const [state, setState] = React.useState(persistedCache[key]); | |
| return [state, value => { | |
| persistedCache[key] = value; | |
| React.setState(value) |
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
| /** | |
| * @param {Function} callback | |
| * @param {undefined|number} timeoutHandler | |
| * @param {number=300} time | |
| */ | |
| export default function debounce( | |
| callback, | |
| time = 300, | |
| timeoutHandler = window.DEBOUNCE_TIMEOUT_HANDLER | |
| ) { |
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
| BRANCH=$(git branch | grep \* | sed -E 's/\*[ ]//g') && git push -u origin $BRANCH; |
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
| javascript:var t=document.createElement('textarea');t.id='t';document.body.appendChild(t);t.innerHTML=document.querySelector('.image-container .screenshot-image').src;t.select();document.execCommand('copy'); |
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
| $blue--dark: #002a5c; | |
| $blue--light: #1ab6e9; | |
| $red: #d11145; | |
| $yellow: #fee619; | |
| $blue--light--darkened: #0C5D78; |
NewerOlder