Skip to content

Instantly share code, notes, and snippets.

View pascualmg's full-sized avatar
👾
happy coding!

Pascual Muñoz pascualmg

👾
happy coding!
View GitHub Profile
@pascualmg
pascualmg / webSocketTest.js
Last active August 10, 2018 00:12
trasteando webSockets
/**
fuentes https://www.youtube.com/watch?v=GhuyqjWPjGk
https://www.youtube.com/watch?v=ppiAvvkvAz0
https://www.w3.org/TR/websockets/
*/
//in browser
function wsClient(wsUri){
wsUri = wsUri || (function IIFFE_getExampleWSURIBasedOnProtocol(){
var isHttps = location.protocol.slice(-2,-1)==="s";
@pascualmg
pascualmg / inherit.js
Created May 28, 2018 23:17
Como crear una func que emule la herencia.
function inherits(target, source) {
for (var k in source.prototype)
target.prototype[k] = source.prototype[k];
}
@pascualmg
pascualmg / basicClosureExample.js
Created May 9, 2018 19:48
basic closure example , get set with a private var.
function fuera() {
var str = "las closures son...";
return function dentro(value) {
if (typeof value !== "undefined") {
str = str + value;
}
return str + "";
}
}
var dentroDesdeFuera = fuera();
function Persona(sexo) {
this.sexo = sexo;
};
Persona.prototype = {
saluda: function Saludar() {
console.log('hola me llamo ' + this.nombre + ' y soy ' + this.sexo);
}
};
@pascualmg
pascualmg / package.json
Last active April 22, 2018 11:09
auto testing with coverage and verbose with Jest , cmd line "npm test"
"scripts": {
"test": "jest -o --watch"
},
"jest": {
"collectCoverage": true,
"verbose": true
},
"devDependencies": {
"jest": "^22.4.3",
"fsevents": "^1.2.0"
@pascualmg
pascualmg / gulpfile.js
Created April 17, 2018 22:59
gulpfile skel
const Gulp = require('gulp');
const genericPlugin = concatena = minifica = ofusca = () => null;
Gulp.task('default', () => {
console.log('haciendo cosicas');
return Gulp.src('./inputDir')
.pipe(genericPlugin)
.pipe(concatena)
.pipe(minifica)
@pascualmg
pascualmg / FunctionalTank.js
Created April 17, 2018 16:26
con una función cualquiera te haces un componente en react
import React from 'react';
export default function FunctionalTank(props) {
console.log('Con una función cualquiera te haces un componente',props );//TODO: borrame.
const info =
<div className="tankInfo">
El tanke tiene:{props.material}
le cogen : {props.maxCapacity}
Contenido actual: {props.actualQuantity}
Está ahora mismo al : {(props.actualQuantity / props.maxCapacity) * 100} %
</div>;
@pascualmg
pascualmg / ApiClient.js
Created November 19, 2017 20:47
Javasctript Api Rest Client using "fetch"
/**
* Clase para probar el "fetch" , by PasSh.
*/
"use strict"
var fetch = require('node-fetch');
class ApiClient {
constructor(url, token) {
this.url = url;
this.token = token;
}