Skip to content

Instantly share code, notes, and snippets.

View HugoRoca's full-sized avatar
🏠
Working from home

Hugo Roca HugoRoca

🏠
Working from home
View GitHub Profile
@HugoRoca
HugoRoca / number2decimal
Last active June 4, 2018 18:40
Función para convertir un numero a 2 decimales
// 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})/;
@HugoRoca
HugoRoca / autocomplete a partir de una letra
Created July 9, 2018 21:52
Se autocompleta a partir de una letra en especifica, sirve para correos "@", etc..
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
box-sizing: border-box;
}
body {
font: 16px Arial;
{
"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 / config.js
Last active December 25, 2018 06:46
REDIS - configuración
const config = {
redis: {
port: 6379,
host: "localhost",
retries: 3,
time_to_retry: 100,
time_live: 3600 // tiempo de vida en segundos
}
}
@HugoRoca
HugoRoca / redis-connection.js
Created December 25, 2018 06:55
REDIS - connection IORedis
"use strict";
const redis = require("ioredis");
const config = require("./config");
module.exports = class RedisConnection {
constructor() {
this.client = this.connect();
}
@HugoRoca
HugoRoca / redisSet.js
Last active December 25, 2018 16:35
REDIS - set
"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 / redisGet.js
Created December 25, 2018 16:35
REDIS - get
"use strict";
const redisConnection = require("./redis-connection");
const redis = new redisConnection();
(async () => {
try {
let rr = await redis.get("dataPrueba");
console.log(rr);
} catch (error) {
/*
logger: {
connectionString: "mongodb+srv://usrmongotdapp:Mongo2018@personalizacionqas-xfhrx.mongodb.net",
database: "StreamLog",
collection: "Logs",
defaultSource: "lb.estrategia",
enableLogInfo: true,
enableLogError: true
}
*/
@HugoRoca
HugoRoca / aggregation_lookup.md
Created May 18, 2020 01:16 — forked from bertrandmartel/aggregation_lookup.md
MongoDB $lookup aggregation example

MongoDB $lookup aggregation

SO link

db.votes.aggregate([{
    $lookup: {
        from: "users",
        localField: "createdBy",
        foreignField: "_id",
select * from ['material-PA$']
update ['material-PA$'] set Categoría = 'Maquillaje' where Categoría = 'MAQUILLAJE'
update ['material-PA$'] set Categoría = 'Fragancias' where Categoría = 'FRAGANCIAS'
update ['material-PA$'] set Categoría = 'Tratamiento Facial' where Categoría = 'TRATAMIENTO FACIAL'
update ['material-PA$'] set Categoría = 'Cuidado Personal' where Categoría = 'CUIDADO PERSONAL'
-- que todos tengan la extención
update ['material-PA$'] set Miniatura = 'Portada Antibacterial(1).jpg' where Miniatura = 'Portada Antibacterial(1)'