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 timestamp = 1747399747; // This is a Unix timestamp | |
| const date = new Date(timestamp * 1000); // JavaScript's Date constructor expects milliseconds, so the timestamp is multiplied by 1000. | |
| console.log(date.toISOString()); // toISOString() outputs the date in ISO 8601 format in UTC time | |
| console.log(date.toLocaleString()); // toLocaleString() converts the date to a locale-specific string, such as "5/15/2025, 9:35:47 PM" in U.S. format (depending on your system locale and time zone). |
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
| typeof x === 'object' && !Array.isArray(x) && x !== null |
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 prefix = "is-"; | |
| const elements = document.querySelectorAll(<SELECTOR>); | |
| elements?.forEach((element) => { | |
| const classes = elements.className | |
| .split(" ") | |
| .filter((c) => !c.startsWith(prefix)); | |
| elements.className = classes.join(" ").trim(); | |
| }); |
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 items = [ | |
| { | |
| key: 'categoryA', | |
| sequence: 1 | |
| }, | |
| { | |
| key: 'categoryB', | |
| sequence: 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
| // array-of-objects | |
| const dataset = [ | |
| { | |
| id: 1, | |
| name: 'Foo', | |
| timestamp: new Date() | |
| }, | |
| { | |
| id: 2, | |
| name: 'Bar', |
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 findByKey(obj, keyToFind) { | |
| return Object.entries(obj) | |
| .reduce((acc, [key, value]) => (key === keyToFind) | |
| ? acc.concat(value) | |
| : (typeof value === 'object') | |
| ? acc.concat(findByKey(value, keyToFind)) | |
| : acc | |
| , []) | |
| } |
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 xmlData = ``; | |
| function getCommaSeparatedUrls(xml) { | |
| const parser = new DOMParser(); | |
| const xmlDoc = parser.parseFromString(xml, 'text/xml'); | |
| const sitemapNodes = xmlDoc.getElementsByTagName('loc'); | |
| const urls = []; | |
| for (let i = 0; i < sitemapNodes.length; i++) { | |
| urls.push(sitemapNodes[i].textContent); |
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
| name: Create Environment Variables | |
| on: push | |
| jobs: | |
| dev-build: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@v2 | |
| - name: Create develop env file |
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 { toRefs } from 'vue' | |
| import { reactive } from '@vue/reactivity' | |
| import { IFetch } from '@/interfaces' | |
| export default function useFetch() { | |
| const state: IFetch = reactive({ | |
| data: null, | |
| isLoading: false, | |
| errorMessage: '', | |
| isFinished: false, |
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 webComponent = document.querySelector(<COMPONENT>); | |
| const shadow = webComponent && webComponent.shadowRoot; | |
| const frame = shadow && shadow.querySelector('iframe'); | |
| if (frame) { | |
| const sheet = new CSSStyleSheet; | |
| sheet.replaceSync('iframe { height: 100vh !important; width: 100vw !important; }'); | |
| shadow.adoptedStyleSheets = [sheet]; | |
| } |
NewerOlder