$ docker
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 Base32(v) { | |
v = v?.toString(); | |
if (!v || !v.length) { | |
throw new Error('Value must not be empty'); | |
} | |
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; | |
let bits = 0; |
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
const getActualRequestDurationInSeconds = start => { | |
const NS_PER_SEC = 1e9; // convert to nanoseconds | |
const diff = process.hrtime(start); | |
console.log( diff ); | |
return (diff[0] * NS_PER_SEC + diff[1]) / NS_PER_SEC; | |
}; | |
const requestDurationMiddleware = (req, res, next) => { | |
const start = process.hrtime(); | |
res.on('finish', () => { |
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
document.getElementById("app").innerHTML = ` | |
<button id="white-demo">White Noise</button> | |
<button id="pink-demo">Pink Noise</button> | |
<button id="brown-demo">Brown Noise</button> | |
`; | |
(function (AudioContext) { | |
AudioContext.prototype.createWhiteNoise = function (bufferSize) { | |
bufferSize = bufferSize || 4096; | |
const node = this.createScriptProcessor(bufferSize, 1, 1); |
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
const { generateKeyPairSync, createSign, createVerify } = require('crypto'); | |
const ALGORITHM = 'ec'; | |
const NAMED_CURVE = 'P-256'; | |
const HASH_FUNCTION = 'sha256'; | |
const ENCODING = 'base64'; | |
const { privateKey, publicKey } = generateKeyPairSync(ALGORITHM, { | |
namedCurve: NAMED_CURVE, | |
}); |
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 * as crypto from 'crypto'; | |
const ALGORITHM = 'aes-256-gcm'; | |
const IV_LENGTH = 16; | |
const SALT_LENGTH = 64; | |
const TAG_LENGTH = 16; | |
const TAG_POSITION = SALT_LENGTH + IV_LENGTH; | |
const ENCRYPTED_POSITION = TAG_POSITION + TAG_LENGTH; | |
export class AES { |
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
/** | |
* | |
* @param html encoded html | |
* example: | |
* <p>In this course, you&rsquo;ll learn:</p> | |
* wiill get decoded to: | |
* <p>In this course, you'll learn:</p> | |
*/ | |
function decode(html: string) { | |
var txt = document.createElement('textarea'); |
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 ReactDOM from 'react-dom'; | |
import 'bootstrap/dist/css/bootstrap.min.css'; | |
import { Button, Tooltip } from 'reactstrap'; | |
class App extends React.Component { | |
state = {}; | |
toggle = targetName => { | |
if (!this.state[targetName]) { |