Skip to content

Instantly share code, notes, and snippets.

View thihenos's full-sized avatar

Thiago Silva thihenos

View GitHub Profile
/*
* Sync all tables to database
*/
db.sequelize.sync({force:true}).then(function(){
console.log('DB Connection - OK');
let crypto = require('crypto');
//Lib for crypting strings
let crypto = require('crypto');
//Creating my cipher, by using the key REPLACE_YOUR_KEY_HERE
<!-- This is assuming that this document will get in folder Layout, the dust file layout as it template -->
{>"layout/layout" /}
<!-- This variable, is responsable for get all HTML content and compile it together with the {+body /} in layout file-->
{<body}
<div class="row"><br></div>
<main role="main" class="container">
<div class="jumbotron">
<h1><p><strong>Here it is my second dust file!</strong></p></h1>
@thihenos
thihenos / convertFileToBitSave.js
Last active June 30, 2018 20:23
Example for medium procedure
/*
* Example with one file upload
* In this example, inside single() function, we use the name of the name of the element in the html
* which we are sending the post, in this case, it is called file ( check line 19 of file.dust file )
*/
app.post('/file', upload.single('file'),function(req, res) {
//res.json(req.file);
if(req.file){
//Reading the file saved in src/temp folder
let fileContent = base64_encode(req.file.filename);//sendind filename which Multer gives
var fs = require('fs');
//Convertendo binario em arquivo
function base64_decode(base64str,fileName){
var bitmap = new Buffer (base64str, 'base64');
fs.writeFileSync('src/temp/'+fileName+'',bitmap, 'binary', function (err){
if(err){
console.log('Conversao com erro');
}