Skip to content

Instantly share code, notes, and snippets.

View 3rdp's full-sized avatar

Alex Davydenko 3rdp

  • Ukraine
View GitHub Profile
function timeSince(timeStamp) {
var now = new Date(),
secondsPast = (now.getTime() - timeStamp.getTime()) / 1000;
if(secondsPast < 60){
return [-parseInt(secondsPast), 'seconds']
}
if(secondsPast < 3600){
return [-parseInt(secondsPast/60), 'minutes']
}
if(secondsPast <= 86400){
@3rdp
3rdp / pre-commit.sh
Last active June 6, 2019 06:52 — forked from gerad/pre-commit.sh
git pre-commit hook that checks for debugger / console.log
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, make this file executable.
if git-rev-parse --verify HEAD 2>/dev/null
@3rdp
3rdp / countOfSymbol.js
Last active November 27, 2017 21:36 — forked from anonymous/countOfSymbol.js
Test quest javascript / Save The Day
/*
* Finished: 30 min
*/
function countOfSymbol(arr) {
let filter2 = (v) => v == '2'
return arr.map((v) => v.toString().split(''))
.reduce((prev, curr) => prev.filter(filter2).length >= curr.filter(filter2).length ? prev : curr, [])
.join('') || null
}