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
;(function(refreshAfter){ | |
var hideTime = null | |
document.addEventListener("visibilitychange", function() { | |
if (document.hidden) { | |
hideTime = Date.now() | |
} else if (hideTime && Date.now() - hideTime > refreshAfter) { | |
location.reload() | |
} | |
}, false) | |
}(5000)) |
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 { Record } from 'immutable' | |
interface PersonProps { | |
firstName: string | |
lastName: string | |
} | |
const defaultPersonProps: PersonProps = { | |
firstName: '', | |
lastName: '', |
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
async function sha1(str) { | |
const enc = new TextEncoder(); | |
const hash = await crypto.subtle.digest('SHA-1', enc.encode(str)); | |
return Array.from(new Uint8Array(hash)) | |
.map(v => v.toString(16).padStart(2, '0')) | |
.join(''); | |
} | |
// await sha1('hello, world!'); | |
// outputs: 1f9d3c707d53f3d16c53dd73d70a6ce7596a9 |