Skip to content

Instantly share code, notes, and snippets.

View vladcorn's full-sized avatar
🎯
Focusing

Vlad Petrovich vladcorn

🎯
Focusing
  • Kharkiv, Ukraine
View GitHub Profile
const formatDurationPolls = (
createdAt: Date,
duration: number,
timeOfEdit: Date = new Date()
) => {
const ends = moment(new Date(createdAt).getTime() + duration * 60000);
const days = moment(timeOfEdit).diff(ends, 'days') * -1;
const hours = moment(timeOfEdit).diff(ends, 'hours') * -1 - days * 24;
const minutes =
moment(timeOfEdit).diff(ends, 'minutes') * -1 -
@vladcorn
vladcorn / colorTypeChecker.js
Created May 20, 2020 07:33
Check type of color (dark or light)
function colorChecker(red,green,blue){
if (1 - (0.299 * red + 0.587 * green + 0.114 * blue) / 255 < 0.5) {
//light
}
else {
// dark
}
}