AD | Andorre AE | Émirats arabes unis AF | Afghanistan AG | Antigua-et-Barbuda AI | Anguilla AL | Albanie AM | Arménie AO | Angola AQ | Antarctique AR | Argentine
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
/** | |
* Stupid nodejs script to use localtunnel and auto reconnect | |
* usage: node localtunnel.js port=3000 subdomain=toto | |
* | |
*/ | |
/* global console, require, process, setTimeout */ | |
const assert = require('assert'); | |
const localtunnel = require('localtunnel'); | |
var argv = process.argv.reduce(function(accumulator, str) { |
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
// To get [1, 2, 3, 4, 5, 6, ..., 900] | |
const start = 1; | |
const end = 900; | |
const ids = Array.apply(null, { length: end - start}).map(Number.call, (num) => Number(num) + start); |
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
//manifest.json | |
{ | |
"name": "bookmark-search-export", | |
"version": "1.0", | |
"manifest_version": 2, | |
"description": "This extention will dump all bookmarks", | |
"browser_action": { | |
"default_icon": "icon.png" | |
}, | |
"background": { |
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 { useCallback, useEffect, useState, useMemo } from 'react'; | |
const isBrowser = typeof window !== 'undefined'; | |
const isLocalstorageAvailable = () => { | |
if (!isBrowser) { | |
return false; | |
} | |
const test = `test-${Date.now()}`; |
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 { useCallback, useLayoutEffect, useRef } from 'react'; | |
const isBrowser = typeof window !== 'undefined'; | |
const getScrollPosition = ({ element, useWindow }) => { | |
if (!isBrowser) return { x: 0, y: 0 }; | |
if (useWindow) { | |
return { x: window.scrollX, y: window.scrollY }; | |
} |
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 { useCallback, useState, useEffect } from 'react'; | |
const isBrowser = typeof window !== 'undefined'; | |
const getSize = () => { | |
if (isBrowser) { | |
return { | |
width: window.innerWidth, | |
height: window.innerHeight, | |
}; |
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
/* | |
Demo: https://jsfiddle.net/elky/f6khaf2t/ | |
<div class="element"> | |
<div class="truncate"> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt | |
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco | |
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in | |
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat | |
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
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 React from 'react'; | |
import type { LayoutChangeEvent, Insets } from 'react-native'; | |
const defaultGetHitSlopForSize = ({ width, height }: Framesize): Insets => { | |
const x = width > 44 ? 0 : 10; | |
const y = height > 44 ? 0 : 10; | |
return { top: y, bottom: y, left: x, right: x }; | |
}; | |
type Framesize = { width: number; height: number }; |
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, useCallback } from 'react' | |
import { AxiosPromise } from 'axios' | |
export interface ApiResponse<T> { | |
data?: T | undefined | |
error?: Error | undefined | |
loading: boolean | |
} | |
export type UseApiResponse<T> = [ApiResponse<T>, (...args: any[]) => Promise<void>, () => void] |