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 hello () { | |
return new Promise((resolve) => { | |
setTimeout(() => resolve('Hello world!'), 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
var mongo = require('mongodb'); | |
var Grid = require('gridfs-stream'); | |
var Busboy = require('busboy'); | |
var express = require('express'); | |
var app = express(); | |
// Criar uma conexão | |
var db = new mongo.Db('seuBancoDeDados', new mongo.Server('127.0.0.1', 27017)); | |
var gfs = Grid(db, mongo); |
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 nsq = require('nsq') | |
const crypto = require('crypto') | |
module.exports = async (req, res) => { | |
async validarAuth(req.header.authentication) | |
// Depois de validar iniciar a escuta em uma fila única para essa request | |
const replyQueue = crypto.randomBytes(30).toString('hex') | |
nsq.on(replyQueue, data => { | |
res.json(data) |
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 path = require('path') | |
const glob = require('glob') | |
glob.sync('minha_pasta/**/arquivo.js').forEach(caminho => require(path.normalize(__dirname, caminho))) |
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
'use strict' | |
const crypto = require('crypto') | |
const db = require('../lib/db') | |
const email = require('../lib/email') | |
const HMAC_SECRET = 'here_be_dragons' | |
// Cria um link a prova de tampering | |
const nonce = crypto.randomBytes(256).toString('hex') |
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
// Imagine que esse ẽ o modulo1.js | |
var somar = function(a, b){ | |
return a + b; | |
}; | |
// Aqui estou dizendo para o require que ele pode usar | |
// a função que está linkada a esta variável | |
module.exports = somar; | |
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
'use strict' | |
let express = require('express') | |
let app = express() | |
function test () { | |
return typeof null === 'undefined' | |
} | |
let reqs = 0 |
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
var httpProxy = require('http-proxy'); | |
var proxy = httpProxy.createProxyServer(); | |
var http = require('http'); | |
var Mock = require('mock-req'); | |
var Busboy = require('busboy'); | |
var config = { | |
url: '/teste', // A rota a ser protegida | |
method: 'POST', // O método a ser protegido | |
content: 'multipart/form-data', // O tipo de conteúdo |
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
<div class="modal-dialog" style="width: 800px"> |
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
modal('show'); | |
setTimeout(function(){ | |
....replot() | |
}, 2000) |