Skip to content

Instantly share code, notes, and snippets.

@mmfilesi
mmfilesi / main
Created May 3, 2017
propiedades profundas seguras
View main
/* Acceder a propiedades de forma segura. Leído en El abismo de null
https://elabismodenull.wordpress.com/2017/03/16/pequenos-trucos-para-mejorar-tu-javascript/
*/
const isObject = obj => obj && typeof obj === 'object';
const hasKey = (obj, key) => key in obj;
const Undefined = new Proxy({}, {
get: function(target, name){
return Undefined;
@mmfilesi
mmfilesi / index.html
Created Mar 30, 2017
vue - emit - on
View index.html
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title>vue</title>
<script src="js/vendor/vue.js"></script>
</head>
<body>
View index.html
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title>vue</title>
<script src="js/vendor/vue.js"></script>
</head>
<body>
<div id="foo">
View index.html
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title>vue</title>
<script src="js/vendor/vue.js"></script>
</head>
<body>
<!-- 1. bindings -->
View index.html
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@mmfilesi
mmfilesi / LifeCycle.jsx
Created Oct 5, 2016
react component lifecicle
View LifeCycle.jsx
import React from 'react';
/*
Los componentes react con estado(1) tienen tres grandes fases en su ciclo de vida:
Mounting: montaje
Mounted: ya está montado
Unmounting: cuando se desmonta
Cada fase tiene una serie de métodos asociados que nos pueden servir de punto de captura para hacer cosas. Los detallo en el propio componente.
1. Los stateless no tienen ciclo de vida.
@mmfilesi
mmfilesi / .babelrc
Created Oct 4, 2016
react, webpack configuration
View .babelrc
{
"presets": ["es2015", "stage-1", "react"]
}
@mmfilesi
mmfilesi / constructor
Created May 5, 2016
3 node modules patterns
View constructor
'use strict';
function Foo(numParam) {
this.bar = numParam || 0;
}
Foo.prototype.publicMethod = function() {
let temp = 1 + this.bar;
return temp;
};
View foo-jquery.js
'use strict';
(function () {
var foo = function (params) {
return new DomModule(params);
};
var DomModule = function (params) {
var selector = document.querySelectorAll(params),
@mmfilesi
mmfilesi / gist-list.html
Created Mar 16, 2016
web component (polymer) to show user gists (0.0.5)
View gist-list.html
<dom-module id="gist-list">
<template>
<style>
.fade-ajax-out {
transition:1s linear all;
opacity:0;
background-color: #fcffdf;
}
.fade-ajax-in {