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
| void alterarValor(int x){ | |
| x = x + 2; | |
| } | |
| int main(){ | |
| int x = 4; | |
| int *endereco_de_x = &x; //repare nesta linha | |
| printf("x está armazenada em %p \n\n", endereco_de_x); //e nesta também | |
| //x está armazenada em 0x7fff69032c24 |
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
| void alterarValor(int* x){ //repare nesta linha, recebemos um endereço | |
| *x = *x + 2; | |
| } | |
| int main(){ | |
| int x = 4;//x armazenada em `stack` | |
| int *endereco_de_x = &x; | |
| printf("x está armazenada em %p \n\n", endereco_de_x); | |
| //x está armazenada em 0x7fff69032c24 |
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
| var mongoose = require("mongoose"); | |
| mongoose.set('debug', true); | |
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
| var mongoose = require("mongoose"); | |
| mongoose.set('debug', true); | |
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
| app.use(express.cookieParser()); | |
| app.use(express.session({ secret: '1234' })); | |
| app.use(app.router); |
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
| var municipioSchema = new Schema({ | |
| nome: { type: String, required: true, trim: true }, | |
| estado: { type: String, required: true } | |
| }, { versionKey: false }); //remove a chave de versionamento | |
| var municipioSchema = new Schema({ | |
| nome: { type: String, required: true, trim: true }, | |
| estado: { type: String, required: true } | |
| }, { versionKey: "versao" }); //renomeia a chave de versionamento |
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
| var crypto = require('crypto'); | |
| var assert = require('assert'); | |
| var algorithm = 'aes256'; // or any other algorithm supported by OpenSSL | |
| var key = 'password'; | |
| var text = 'this is a secret'; | |
| var cipher = crypto.createCipher(algorithm, key); | |
| var encrypted = cipher.update(text, 'utf8', 'hex') + cipher.final('hex'); |
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
| var mongoose = require("mongoose"); | |
| mongoose.connect("mongodb://localhost/basededados?w=1"); | |
| mongoose.connection.db.executeDbCommand({ ping: 1 }, {}, function(err, result){ | |
| if(err) console.log(err); | |
| else console.log(result); | |
| }); |
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 formatarChaveDeAcessoNfe(chave){ | |
| if(chave.length !== 44) return chave; | |
| else{ | |
| return chave.split("").reduceRight(function(elemento, anterior){ | |
| var temp = anterior + elemento; | |
| if(temp.replace(/\s/g, "").length % 4 === 0) return " " + temp; | |
| else return temp; | |
| }); | |
| } | |
| } |
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
| //valor: | |
| // string contendo os números a terem seu mod11 calculado. | |
| //restornarResto: | |
| // boleano indicando se deve ser retornado o apenas o resto do multiplicatório ou o resultado da subtração por 11. | |
| //multiplicadores: | |
| // conjunto de números que multiplicarão ciclicamente o valor de entrada. | |
| function mod11(valor, retornarResto, multiplicadores){ |