This file contains 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
/** | |
* Prompts a user when they exit the page | |
*/ | |
import { useCallback, useContext, useEffect } from 'react'; | |
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom'; | |
function useConfirmExit(confirmExit: () => boolean, when = true) { | |
const { navigator } = useContext(NavigationContext); |
This file contains 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 fetch = require("isomorphic-unfetch"); | |
const querystring = require("querystring"); | |
class DevTo { | |
constructor(config) { | |
this.api_key = config.api_key; | |
this.basePath = "https://dev.to/api"; | |
} | |
request(endpoint = "", options = {}) { | |
let url = this.basePath + endpoint; |
This file contains 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 { useState, useEffect } from 'react'; | |
function useDeferredMount() { | |
const [shouldMount, setShouldMount] = useState(false); | |
useEffect(() => { | |
window.requestAnimationFrame(() => { | |
window.requestAnimationFrame(() => { | |
setShouldMount(true); | |
}); |
This file contains 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
#1 Pure CSS Parallax | |
https://keithclark.co.uk/articles/pure-css-parallax-websites/demo3/ | |
https://keithclark.co.uk/articles/pure-css-parallax-websites/ | |
#2 Custom element for rendering 3D models and controlling them with CSS | |
https://keithclark.co.uk/labs/3d-model-custom-element/examples/tests/ | |
#3 Loading CSS without blocking render | |
https://keithclark.co.uk/articles/loading-css-without-blocking-render/ |
This file contains 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
/** | |
* Hypertext Transfer Protocol (HTTP) response status codes. | |
* | |
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes} | |
*/ | |
export enum HttpStatusCode { | |
/** | |
* The server has received the request headers and the client should proceed to send the request body | |
* (in the case of a request for which a body needs to be sent; for example, a POST request). |
This file contains 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
# use string replacement to rename parts of all matching filenames | |
# based on http://stackoverflow.com/questions/7450818/rename-all-files-in-directory-from-filename-h-to-filename-half | |
for file in *.wav; do mv "$file" "${file/selection/substitution}"; done |
This file contains 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
/** | |
* Axios Request Wrapper | |
* --------------------- | |
* | |
* @author Sheharyar Naseer (@sheharyarn) | |
* @license MIT | |
* | |
*/ | |
import axios from 'axios' |
This file contains 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
/* global createImageBitmap */ | |
function loadImageWithImageTag(src) { | |
return new Promise((resolve, reject) => { | |
const img = new Image; | |
img.crossOrigin = ''; | |
img.src = src; | |
img.onload = () => { resolve(img); }; | |
img.onerror = () => { reject(img); }; | |
}); |
This file contains 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
// Add on element with overflow | |
-webkit-mask-image: -webkit-radial-gradient(white, black); |
This file contains 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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
NewerOlder