This Web Components keeps the year in your copyright notice up-to-date.
export { CopyrightYearElement }
const name = "copyright-year";
class CopyrightYearElement extends HTMLSpanElement {| // Converts `1234567` => `"1,234,567" | |
| // Does not support decimals yet | |
| function formatNumberWithCommas (number) { | |
| return ('' + number) // Convert to a string | |
| .split('').reverse().join('') // Reverse the order of the characters (which are all digits at this point) | |
| .replace(/(...)/g, '$1,') // Insert a comma after every three digits | |
| .split('').reverse().join('') // Un-reverse the characters | |
| .replace(/^,/, ''); // Remove any commas that were added to the beginning (i.e. if the number of digits was a multiple of three) | |
| }; |
| import { useEffect, useState } from "react" | |
| import { createBrowserHistory } from "history" | |
| const history = createBrowserHistory() | |
| const trim = url => url.replace(/^\/|\/$/g, "") | |
| function useRouter(initial = "") { | |
| const [route, setRoute] = useState(initial) | |
| useEffect(() => { | |
| const { pathname, search } = new URL(route, window.location.href) |
Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "[email protected]"
| { | |
| "keys": ["tab"], | |
| "command": "expand_abbreviation_by_tab", | |
| // put comma-separated syntax selectors for which | |
| // you want to expandEmmet abbreviations into "operand" key | |
| // instead of SCOPE_SELECTOR. | |
| // Examples: source.js, text.html - source | |
| "context": [ | |
| { |