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 inputs = ['cat', 'dog', 'tca', 'tac', 'cat']; | |
const sortString = (word) => { | |
return word.split('').sort().join(''); | |
} | |
// build ((2M + M * log(M)) * n) = (NM * log(M) + NM) | |
// clear N | |
// cast 2 N | |
// total = (NM * log(M) + NM) + 3N |
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 checkSchema = (schema, type) => { | |
for (let i in schema) { | |
if (schema[i][0] === type) { | |
return schema[i][2]; | |
} | |
} | |
}; | |
const checkTelefone = (result, fact) => { | |
if (fact[1] === 'telefone') { | |
if (fact[2].length === 10) { |
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
let RUN =32; | |
// this function sorts array from left index to | |
// to right index which is of size atmost RUN | |
const insertionSort=(arr, left, right)=>{ | |
for (let i = left + 1; i <= right; i++) | |
{ | |
let temp = arr[i]; | |
let j = i - 1; | |
while (arr[j] > temp && j >= left) |
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
//Register New Scanners | |
app.post('/api-iot/scanners/insert', function (req, res) { //rota definida como "/api-iot/scanners" e metodo de requisição definido como post | |
// res.setHeader("Access-Control-Allow-Origin", "*"); | |
console.log("Post beacons into DB"); //log para informar que chegou neste função | |
var data = req.body; //está capturando a informação do body da aplicação. | |
console.log("Scanners:" + JSON.stringify(data)); //mostrando no console qual a informação que está chegando. | |
db.open(function (err, mongocliente) { //abrindo conexão com o banco | |
mongocliente.collection('scanners', function (err, collection) { //selecionando a coleção scanners. | |
collection.findOne({"addr": data.addr}).then(function (sucess) { |