miércoles, 29 de abril de 2020

Validar contraseña fuerte

En los sistemas actuales, incluso no solos los web, es muy usual, que las calves de los usuarios para acceder contengan valores que sean difícil de poder ser descubiertas por personas y algoritmos que se encargan de descifrar la contraseña.
En el ejemplo que a continuación les brindamos, es un sencillo algoritmo en lenguaje javascript, utilizando las funciones nativas del propio lenguaje, podremos validar que una contraseña ingresada cumpla con los requerimientos de una contraseña fuerte.
Primeramente los criterios que tomaremos para validar que la contraseña sea fuerte son los siguientes:
  • Tiene ocho caracteres como mínimo.
  • Letras mayúsculas.
  • Letras minúsculas.
  • Números.
  • Símbolos del teclado (todos los caracteres del teclado que no se definen como letras o números) y espacios.
Para el proceso de validación se utiliza el código ASCII, comparimos en el siguiente enlace la tabla de ASCII de la wikipedia: códigos ASCII.
para conocer el código ASCII de un carácter de una cadena en javascript utilizamos la función: charCodeAt
A continuación la función en javascript:

 function validar_clave(contrasenna)
  {
   if(contrasenna.length >= 8)
   {  
    var mayuscula = false;
    var minuscula = false;
    var numero = false;
    var caracter_raro = false;
    
    for(var i = 0;i<contrasenna.length;i++)
    {
     if(contrasenna.charCodeAt(i) >= 65 && contrasenna.charCodeAt(i) <= 90)
     {
      mayuscula = true;
     }
     else if(contrasenna.charCodeAt(i) >= 97 && contrasenna.charCodeAt(i) <= 122)
     {
      minuscula = true;
     }
     else if(contrasenna.charCodeAt(i) >= 48 && contrasenna.charCodeAt(i) <= 57)
     {
      numero = true;
     }
     else
     {
      caracter_raro = true;
     }
    }
    if(mayuscula == true && minuscula == true && caracter_raro == true && numero == true)
    {
     return true;
    }
   }
   return false;
  }




Puedes descarga el ejemplo en el siguiente enlace: descargar ejemplo de validar contraseña fuerte.

martes, 28 de abril de 2020

Servidor Nginx Multidominio


video ->  https://www.youtube.com/watch?v=Qkk235ewXZw

-- Crear los archivos  o clonar en esta direccion (deploy) en :

cd /var/www/

--Ahora creamos los dominios (COPIAMOS LO MISMO QUE TIENE EL ARCHIVO 'default') en :

cd /etc/nginx/sites-available/

-- CHAT2
cp default www.thesnipersoft.com

-- mihogar01
cp default www.devsoft2018.online

-- bien ahora modificaremos los archivos que creamos (DOMINIO)

server {
    listen 80;
    #
    root /var/www/chat2 --> ESTO ES UN EJEMPLO..

    server_name www.thesnipersoft.com;

    location / {
        proxy_pass http://APP_PRIVATE_IP_ADDRESS:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

        #para el refresh (para cuando tengamos una pagina con rutas no nos mande a default 404)
        #(puede ser index.php.. etc..)
        try_files $uri $uri/ /index.html;
    }
}

-- MUY BIEN ahora hacemos que esos archivos se unan de available a enabled

ln -s /etc/nginx/sites-available/www.devsoft2018.online /etc/nginx/sites-enabled/www.devsoft2018.online

--POR ULTIMO Y MUY IMPORTANTE  REINICIAR EL SERVIDOR NGINX

service nginx reload


---
git clone https://thiago18@bitbucket.org/snewapp/01-pushapp-front.git 'push'

git clone https://thiago18@bitbucket.org/snewapp/02-notices-front.git 'noty'



martes, 21 de abril de 2020

Series Gratis

SERIE SUITS (la ley de los audaces): 
9 temporadas, trama abogados

SERIE SCOPION: 
4 temporadas, trama genios

SERIE LA CASA DE PAPEL: 
4 temporadas, trama atraco


SERIE MR ROBOT:
5 temporadas, trama hacker

SERIE SILICON VALLEY:
6 temporadas, trama tecnologia
https://www.youtube.com/watch?v=dNn1ocho3R0&list=WL&index=2&t=0s

https://descarga-todo-digital-mega-series.blogspot.com/2019/10/descargar-silicon-valley-temporada-6-latino-descargar-mega-series-hd.html

LINK DESCARGAS:
scropion, la casa de papel.
https://serieslatinotheg3n4r0.blogspot.com/

lunes, 13 de abril de 2020

Exportar en Excel con Papaparse

Referencia para agregar

https://www.npmjs.com/package/ngx-papaparse

1. instalar con npm

2. agregar al modulo donde se va usar

3. importar e inyectar en componente
import { Papa } from 'ngx-papaparse';
constructor(
public _posts: QuestionaryService,
private router: Router,
private papa: Papa,
) {
4. codigo de referencia:
el array de datos es tal cual lo recibe con una consulta de api-rest
//31-03-2020
exportCVS(){
var data = JSON.parse(JSON.stringify(this.dataList));
var data = data.map(item=>{

item.category_theme = item.category_theme.description;
item.files = item.files.map(item2=>{
return {
'Index': 'Index: '+ item2.index_content + '\n',
'Content': 'Content body: ' + item2.description,
}
});
item.files = this.papa.unparse( item.files, { header: false });

return {
'Theme': item.title,
'Category_Theme' : item.category_theme,
'Description': item.description,
'Content': item.files,
'Status' : item.status ? 'Active' : 'Inactive',

};
});

this.export( data, "Question"+ "_" + Date.now() );
};

//31-03-2020
async export( dataList:any, nameFile: string ){
try {
let csv = this.papa.unparse( dataList );
var blog = new Blob([csv]);
var a = window.document.createElement("a" );
a.href = window.URL.createObjectURL(blog);
a.download = nameFile + '.csv';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} catch (e) { console.error('error', e); }
};

domingo, 12 de abril de 2020

Generar PDF en angular / ionic

Documentacion oficial PDFmake:
https://pdfmake.github.io/docs/getting-started/client-side/
Instalar: npm install pdfmake
Codigo reutilizable:
import pdfMake from "pdfmake/build/pdfmake";
import pdfFonts from "pdfmake/build/vfs_fonts";
pdfMake.vfs = pdfFonts.pdfMake.vfs;
var pdfObject;
// https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Object/values
// https://pdfmake.github.io/docs/getting-started/
import * as moment from 'moment'
// let dateCurrent = moment(data.created_at).format('DD-MM-YYYY')
import { appConfig as env } from 'src/app/global/app.config';
import { isNullOrUndefined } from 'util';
//09-04-2020
export function mappingHeader( arrHeader ){
return arrHeader.map(item=>{
return {
text: item,
style: 'tableHeader'
};
});
};
//12-04-2020
function mappingBody( arrBody ){
return arrBody.map( item=>Object.values(item) );
};
//12-04-2020
function styleTable(){
return {
header: {
fontSize: 18,
bold: true,
margin: [0, 0, 0, 10]
},
subheader: {
fontSize: 16,
bold: true,
margin: [0, 10, 0, 5]
},
tableExample: {
margin: [0, 5, 0, 15]
},
tableHeader: {
bold: true,
fontSize: 13,
color: 'black'
}
};
}
//12-04-2020
export function _exportPDF( arrData:Array<any>,arrHeaderCustom?:Array<string>, title?:string,subtitle?:string ){
try {
var arrHeader:Array<string>;
if( isNullOrUndefined(arrHeaderCustom) ) arrHeader = Object.keys(arrData[0]);
else arrHeader = arrHeaderCustom;
arrHeader = mappingHeader( arrHeader );
arrData = mappingBody( arrData );
// console.log( arrData, arrHeader );
let obj:Array<any> = [
{ text: title , style: 'header'},
{ text: [ subtitle ], color: 'gray', italics: true },
{ table: {
headerRows: 1,
/* widths: ['*', 'auto'], widths: [ '*', 'auto', 100, '*' ],*/
body: [ arrHeader ]
}, style: 'tableExample',
},
];
for (const item of arrData ) {
obj[2].table.body.push( item );
}
var dd = {
pageOrientation: 'landscape',
pageMargins: [ 20, 30, 20, 30 ],
content: obj,
styles: styleTable()
};
pdfObject = pdfMake.createPdf( dd );
pdfObject.download();
} catch (err) {
console.error( 'Error al generar pdf', err );
}
};
===================
MODO DE USO EN COMPONENTES
//IMPORTAR
import { _exportPDF } from 'src/app/core/utils/table_pdf';
// 12-04-2020
exportPDF(){
var data = JSON.parse(JSON.stringify(this.dataList));
var data = data.map(item=>{
delete item._id;
delete item.photo; delete item.status; delete item.user;
return item;
});
_exportPDF( data, null, "Pacientes",null );
}



Personalizacion:

*cambiar nombre del archivo
info: {
title: 'Reporte',
author: 'john doe',
subject: 'subject of document',
keywords: 'keywords for document',
  },

*orientacion de pagina
pageOrientation: 'landscape',

*Footer en pagina - fuera del content
footer: {
    columns: [
      { text: 'Criterios: Estado=true, Subcategory="Carne roja"', alignment: 'center' }
    ]
  },

* Imagen de logo
     {
      // you can also fit the image inside a rectangle
      image: 'data:image/png;base64,iVg==',
      //fit: [100, 100],
      
      width: 200
    },









viernes, 3 de abril de 2020

Popover de bootstrap para angular

============= Agregar el popover de bootstrap para angular==========

web: https://ng-bootstrap.github.io/#/getting-started
install: npm install --save @ng-bootstrap/ng-bootstrap

add: import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  ...
  imports: [NgbModule, ...],
  ...
})
export class YourAppModule {
}

example:
https://ng-bootstrap.github.io/#/components/popover/examples

<button type="button" class="btn btn-outline-secondary mr-2" placement="top"
        ngbPopover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." popoverTitle="Popover on top">
  Popover on top
</button>