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 copy | |
| import inspect | |
| import sys | |
| import typing | |
| from typing import ( | |
| Any, | |
| Dict, | |
| FrozenSet, | |
| List, | |
| Set, |
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 shello | |
| set envFilePath $HOME/Library/Containers/app.shello/Data/envs/$argv; | |
| # Check if the file exists | |
| if [ -f "$envFilePath" ] | |
| while read -la line | |
| set --local key (echo "$line" | cut -d '=' -f1); | |
| set --local value (echo "$line" | cut -d '=' -f2-); | |
| # Set the environment variable | |
| set -gx $key $value; | |
| # 👀 uncomment the line below if you want to print each 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
| /** | |
| * let the URL of the known image located in Google Drive is | |
| * let image_url = 'https://drive.google.com/file/d/1uD5rSY3eBp4y4HldnxeeRq3_wU9ZKxog/view?usp=sharing' | |
| * then image id would be 1uD5rSY3eBp4y4HldnxeeRq3_wU9ZKxog | |
| */ | |
| export function getDriveImageSourceId(source: string) { | |
| const match = source.match(/d\/([^/]*)/); | |
| if (match) { | |
| return match[1]; |
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
| <script type="application/ld+json"> | |
| { | |
| "@context":"http://schema.org/", | |
| "@type":"Article", | |
| "name":"A Brief History of Emoji", | |
| "headline": "A Brief History of Emoji", | |
| "url":"https://www.collecteurs.com/article/a-brief-history-of-emoji", | |
| "about": [ | |
| { | |
| "@type": "Thing", |
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 default (str) => { | |
| str = String(str).toString(); | |
| str = str.replace(/^\s+|\s+$/g, ""); // trim | |
| str = str.toLowerCase(); | |
| // remove accents, swap ñ for n, etc | |
| const swaps = { | |
| '0': ['°', '₀', '۰', '0'], | |
| '1': ['¹', '₁', '۱', '1'], | |
| '2': ['²', '₂', '۲', '2'], |
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
| /* Input placeholder animations */ | |
| ::placeholder { | |
| transition: all 350ms ease; | |
| } | |
| .your-input-class:focus::placeholder { | |
| transform: translate(20px, 0); | |
| opacity: 0; | |
| } |
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 extract_text(txt) { | |
| let innerText = "" | |
| let txtType = Object.prototype.toString.call(txt) | |
| // String header | |
| if (txtType === '[object String]') { | |
| innerText = txt | |
| } | |
| // Anchor header | |
| else if (txtType === '[object Object]') { | |
| innerText = txt.props.children |
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
| // Hook | |
| function useOnClickOutside(ref, handler) { | |
| useEffect( | |
| () => { | |
| const listener = (event) => { | |
| // Do nothing if clicking ref's element or descendent elements | |
| if (!ref.current || ref.current.contains(event.target)) { | |
| return; | |
| } | |
| handler(event); |
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 useDebounce(value, delay) { | |
| // State and setters for debounced value | |
| const [debouncedValue, setDebouncedValue] = useState(value); | |
| useEffect( | |
| () => { | |
| // Update debounced value after delay | |
| const handler = setTimeout(() => { | |
| setDebouncedValue(value); | |
| }, delay); |
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 useWindowSize(initialWidth, initialHeight) { | |
| const [windowSize, setWindowSize] = useState({ | |
| width: isClient ? window.innerWidth : initialWidth, | |
| height: isClient ? window.innerHeight : initialHeight, | |
| }); | |
| useEffect(() => { | |
| function resizeHandler() { | |
| if (windowSize.width !== window.innerWidth || windowSize.height !== window.innerHeight) { |
NewerOlder