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
// strip tags from HTML string | |
let strippedString = originalString.replace(/(<([^>]+)>)/gi, ""); | |
// remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)]; | |
// shuffle Array | |
const shuffleArray = (arr) => arr.sort(() => Math.random() - 0.5); | |
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
console.log(shuffleArray(arr)); |
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
export const slugify = string => { | |
const a = | |
"àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;"; | |
const b = | |
"aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------"; | |
const p = new RegExp(a.split("").join("|"), "g"); | |
return string | |
.toString() | |
.toLowerCase() |
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 { useState, useCallback } from "react"; | |
import useLayoutEffect from "hooks/useIsomorphicLayoutEffect"; | |
function getDimensionObject(node) { | |
if (node.getBoundingClientRect) { | |
const rect = node.getBoundingClientRect(); | |
return { | |
width: rect.width, | |
height: rect.height, |
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": "Afghanistan", | |
"cca2": "AF", | |
"cca3": "AFG", | |
"ccn3": 4 | |
}, | |
{ | |
"Name": "Albania", | |
"cca2": "AL", |
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
# Logs | |
logs | |
*.log | |
npm-debug.log* | |
yarn-debug.log* | |
yarn-error.log* | |
lerna-debug.log* | |
# Diagnostic reports (https://nodejs.org/api/report.html) | |
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json |
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
# build environment | |
FROM node:10.15.3-alpine as builder | |
WORKDIR /usr/src/app | |
ENV PATH /usr/src/app/node_modules/.bin:$PATH | |
COPY ./package.json ./ | |
RUN npm install | |
COPY . . | |
RUN npm run build | |
# production environment |
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
// By @coderitual | |
// https://twitter.com/coderitual/status/1112297299307384833 | |
// Remove any duplicates from an array of primitives. | |
const unique = [...new Set(arr)] | |
// Sleep in async functions. Use: await sleep(2000). | |
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
// Type this in your code to break chrome debugger in that line. |
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
FROM node:alpine | |
EXPOSE 8000 9929 9230 | |
RUN \ | |
apk add --no-cache python make g++ && \ | |
apk add vips-dev fftw-dev --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing --repository http://dl-3.alpinelinux.org/alpine/edge/main && \ | |
rm -fR /var/cache/apk/* | |
RUN npm install -g gatsby-cli yarn | |
WORKDIR /app |