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 http = require('http'); | |
const httpProxy = require('http-proxy'); | |
const proxy = httpProxy.createProxyServer({ | |
target: { | |
host: 'pulsar-host', | |
port: 8080 | |
} | |
}); |
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
https://8811d579.ngrok.io/lesson/5ea876762d3a5a5aafaaa543 |
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
extern crate actix; | |
extern crate tokio; | |
use actix::io::{WriteHandler, Writer}; | |
use actix::prelude::*; | |
use actix::{Actor, Addr, Context, Handler, Syn}; | |
use tokio::io; | |
use tokio::io::{ReadHalf, WriteHalf}; | |
use tokio::net::{TcpListener, TcpStream}; | |
use tokio::prelude::stream::Stream; |
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 rust = require('rustify'); | |
const wasm = rust` | |
use std::ffi::{CString}; | |
use std::os::raw::{c_char}; | |
#[no_mangle] | |
pub extern "C" fn str_len(ptr: *mut c_char) -> usize { | |
unsafe { | |
let string = CString::from_raw(ptr); | |
string.to_bytes().len() |
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
async function fazerAlgo() { | |
const resposta = await request('https://google.com.br') | |
await fs.writeFile('resposta.html', resposta) | |
const resposta2 = await request('https://facebook.com') | |
await fs.writeFile('resposta2.html', resposta2) | |
console.log('Todas as respostas foram salvas!') | |
} |
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 semaforo = 0 | |
var valores = ['hello', 'world'] | |
function callback () { | |
semaforo-- | |
if (semaforo === 0) { | |
console.log('Acabou tudo o que tinha pra fazer, vou finalizar') | |
process.exit() | |
} else { |
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') | |
/** | |
* Encripta dados utilizando o cipher camellia256 | |
* @param {String} data dados a serem encriptados | |
* @param {String} encoding utf8, base64 ou hex | |
* @param {String} output base64 ou hex | |
* @return {String} O resultado da encriptação com o output selecionado |
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
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))) |
NewerOlder