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 media(...arguments) { | |
total = arguments.reduce((a,b) => a+b); | |
return total/arguments.length; | |
} | |
console.log(media(12,6,6,3)); |
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 fs = require('fs') | |
let texto = 'Coffee is life!' | |
const escreve = (file, texto) => new Promise((resolve, reject) => fs.writeFile(file, texto, (err) => err ? reject(err) : resolve())) | |
escreve('teste.txt', texto) | |
.then(() => console.log('Deu certo..')) | |
.catch(() => console.log('Deu ruim... TRATAR')) |
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 ChipInput from 'material-ui-chip-input' | |
class Chip extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
chips: [], | |
limit: 3 | |
} |
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 request = require('request') | |
const [comand, path, ...urls] = [...process.argv] | |
const searchs = [] | |
const searchHttp = (url) => new Promise((resolve, reject) => | |
request(url, (err, response, body) => err ? reject(err) : resolve(body))) | |
urls.map((url) => searchs.push(searchHttp(url))) | |
Promise.all(searchs).then((results) => |
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
//Dockerfile | |
FROM node:8.4.0 | |
ENV HOME=/home/app | |
COPY package.json $HOME/node_todo/ | |
WORKDIR $HOME/node_todo | |
RUN npm install --silent --progress=false |
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 channels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"]; | |
const colorsListItem = ["--yellow", "--coral", "--purple"]; | |
// Showing channel names and adding colored item | |
for(i=0;i<channels.length;i++){ | |
// Creating random value for item color | |
function randomColor(){ | |
number = Math.floor(Math.random()*colorsListItem.length); | |
color = colorsListItem[number]; |
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 ThousandsSeparatorRegex = () => { | |
const format = (value, separator = ',') => { | |
const formatToThousands = (str, formater = ',') => str.toString().replace(/\B(?=(\d{3})+(?!\d))/g, formater); | |
if (value >= 0 || (value.length >= 0 && value.length <= 15)) { | |
const formatedThousands = formatToThousands(value, separator); | |
return formatedThousands; | |
} else if (value < 0) { | |
const formatedThousands = formatToThousands(value, separator); | |
return formatedThousands; |
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 server = require('net').createServer(); | |
const sockets = {}; | |
let counter = 0; | |
server.on('connection', socket => { | |
socket.id = counter++; | |
console.log('Client connected!'); | |
socket.write('Please type your name: '); |
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 showPhrase() { | |
phrase = 'JavaScript é sensacional!'; | |
console.log(phrase); | |
} | |
showPhrase(); // JavaScript é sensacional! | |
console.log(phrase); // JavaScript é sensacional! |
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 showPhrase() { | |
if (true) { | |
let phrase = 'JavaScript é sensacional!'; | |
console.log(phrase); // JavaScript é sensacional! | |
} | |
console.log(phrase); // prhase is not defined | |
} | |
showPhrase(); |
OlderNewer