This file contains hidden or 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 multer = require('multer') | |
const express = require('express') | |
const storage = multer.diskStorage({ | |
destination: (req, file, cb) => { | |
cb(null, 'files/tmp') | |
}, | |
filename: (req, file, cb) => { | |
if(['jpg','jpeg','png', 'octet-stream'].includes(file.mimetype.split('/')[1].toLocaleLowerCase())){ | |
cb(null, Date.now()+"_"+file.originalname ) |
This file contains hidden or 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 socket=new WebSocket('ws://localhost:3000/seuToken') | |
socket.onerror = error=>console.log(error) | |
socket.onclose = closeData=console.log(closeData) | |
socket.onmessage = ({data})=>console.log(data) | |
socket.send('minha mensagem') |
This file contains hidden or 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
/* | |
não se esqueça de instalar o nodemon globalmente mas nada te impede de instala-local :) | |
$ npm i --save express express-ws | |
$ nodemon app | |
*/ | |
const express = require('express') |
This file contains hidden or 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
<?php | |
if ( ! class_exists( 'WP_CLI' ) ) { | |
return; | |
} | |
/** | |
* Load WP-CLI Commands, checking if environment supports commands. | |
* | |
* @see /cli/README.md for instructions on registering new commands. |
This file contains hidden or 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 () { | |
'use strict'; | |
let popEstimada = document.querySelector("#pop_estimada"); | |
function defaultMethod() { | |
const myMap = L.map('map').setView([-21.99, -43.00], 8); // Setado Juiz de Fora apenas para centralizar um pouco o Rio de Janeiro | |
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { | |
maxZoom: 22, |
This file contains hidden or 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') | |
const moment = require('moment') | |
const errors = (err, res) => { | |
if(!err)return false | |
const logName = moment().format('DD_MM_YYYY-HH_mm_ss_SSS') + '.txt' | |
if(res){ | |
res.status(500).json({status: false, message: "Erro interno no servidor, log disponível apneas no servidor em /logs/errors/DATA_HORA_MILLESEGUNDOS.txt"}) | |
} | |
fs.writeFile(__dirname + '/../logs/errors/' + logName, err.stack || err, err=>{ |
This file contains hidden or 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
<?php | |
@$files = $_FILES['files']; // aqui eu pego todos os arquivos que estiverem no campo files | |
@$name = $_POST['name']; // aqui eu pego o campo com o name="name" do formulário | |
$returnJson = array(); | |
if($files){ | |
array_push($returnJson, $files); | |
//var_dump($files); | |
} | |
if($name){ | |
array_push($returnJson, $name); |
This file contains hidden or 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
export const download = async (params = {}) => { | |
const caching = await fetch(params.url, params) | |
const fileName = caching.headers.get('Content-Disposition') | |
const ext = fileName.split('.')[fileName.split('.').length - 1].replace('"', '') | |
const blob = await caching.blob() | |
const url = await URL.createObjectURL(blob) | |
const a = document.createElement("a"); | |
a.href = url | |
a.download = `Reports.${ext}` | |
a.click() |