Skip to content

Instantly share code, notes, and snippets.

Peter Forgacs peterforgacs

Block or report user

Report or block peterforgacs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ffmpeg-normalize.js
const { normalize } = require('ffmpeg-normalize');
normalize({
input: 'input.mp4',
output: 'output.mp4',
loudness: {
normalization: 'ebuR128',
target:
{
input_i: -23,
View normalize.sh
ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:print_format=json -f null -
ffmpeg -i input.mp4 -af
loudnorm=I=-23:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11 04:measured_thresh=-40.21:offset=-0.47 -ar 48k -y output.mp4
View flatten-benchmark.js
const { Benchmark } = require("benchmark");
function generateRandomNumberBetween(min, max){
return Math.floor(Math.random() * max) + min;
}
function generateTupleArray(length) {
const tupleArray = [];
for (let i = 0; i < length; i++) {
tupleArray.push([generateRandomNumberBetween(1, 1e3), generateRandomNumberBetween(1, 1e3)]);
}
return tupleArray;
View flatten.js
let arr = [ [1, 2], [3, 4]];
// version 1
arr.reduce((acc, curr) => acc.concat(curr), []);
// version 2
arr.reduce((acc, curr) => [...acc, ...curr], []);
// version 3
[].concat(...arr);
View reverse-benchmark.js
const { Benchmark } = require("benchmark");
function generateRandomString(length) {
var result = "";
var characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
View reverse.js
// version 1
"hello".split("").reverse();
// version 2
[..."hello"].reverse();
// version 3
Array.from("hello").reverse();
View flatten-benchmark.js
const { Benchmark } = require("benchmark");
function generateRandomNumberBetween(min, max){
return Math.floor(Math.random() * max) + min;
}
function generateTupleArray(length) {
const tupleArray = [];
for (let i = 0; i < length; i++) {
tupleArray.push([generateRandomNumberBetween(1, 1e3), generateRandomNumberBetween(1, 1e3)]);
}
return tupleArray;
@peterforgacs
peterforgacs / index.js
Last active Feb 10, 2018
[base64 string to image file] How to write an image in node.js #Node.js
View index.js
'use strict';
const util = require('util');
const fs = require('fs');
const write = util.promisify(fs.writeFile);
module.exports = ({ image, identifier, directory }) => {
try {
const extension = image.split(';')[0].match(/jpeg|png|gif/)[0];
const data = image.replace(/^data:image\/\w+;base64,/, '');
@peterforgacs
peterforgacs / README.md
Last active Feb 3, 2018
[Koa routing] How to pipe koa steps and routers #koa #koarouter #node.js #javascript
View README.md

Koa

Uses middleware pattern.
Each time we use app.use we add an other middleware function.

ctx - The context contains all the information for a signle request and the response object aswell.

next - Calls the next middleware.

@peterforgacs
peterforgacs / stats.js
Last active Jan 19, 2018
Peer connection RTCLegacyStatsReport
View stats.js
// Chrome 63
let peerConnectionObject = ... // Some peer connection
peerConnectionObject.getStats(function(res) {
console.log(res.result());
});
You can’t perform that action at this time.