A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
One-line version to paste in your DevTools
Use $$ if your browser aliases it:
~ 108 byte version
| //////////////////////////////////////////////////////////////////////// | |
| // Intro | |
| /////////////////////// | |
| // Tools like Redux-saga, React-redux and Reselect can easily be used without Redux | |
| // For Reselet there's nothing to do, it's just not coupled to Redux | |
| // For the others, you just need to provide an adapter | |
| // At Stample.co we use a legacy framework that is quite close to Redux but with a bad API | |
| // We want to progressively migrate to Redux, so starting now to use Redux tools on new features will make our migration faster |
| define(function(require) { | |
| var React = require('react'); | |
| var paramRegex = /__(\d)+/; | |
| var parser = new DOMParser(); | |
| var errorDoc = parser.parseFromString('INVALID', 'text/xml'); | |
| var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI; | |
| // turns the array of string parts into a DOM | |
| // throws if the result is an invalid XML document. |
There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.
However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.
| //<editor-fold desc="Node Requires, gulp, etc"> | |
| var gulp = require('gulp'), | |
| autoprefixer = require('gulp-autoprefixer'), | |
| clean = require('gulp-clean'), | |
| concat = require('gulp-concat'), | |
| csso = require('gulp-csso'), | |
| debug = require('gulp-debug'), | |
| footer = require('gulp-footer'), | |
| gutil = require('gulp-util'), | |
| gzip = require('gulp-gzip'), |
#Error management in gulp
Sucking at something is the first step to becoming sorta good at something
No one can assure you, that plugins will run smooth in any circumstances (except for tests - they could), so neither should you convince anyone, that your plugin will never break. Only thing, that you could possibly do (if something gone wrong) - is gracefully inform your plugin user, that something went wrong and die.
We are will use this plugin from beginning to demonstrate error management. Suppose you have a task in gulpfile.js that contains this code (we modified it a little bit to be closer to real-usage):
var coffee = require('gulp-coffee');Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.
Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.
On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 Olivier Scherrer | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |