Skip to content

Instantly share code, notes, and snippets.

@ingeit
ingeit / ex.txt
Created October 17, 2019 23:54
nginx policy redirect
location /policy/ {
alias /var/www/policy/;
index tyc.pdf;
}
@ingeit
ingeit / ex.ts
Created July 25, 2019 23:55
push notificacion apple fcm firebase
https://www.freecodecamp.org/news/how-to-get-push-notifications-working-with-ionic-4-and-firebase-ad87cc92394e/
@ingeit
ingeit / ex.ts
Last active July 12, 2019 17:19
cropp croppper foto base64 auto resize
// libreria para disminuir el tamaño y redimensrionar a un width, pero a un heigth automatico para que mantenga el aspect, lo cual no necesitamos, pero es lo que hay, entonces antes que eso, se la redminesiona realmente a WxH que queremos, pero con el metodo canvas, el tamaño se va al pingo. entonces recien ahi usamos la libreria esta para achicar los KB.
-- npm install --save image-resize
import ResizeImage from 'image-resize';
croppFoto(foto) {// la foto tiene que ser base64: data:image/jpg;base64,.... si o si el data:image.....
const img = document.createElement('img');
// When the event "onload" is triggered we can resize the image.
img.onload = () => {
@ingeit
ingeit / ej.js
Last active August 19, 2022 14:21
agrupar propiedas en js, datos repetidos
// parametros: array de la respuesta a agrupar
// groupBy: propiedad por la que se quiere agrupar EJ: id repetidos
// newProp: nueva propiedad a generar con la informacion que me genera lineas repetidas
// props: array de propiedades a generar en la newProp y finalmente borrarlas
//=====================================================================================
// EJEMPLO DE USO
// listar() {
// return this.http.get<any>(`${urlServidor}/`).toPromise()
// .then(res => {
// return this.agruparSegun(res.respuesta, 'idEvento', 'precios', ['importe', 'tipo', 'idPrecio', 'precioEstado'])
@ingeit
ingeit / ex.script
Created April 4, 2019 00:53
ubuntu utc timezone change
dpkg-reconfigure tzdata
@ingeit
ingeit / ex.ts
Created March 21, 2019 16:24
date format utc contemplando timezone en angular desde mysql to angular
import * as moment from 'moment';
moment.locale('es');
const fechaAlta = moment(fecha).utc().format('DD/MM/YY HH:mm:ss')
@ingeit
ingeit / ex.ts
Created March 2, 2019 15:04
hotkeys shortcut keyboard key board combination angular javascript
// VERSION LIGTH VANILLA JAVASCRIPT FUENTE: https://www.npmjs.com/package/hotkeys-js
// teclas posibles Supported Keys
//HotKeys understands the following modifiers: ⇧, shift, option, ⌥, alt, ctrl, control, command, and ⌘.
//The following special keys can be used for shortcuts: backspace, tab, clear, enter, return, esc, escape, space, up, down, left, right, home, end, pageup, pagedown, del, delete and f1 through f19.
<script src="https://unpkg.com/hotkeys-js/dist/hotkeys.min.js"></script>
<script type="text/javascript">
hotkeys('ctrl+a,ctrl+b,r,f', function(event,handler) {
switch(handler.key){
case "ctrl+a":alert('you pressed ctrl+a!');break;
@ingeit
ingeit / ex.ts
Created February 25, 2019 12:01
imprimir div html angular print
// boton ejecuta impruimir
<button nz-button nzGhost (click)="printer()">
<i nz-icon type="printer" theme="outline"></i>Imprimir
</button>
//DIV a imprimir
<div style="visibility: hidden;" id="print" class="print">
<div nz-col style="text-align: center;">
<h2>Comprobante número: {{respuesta?.numeroComprobante}}</h2>
<h3>Informacion del alumno:</h3>
@ingeit
ingeit / ex.ts
Created February 24, 2019 23:26
format time date javascript to mysql moment parse formato fecha
// esto sirve para parsear una fecha de javascript al formato de MYSQL contemplando el UTC -3
import * as moment from 'moment';
moment.locale('es');
funcion(fecha){
//
let aux = moment(fecha).format('YYYY-MM-DD HH:mm:ss')
// ahora AUX tiene el formato de fecha año-mes-dia hora:min:segundos reales, sin necesidad de andar restando o sumando
}
@ingeit
ingeit / ex.ts
Created February 23, 2019 14:51
upload img angular ngzorro zorro image
//HTML
<div>
<nz-upload nzType="drag" [nzBeforeUpload]="beforeUpload" [nzLimit]="1" nzAccept="image/*" nzFIleType="image/*" [nzData]="img"
[nzShowUploadList]="false" [hidden]="disableUpload">
<h2>Subir Flyer</h2>
<p class="ant-upload-drag-icon" *ngIf="!disableUpload">
<i nz-icon type="upload" theme="outline"></i>
</p>
<p class="ant-upload-text" *ngIf="!disableUpload">Click o arrastre la foto a esta zona para subir</p>
</nz-upload>