Skip to content

Instantly share code, notes, and snippets.

View EminQasimov's full-sized avatar
🎯
Focusing

Emin Gasimov EminQasimov

🎯
Focusing
View GitHub Profile
@MarksCode
MarksCode / use-prompt.ts
Last active May 16, 2024 11:16
return `usePrompt` capabilities from react-router
/**
* 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);
@markmichon
markmichon / devto.js
Created March 9, 2020 02:04
Dev.to API client example
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;
@bmcmahen
bmcmahen / useDeferredMount.js
Last active February 1, 2020 16:24
Deferred mounting hook
import { useState, useEffect } from 'react';
function useDeferredMount() {
const [shouldMount, setShouldMount] = useState(false);
useEffect(() => {
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => {
setShouldMount(true);
});
@EminQasimov
EminQasimov / Learning resources examples-demos
Last active January 23, 2020 13:27
Learning resources examples-demos links
#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/
/**
* 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).
@delucis
delucis / rename-files.sh
Created May 11, 2017 19:15
Bash rename multiple files
# 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
@sheharyarn
sheharyarn / request.js
Last active August 24, 2023 14:55
Axios Request Wrapper for React (https://to.shyr.io/axios-requests)
/**
* Axios Request Wrapper
* ---------------------
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
*/
import axios from 'axios'
@ahem
ahem / loadimage.js
Created October 18, 2016 12:59
Load and decode images with webworker
/* 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); };
});
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
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"