Skip to content

Instantly share code, notes, and snippets.

View victorkurauchi's full-sized avatar
🎯
Focusing

Victor Kurauchi victorkurauchi

🎯
Focusing
View GitHub Profile
@victorkurauchi
victorkurauchi / beer Js
Created November 16, 2013 19:04
beer.js ~ implementação de insert com mongoose/express
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 () {
@victorkurauchi
victorkurauchi / angularfirebase.js
Last active January 2, 2016 15:18
Angular Firebase Service
// 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',
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);
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)->
# 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 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
# 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 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
return {
scannerAvailable: false,
scanner: null,
isEnabled: function() {
if ('plugins' in window && 'barcodeScanner' in window.plugins) {
scanner = window.plugins.barcodeScanner;
}
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;
}