If you have to extend an existing object with additional property, always prefer Vue.set()
over Object.assign()
(or spread operator).
Example below explains implications for different implementations.
const flatten = < T = any > (arr: T[]) => { | |
const reducer = < T = any > (prev: T[], curr: T | T[]) => { | |
if (curr.constructor !== Array) { | |
return [...prev, curr]; | |
} | |
return curr.reduce(reducer, prev); | |
}; | |
return arr.reduce(reducer, []); | |
}; |
// A Declarative Pipeline is defined within a 'pipeline' block. | |
pipeline { | |
// agent defines where the pipeline will run. | |
agent { | |
// This also could have been 'agent any' - that has the same meaning. | |
label "" | |
// Other possible built-in agent types are 'agent none', for not running the | |
// top-level on any agent (which results in you needing to specify agents on | |
// each stage and do explicit checkouts of scm in those stages), 'docker', |
const fileHash = crypto.createHash('md5').update(fileContents).digest('hex'); |
Lightning talk proposal for the Reactive 2016 Conference. Here's a handy retweet link
When I started writing React apps, I approached components as if they were “just the V in MVC!” Seriously, we’ve all heard it.
I have found this to be an inferior way of thinking about and building React applications. It makes people treat React as a drop-in replacement for something like a Backbone or Angular 1.x View. In other words, people treat it like a glorified template system with partials and don’t harness the power of its functional paradigms.
function supportsWoff2() { | |
"use strict"; | |
/*global FontFace*/ | |
// Source: https://github.com/filamentgroup/woff2-feature-test | |
if (!window.FontFace) { | |
return false; | |
} else { | |
var f = new FontFace('t', 'url("data:application/font-woff2,") format("woff2")', {}); | |
f.load(); | |
return f.status === 'loading'; |
This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.
A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:
<?php | |
/** | |
* Útil cuando se necesita calcular el tamaño de un paquete a enviar en el cual | |
* dentro van N productos con distintas medidas. | |
* | |
* Con este algoritmo se puede obtener el tamaño de la caja contenedora final necesaria. | |
*/ | |
$dimensiones = array(0, 0, 0); // Largo, alto, ancho |
<script type="text/javascript"> | |
(function () { | |
"use strict"; | |
// once cached, the css file is stored on the client forever unless | |
// the URL below is changed. Any change will invalidate the cache | |
var css_href = './index_files/web-fonts.css'; | |
// a simple event handler wrapper | |
function on(el, ev, callback) { | |
if (el.addEventListener) { | |
el.addEventListener(ev, callback, false); |