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 rodando = false; | |
| var minhaFunc = function(){ | |
| if(rodando) | |
| return; // Já está rodando | |
| rodando = true; | |
| db.query('select 1 + 1 as result', function(err, result){ | |
| rodando = false; | |
| if(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
| // no arquivo1.js | |
| process.on('excluir', function(socket){ | |
| array_de_sockets.splice(socket.....); | |
| }); | |
| // no arquivo2.js | |
| if(tem_alguma_coisa_errada) | |
| process.emit('excluir', socket); |
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 SiteSchema = new Mongoose.Schema({ | |
| site: String, | |
| newLink: { | |
| tipe: String, | |
| index: { | |
| unique: 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
| // Biblioteca responsável pela conexão no banco de dados | |
| var level = require('levelup'); | |
| var config = require(__dirname + '/config'); | |
| var db = level(config.get('connection')); | |
| var conns = { | |
| _db: db // Para acesso direto ao LevelDB | |
| }; |
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
| // jshint node: true, strict: false | |
| var tls = require('tls'); | |
| // Configurações do servidor | |
| var config = { | |
| host: '****', | |
| port: 8080 | |
| }; | |
| // Dispara se o servidor não conectar em 5 segundos |
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
| /*! | |
| * Node.JS module "Deep Extend" | |
| * @description Recursive object extending. | |
| * @author Viacheslav Lotsmanov (unclechu) <lotsmanov89@gmail.com> | |
| * @license MIT | |
| * | |
| * The MIT License (MIT) | |
| * | |
| * Copyright (c) 2013 Viacheslav Lotsmanov | |
| * |
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 util = require('util'); | |
| module.exports = function getUrl(bucket, object, insegure){ | |
| return util.format('%s://%s.s3.amazonaws.com/%s', insecure? 'http' : 'https', bucket, object); | |
| } |
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
| // Load all files inside this folder with a single require | |
| var fs = require('fs'); | |
| var str = require('underscore.string'); | |
| var files = fs.readdirSync(__dirname); | |
| module.exports = {}; | |
| // Iterate over the files that we found, replace the name | |
| // require the file and exports it | |
| files = files.forEach(function(file){ |
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 express = require('express'); | |
| var app = expres(); | |
| var knox = require('knox'); | |
| // Criamos um cliente para conectar no S3 | |
| var s3 = knox.createClient({ | |
| key: 'di32jdouh329dhu2jdjed==' | |
| secret: 'dihuhdi2u3hdu3d9h23udh9382hd93=' | |
| bucket: 'ILoveYourNastyBucket' | |
| }); |
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
| $scope.form = $location.search().form; | |
| console.log($scope.form); |