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
// Init | |
google.maps.event.addDomListener(window, 'load', function() { | |
var map_container = document.getElementById("map-canvas"); | |
var minZoomLevel = 2; | |
var startZoomLevel = 8; | |
var map = new google.maps.Map(map_container,{ | |
center: new google.maps.LatLng(-34.397, 150.644), |
Recommendations of unit types per media type:
Media | Recommended | Occasional use | Infrequent use | Not recommended |
---|---|---|---|---|
Screen | em, rem, % | px | ch, ex, vw, vh, vmin, vmax | cm, mm, in, pt, pc |
em, rem, % | cm, mm, in, pt, pc | ch, ex | px, vw, vh, vmin, vmax |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
{ | |
/** | |
* Tell JSHint about global variables. | |
*/ | |
"predef": [ | |
// https://github.com/pivotal/jasmine | |
"after", | |
"afterEach", |
// Assuming 5 fixed digits | |
function dehydrateFloat(f){ | |
return Math.floor(f.toFixed(5)*100000).toString(36); | |
} | |
function hydrateFloat(dryf){ | |
return (parseInt(dryf,36)/100000).toFixed(5); | |
} |
#Social Network Crawler User Agents Users can post URLs on a lot of different platforms nowadays. Most of those platforms will send a request to that URL to generate some preview data from it.
These are a couple of user agents I quickly tested out.
facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.
// Generate a middleware | |
function middleware(mw){ | |
return function(fn){ | |
fn = (typeof fn == "function") ? fn : window[fn]; | |
return function(){ | |
var args = arguments || []; | |
if(false !== mw.apply(this,args)) fn.apply(this,args); | |
}; | |
}; | |
} |