Skip to content

Instantly share code, notes, and snippets.

View piotrlo's full-sized avatar

Piotr Loch piotrlo

  • Gdynia, Poland
View GitHub Profile
@sarakusha
sarakusha / createDebouncedAsyncThunk.ts
Last active December 30, 2023 16:26
A debounced analogue of `createAsyncThunk` from `@reduxjs/toolkit`
import { createAsyncThunk, AsyncThunkPayloadCreator, AsyncThunk } from '@reduxjs/toolkit';
type DebounceSettings = {
/**
* The maximum time `payloadCreator` is allowed to be delayed before
* it's invoked.
* @defaultValue `0`
*/
maxWait?: number;
/**
@franky47
franky47 / use100vh.js
Created January 11, 2020 07:44
React hook to fix the 100vh issue on mobile Chrome and Safari
import React from 'react';
import { useWindowSize } from 'react-use';
// 100vh is broken on mobile (Chrome, Safari):
// https://chanind.github.io/javascript/2019/09/28/avoid-100vh-on-mobile-web.html
export default function use100vh() {
const ref = React.useRef();
const { height } = useWindowSize();
@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);
@cawa87
cawa87 / base64.js
Last active August 26, 2021 07:36
JavaScript Convert an image to a base64 url
/**
* Convert an image
* to a base64 url
* @param {String} url
* @param {Function} callback
* @param {String} [outputFormat=image/png]
*/
function convertImgToBase64URL(url, callback, outputFormat){
var img = new Image();
img.crossOrigin = 'Anonymous';