Skip to content

Instantly share code, notes, and snippets.

💻
👨‍💻 😄

Hugo Roca HugoRoca

💻
👨‍💻 😄
Block or report user

Report or block HugoRoca

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
}
*/
@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",
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 / 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.