Skip to content

Instantly share code, notes, and snippets.

View piotrlo's full-sized avatar

Piotr Loch piotrlo

  • Gdynia, Poland
View GitHub Profile
// Capitalize all words of a string
function capitalize(string) {
return string.replace(/\b[a-z]/g, (char) => char.toUpperCase());
}
capitalize('overment rocks!');
@piotrlo
piotrlo / use100vh.js
Created June 1, 2020 21:14 — forked from franky47/use100vh.js
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();
// Array to CSV data
const csvContent = result.map(e => e.join(",")).join("\n");
copy(csvContent)