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 / 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();
@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 / 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 / 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 / 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 / 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 }
on: [push]
jobs:
merge_conflict_job:
runs-on: ubuntu-latest
name: Find merge conflicts
steps:
# Checkout the source code so we have some files to look at.
- uses: actions/checkout@v2
# Run the actual merge conflict finder
- [] learn smart contracts
- [] learn Types of Blockchain
- [] learn eth
- [] learn DEFI
- [] learn Dapps
- [] learn Tokens
@italosantana
italosantana / hardhat.config.js
Last active March 4, 2022 11:52
hardhat.config.js
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.7",
paths: {
artifacts: './src/artifacts',
},
networks: {
@italosantana
italosantana / Querying the Blockchain
Last active March 4, 2022 19:06
Querying the Blockchain
// Look up the current block number
await provider.getBlockNumber()
// 14135476
// Get the balance of an account (by address or ENS name, if supported by network)
balance = await provider.getBalance("ethers.eth")
// { BigNumber: "82826475815887608" }
// Often you need to format the output to something more user-friendly,
// such as in ether (instead of wei)