This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { resolve } = require('path'); | |
module.exports = { | |
'config': resolve(__dirname, 'src', 'config', 'database.js'), | |
'models-path': resolve(__dirname, 'src', 'app', 'models'), | |
'migrations-path': resolve(__dirname, 'src', 'database', 'migrations'), | |
'seeders-path': resolve(__dirname, 'src', 'database', 'seeds'), | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
dialect: 'postgres', | |
host: 'localhost', | |
username: 'postgres', | |
password: 'docker', | |
database: 'gobarber', | |
define: { | |
timestamps: true, | |
underscored: true, | |
underscoredAll: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body { | |
background: #ececf0; | |
font-family: "Helvetica Neue", "Helvetica", "Arial", "sans-serif"; | |
text-rendering: optimizeLegibility !important; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createGlobalStyle } from 'styled-components'; | |
export default createGlobalStyle` | |
* { | |
margin: 0; | |
padding: 0; | |
outline: 0; | |
box-sizing: border-box; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Router } from 'react-router-dom'; | |
import history from './services/history'; | |
import Routes from './routes'; | |
function App() { | |
return ( | |
<Router history={history}> | |
<Routes /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = 24 | |
y = 99 | |
// Traditional way: | |
x = x + y | |
y = x - y | |
x = x - y | |
// if using ES6 this can be done using destructuring assignment array matching: | |
// [x, y] = [y, x] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* FizzBuzz algorithm | |
*/ | |
function checkMultiples(n) { | |
let result = ""; | |
result = n % 3 === 0 ? "Fizz" : result; | |
result = n % 5 === 0 ? result + "Buzz" : result; | |
return result !== "" ? result : n; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i = 0; i <= 3; i++) { | |
delay(i); | |
} | |
function delay(i) { | |
setTimeout(function() { | |
console.log(i); | |
}, 100); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomTimeout() { | |
const t = Math.floor(Math.random() * 3000 + 1); | |
return t; | |
} | |
const method1 = new Promise(resolve => { | |
timeout = randomTimeout(); | |
setTimeout(() => resolve("method1"), timeout); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomTimeout() { | |
const t = Math.floor(Math.random() * 3000 + 1); | |
return t; | |
} | |
// SetTimeout does not return a promise, so we can't await for it. This funcion promisify it mannualy. | |
function timeout(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} |
OlderNewer