Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Hugo Roca HugoRoca

🏠
Working from home
View GitHub Profile
@HugoRoca
HugoRoca / aggregation_lookup.md
Created May 18, 2020 — forked from bertrandmartel/aggregation_lookup.md
MongoDB $lookup aggregation example
View aggregation_lookup.md

MongoDB $lookup aggregation

SO link

db.votes.aggregate([{
    $lookup: {
        from: "users",
        localField: "createdBy",
        foreignField: "_id",
View connection-mongo.js
/*
logger: {
connectionString: "mongodb+srv://usrmongotdapp:Mongo2018@personalizacionqas-xfhrx.mongodb.net",
database: "StreamLog",
collection: "Logs",
defaultSource: "lb.estrategia",
enableLogInfo: true,
enableLogError: true
}
*/
View redisGet.js
"use strict";
const redisConnection = require("./redis-connection");
const redis = new redisConnection();
(async () => {
try {
let rr = await redis.get("dataPrueba");
console.log(rr);
} catch (error) {
@HugoRoca
HugoRoca / redisSet.js
Last active Dec 25, 2018
REDIS - set
View redisSet.js
"use strict";
const redisConnection = require("./redis-connection");
const redis = new redisConnection();
(async () => {
try {
// Para este caso haremos uso de un JSON, tambien se puede guardar string, int, double, etc.
let data = [{
"_id": "5c21d04d34b4a04750f9aa6f",
@HugoRoca
HugoRoca / redis-connection.js
Created Dec 25, 2018
REDIS - connection IORedis
View redis-connection.js
"use strict";
const redis = require("ioredis");
const config = require("./config");
module.exports = class RedisConnection {
constructor() {
this.client = this.connect();
}
@HugoRoca
HugoRoca / config.js
Last active Dec 25, 2018
REDIS - configuración
View config.js
const config = {
redis: {
port: 6379,
host: "localhost",
retries: 3,
time_to_retry: 100,
time_live: 3600 // tiempo de vida en segundos
}
}
View package.json
{
"name": "[nombre]",
"version": "[versión]",
"description": "[descripción]",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Hugo Roca - hugo.rock20@hotmail.com",
"license": "[licencia]"
@HugoRoca
HugoRoca / autocomplete a partir de una letra
Created Jul 9, 2018
Se autocompleta a partir de una letra en especifica, sirve para correos "@", etc..
View autocomplete a partir de una letra
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
box-sizing: border-box;
}
body {
font: 16px Arial;
@HugoRoca
HugoRoca / number2decimal
Last active Jun 4, 2018
Función para convertir un numero a 2 decimales
View number2decimal
// validación para poner a decimales
var formatNumber = {
separador: ",",
sepDecimal: '.',
formatear: function (num) {
num += '';
var splitStr = num.split('.');
var splitLeft = splitStr[0];
var splitRight = splitStr.length > 1 ? this.sepDecimal + splitStr[1] : '';
var regx = /(\d+)(\d{3})/;
You can’t perform that action at this time.