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/workshop-novembro'); | |
var db = mongoose.connection; | |
db.on('error', function(err){ | |
console.log('Erro de conexao.', err) | |
}); | |
db.once('open', function () { |
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
// In this case it is a simple value service. | |
angular.module('myApp.services', ['firebase']). | |
value('version', '0.1') | |
// Serviço criado para persistir dados no firebase, | |
// com a possibilidade de ser a propria persistencia em base de dados como mongodb etc.. | |
.service('Firebase', function($rootScope, $firebase) { | |
return { | |
url: 'https://myurl.firebaseio.com', |
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 str = 'https://www.youtube.com/watch?v=iG6yKgnTrgo'; | |
var youtubeId = str.indexOf('v='); | |
var limit = str.indexOf('&') | |
if (limit < 0) { | |
var stringYoutube = str.slice(youtubeId + 2); | |
} else { | |
var stringYoutube = str.slice(youtubeId + 2, limit); | |
} | |
alert(stringYoutube); |
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
Article.find() | |
.where('tripleSpotlight').equals('true') | |
.where('columnist').equals('null') | |
.sort({'date.created': 'desc'}).limit(3).exec (err, inlineSpotlights)-> #first created to last created | |
a = new Array | |
idx = 0 | |
inlineSpotlights.forEach (item)-> | |
item = item.toObject() | |
category.model.findOne({'id':item.category}).exec (err, categories)-> |
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
# Stop using callback, alternative is async | |
# http://webapplog.com/seven-things-you-should-stop-doing-with-node-js/?utm_source=nodeweekly&utm_medium=email | |
async.series [ | |
(callback)-> | |
# Find store based on store property returned from xml | |
Store.model.findOne({id: 'hstern'}).exec (err, store)-> | |
callback err, store |
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
// This script will boot app.js with the number of workers | |
// specified in WORKER_COUNT. | |
// | |
// The master will respond to SIGHUP, which will trigger | |
// restarting all the workers and reloading the app. | |
var cluster = require('cluster'); | |
var workerCount = process.env.WORKER_COUNT || 2; | |
// Defines what each worker needs to run |
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
# checking concurrent connections using Siege as HTTP load testing | |
# http://blog.remarkablelabs.com/2012/11/benchmarking-and-load-testing-with-siege | |
http = require 'http' | |
http.globalAgent.maxSockets = 20 | |
server = http.createServer (req, res)-> | |
res.end 'hi!' |
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
// This script will boot app.js with the number of workers | |
// specified in WORKER_COUNT. | |
// | |
// The master will respond to SIGHUP, which will trigger | |
// restarting all the workers and reloading the app. | |
var cluster = require('cluster'); | |
var workerCount = process.env.WORKER_COUNT || 2; | |
// Defines what each worker needs to run |
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
return { | |
scannerAvailable: false, | |
scanner: null, | |
isEnabled: function() { | |
if ('plugins' in window && 'barcodeScanner' in window.plugins) { | |
scanner = window.plugins.barcodeScanner; | |
} |
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 jsftp = require("jsftp"); | |
var Ftp = function($host, $port, $user, $pass) { | |
this.instance = null; | |
this.host = $host; | |
this.port = $port; | |
this.user = $user; | |
this.pass = $pass; | |
} |
OlderNewer