Skip to content

Instantly share code, notes, and snippets.

View giovanniantonaccio's full-sized avatar
🎯
Focusing

Giovanni Antonaccio giovanniantonaccio

🎯
Focusing
  • CI&T
  • Brazil
View GitHub Profile
@giovanniantonaccio
giovanniantonaccio / index.js
Last active September 28, 2022 16:14
React scanner config file
#!/usr/bin/env node
const scanner = require("react-scanner");
const os = require("os");
const path = require("path");
const getLastItemFromPath = (thePath) => thePath.substring(thePath.lastIndexOf("/") + 1);
const userHomePath = os.homedir();
const projectPath = process.cwd();
@giovanniantonaccio
giovanniantonaccio / bumpme
Last active February 26, 2021 21:22
Concourse test
Fri Feb 26 21:21:58 UTC 2021
@giovanniantonaccio
giovanniantonaccio / vscode-material-ui-snippets
Created June 16, 2020 03:00
Snippets to create React Components with Material UI
{
"styles": {
"prefix": "muistyles",
"body": [
"import { Theme, makeStyles } from '@material-ui/core/styles';",
"",
"export const useStyles = makeStyles((theme: Theme) => ({",
" container: {},",
"}));",
""
@giovanniantonaccio
giovanniantonaccio / javascript.json
Created January 31, 2020 14:33
VS Code React Snippets
{
"useStateHook": {
"prefix": "s",
"body": [
"const[$1, use${1/(.*)/${1:/capitalize}/}] = useState($2);",
"$0"
],
"description": "Create useState hook"
},
"useStateHookVariables": {
@giovanniantonaccio
giovanniantonaccio / reset.css
Created September 23, 2019 17:41
Reset CSS
import { createGlobalStyle } from 'styled-components';
export default createGlobalStyle`
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap');
* {
margin: 0;
padding: 0;
outline: 0;
box-sizing: border-box;
@giovanniantonaccio
giovanniantonaccio / reset.css
Created September 23, 2019 17:41
Reset CSS
import { createGlobalStyle } from 'styled-components';
export default createGlobalStyle`
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap');
* {
margin: 0;
padding: 0;
outline: 0;
box-sizing: border-box;
@giovanniantonaccio
giovanniantonaccio / asyncAwaitTest.js
Last active September 20, 2019 17:49
This gist simulates the execution of two async methods using async/await. It returns a message of success when both complete. A random timeout between 1 and 3000ms is being used.
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));
}
@giovanniantonaccio
giovanniantonaccio / promiseTest.js
Last active September 20, 2019 17:46
This gist simulates the execution of two async methods using promises. It returns a message of success when both complete. A random timeout between 1 and 3000ms is being used.
function randomTimeout() {
const t = Math.floor(Math.random() * 3000 + 1);
return t;
}
const method1 = new Promise(resolve => {
timeout = randomTimeout();
setTimeout(() => resolve("method1"), timeout);
});
@giovanniantonaccio
giovanniantonaccio / loopfix.js
Created September 20, 2019 14:32
SetTimeout Loop Fix
for (var i = 0; i <= 3; i++) {
delay(i);
}
function delay(i) {
setTimeout(function() {
console.log(i);
}, 100);
}
@giovanniantonaccio
giovanniantonaccio / fizzbuzz.js
Created September 20, 2019 14:04
FizzBuzz algorithm
/**
* FizzBuzz algorithm
*/
function checkMultiples(n) {
let result = "";
result = n % 3 === 0 ? "Fizz" : result;
result = n % 5 === 0 ? result + "Buzz" : result;
return result !== "" ? result : n;
}