Skip to content

Instantly share code, notes, and snippets.

View wescleymatos's full-sized avatar
:octocat:
I'm ready!

Wescley Matos wescleymatos

:octocat:
I'm ready!
View GitHub Profile
const produtos = [
{
nome: 'Bicicleta',
preco: 1200.0
},
{
nome: 'Capacete',
preco: 450.0
}
]
const produtos = [
{
id: 1,
preco: 10.0,
qtd: 2
},
{
id: 2,
preco: 10.0,
qtd: 2
const fs = require('fs')
const path = './'
function readdirPromise(path) {
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => {
if (err) {
reject(err);
} else {
resolve(files);
const fs = require('fs')
const path = './'
function readdirPromise(path) {
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => {
if (err) {
reject(err);
} else {
resolve(files);
const fs = require('fs')
const path = './'
function readdirPromise(path) {
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => {
if (err) {
reject(err);
} else {
resolve(files);
const express = require('express')
const app = express()
const port = 3000
app.get('/somar', (request, response) => {
let soma = (parseInt(request.query.num1) + parseInt(request.query.num2))
response.end(`A soma é ${soma}`);
});
<snippet>
<content><![CDATA[public function get${1/(.*)/\u$1/}()
{
return \$this->${1:$SELECTION};
}
public function set${1/(.*)/\u$1/}(\$$1)
{
return \$this->$1 = \$$1;
}
@wescleymatos
wescleymatos / es7-async-await.js
Created September 27, 2017 06:31 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@wescleymatos
wescleymatos / thinced.js
Created October 2, 2017 20:03 — forked from varmais/thinced.js
Geolocation to Promise wrap example
var getPosition = function (options) {
return new Promise(function (resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
getPosition()
.then((position) => {
console.log(position);
})
@wescleymatos
wescleymatos / observer.js
Created October 20, 2017 16:37
Aplicação do padrão Observer com Javascript
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<p></p>
<button id="btn-1" type="button">observar</button>