Skip to content

Instantly share code, notes, and snippets.

View zrobit's full-sized avatar

zrobit ⚡️ zrobit

View GitHub Profile
//NPM: instalar solo dependencia de desarrollo
npm install --only=dev
//NPM instalar solo dependencias de produción
npm install --production

2.147.483.647

var $ = require('jquery');
var salvattore = require('../libs/salvattore.js');
var tim = require('./tim.js');
var $window = $(window);
var $header = $('.header');
var waiting = false, endScrollHandle;
var $grid = $('.cards-pic');
var delta;
@zrobit
zrobit / authController.js
Created February 7, 2017 14:44
simple config for passport and express
router.post('/login', passport.authenticate('local-login', {
successRedirect: '/',
failureRedirect: '/login',
failureFlash: true
}));
// load all the things we need
// http://scotch.io/series/easy-node-authentication
var LocalStrategy = require('passport-local').Strategy;
var FacebookStrategy = require('passport-facebook').Strategy;
var TwitterStrategy = require('passport-twitter').Strategy;
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
// load up the user model
var User = require('../app/models/user');
@zrobit
zrobit / randomUtils.js
Created February 2, 2017 18:19
Random Two values
function randomTwoValues(val1, val2){
return Math.random() < 0.5 ? val1 : val2;
}
@zrobit
zrobit / hash-id-simple.js
Created February 2, 2017 02:34
KISS hash generetor (don't use if avoid hash collision is super necessary)
const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const LENGTH = 8;
function hash() {
let tmp = '';
for (let i = 0; i < LENGTH; i++) {
tmp += ALPHABET.charAt(Math.floor(Math.random() * ALPHABET.length));
}
return tmp;
@zrobit
zrobit / after_res_hooks.js
Created January 31, 2017 15:20 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@zrobit
zrobit / netflix-ids.txt
Last active September 27, 2018 16:39
https://www.netflix.com/browse/genre/{id} netflix códigos que desbloquean géneros
1365 = Action & Adventure
77232 = Asian Action Movies
46576 = Classic Action & Adventure
43040 = Action Comedies
43048 = Action Thrillers
@zrobit
zrobit / time-process.js
Created January 21, 2017 21:03
Calcular el tiempo de ejecución de un script en nodejs
function Hello(){
console.log('execute something');
return null;
}
let hrStart = process.hrtime()
//script o lo que sea a ser medido por hrtime
hello()
let hrEnd =process.hrtime(hrStart)
console.info("Execution time (hr): %ds %dms", hrEnd[0], hrEnd[1]/1000000)