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
Top 6 | |
bugsense.com | |
jslogger.com | |
qbaka.com | |
muscula.com | |
errorception.com | |
exceptionhub.com | |
Not targeting JS primarily: | |
exceptional.io |
'use strict'; | |
/** | |
* This file is mostly pulled from the one generate by Yeoman 1.0 Beta | |
**/ | |
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet; | |
var mountFolder = function (connect, dir) { | |
return connect.static(require('path').resolve(dir)); | |
}; |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.
// Load scripts asynchronously | |
jQuery.loadAsync = function(url, callback) { | |
// Don't use $.getScript since it disables caching | |
jQuery.ajax({ | |
'url': url, | |
'dataType': 'script', | |
'cache': true, | |
'success': callback || jQuery.noop | |
}); | |
}; |
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE in JavaScript | |
// without resorting to user-agent sniffing | |
// ---------------------------------------------------------- | |
// If you're not in IE (or IE version is less than 5) then: | |
// ie === undefined | |
// If you're in IE (>=5) then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: | |
// if (ie) {} |