Skip to content

Instantly share code, notes, and snippets.

View italosantana's full-sized avatar
🎯
Focusing

Ítalo S. italosantana

🎯
Focusing
View GitHub Profile
@italosantana
italosantana / Format a duration ( from seconds ) using date-fns
Created October 21, 2021 10:38
Formating a duration from seconds using date-fns
import { intervalToDuration } from 'date-fns'
const seconds = 10000
intervalToDuration({ start: 0, end: seconds * 1000 })
// { hours: 2, minutes: 46, seconds: 40 }
@italosantana
italosantana / difference in days and hours in the data-fns lib
Created October 21, 2021 10:35
difference in days and hours in the data-fns using lib nodejs/browser
// Get the duration between January 15, 1929 and April 4, 1968.
intervalToDuration({
start: new Date(1929, 0, 15, 12, 0, 0),
end: new Date(1968, 3, 4, 19, 5, 0)
})
// => { years: 39, months: 2, days: 20, hours: 7, minutes: 5, seconds: 0 }
@italosantana
italosantana / testings scripts w10 with jest
Created October 13, 2021 18:29
testings scripts w10 with jest
"scripts": {
"test": "export NODE_ENV=test && jest",
"test:window": "set NODE_ENV=test && jest",
"clear_jest": "jest --clearCache",
"test-watch": "export NODE_ENV=test && jest --watch"
}
@italosantana
italosantana / Setting environment variables package.json
Created October 7, 2021 00:33
Setting environment variables package.json
Make it cross-platform by using cross-env:
"server": "cross-env SERVERPORT=3002 node ./fiboserver"
Linux
"scripts": {
"dev:linux": "NODE_ENV=development node foo.js"
}
@italosantana
italosantana / removendo-pasta-diretorio-do-git
Last active July 29, 2021 14:10
remover pasta/diretório do git
git rm -r --cached FolderName
git commit -m "Removed folder from repository"
git push origin master
@italosantana
italosantana / functionPegarHoraLocal.js
Last active July 25, 2021 00:31
Pegar hora local + tempo real + setInterval
/* Completa com zeros numeros com 1 digito */
function pad(s) {
return (s < 10) ? '0' + s : s;
}
/* Obter a hora e aplica ao objeto */
function newData() {
var date = new Date();