Skip to content

Instantly share code, notes, and snippets.

@ingeit
ingeit / socketIonic.ts
Created July 28, 2017 14:19
Web Socket Inonic
// npm install socket.io-client --save
import * as io from 'socket.io-client';
socket:any
chat_input:string;
chats = [];
constructor(public navCtrl: NavController) {
this.socket = io('http://localhost:3000');
@ingeit
ingeit / socket.js
Created July 28, 2017 14:20
Web Socket simple node
//npm install socket.io --save
// socket.js
var socket = require('socket.io'),
http = require('http'),
server = http.createServer(),
socket = socket.listen(server);
socket.on('connection', function(connection) {
console.log('User Connected');
@ingeit
ingeit / ex.ts
Created July 28, 2017 14:41
pipe fecha en ts, no html.
import { DatePipe } from '@angular/common';
let datePipe = new DatePipe('es-AR');
this.miFecha = datePipe.transform(this.miFecha, 'dd/MM/yyyy');
@ingeit
ingeit / ex.ts
Last active December 16, 2018 23:07
primer letra mayuscula Capital Letter
const capitalizeString = value => value.split(" ")
.map(str => str.charAt(0).toUpperCase() + str.slice(1))
.join(" ");
export { capitalizeString };
@ingeit
ingeit / ex.ts
Created July 28, 2017 14:50
ejemplo completo de como escribrir sobre una imagen typescript
import { Component,ViewChild } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild('myCanvas') canvas: any;
@ingeit
ingeit / canvas.ts
Created July 28, 2017 14:51
usar canvas typescript Raw
import { ViewChild } from '@angular/core';
@ViewChild('myCanvas') canvas: any;
canvasElement: any;
ctx:any;
ngAfterViewInit(){
this.canvasElement = this.canvas.nativeElement;
this.ctx = this.canvasElement.getContext('2d');
@ingeit
ingeit / ex.ts
Created July 28, 2017 14:51
ViewChild
import { ViewChild } from '@angular/core';
@ViewChild('idDelElemento') imagen: any;
imagenHTML: any;
//costructor
this.imagenHTML = this.imagen.nativeElement;
//ya puedo trabajar, por ejmeplo obteniendo el alto del contenedor
this.imagenHTML.height
@ingeit
ingeit / canvas.js
Last active August 4, 2017 15:34
Escribir en imagen con canvas
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d');
canvas.width = $('img').width();
canvas.crossOrigin = "Anonymous";
canvas.height = $('img').height();
ctx.drawImage($('img').get(0), 0, 0);
ctx.font = "36pt Verdana";
$(document).on('input','#inp',function(){
//redraw image
ctx.clearRect(0,0,canvas.width,canvas.height);
@ingeit
ingeit / ex.css
Created July 28, 2017 14:53
alineado vertical css, centro vertical css
.contenedorCentro {
position: absolute;
display: table;
height: 100%;
width: 100%;
text-align: center;
border: 2px dashed #f69c55;
}
.centrado {
@ingeit
ingeit / ex.ts
Created July 28, 2017 14:54
generar mail con archivo adjunto buffer
router.get('/email',function (req, res) {
var pdf = require('html-pdf');
var fs = require('fs');
var html = '<h3>hola</h3><p>chau</p>'
var transporter = nodemailer.createTransport({
host: 'smtp.gmail.com', // mail.clubhonorarios.com
port: 587,