Skip to content

Instantly share code, notes, and snippets.

View AndrewHenderson's full-sized avatar

Andrew Henderson AndrewHenderson

  • Newport Beach, CA
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active May 11, 2024 00:41
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@LeaVerou
LeaVerou / dabblet.css
Created December 17, 2012 08:53
How to visually hide stuff but keep it browser-searchable
/**
* How to visually hide stuff but keep it browser-searchable
*/
body > div:nth-of-type(1) { display: none; }
body > div:nth-of-type(2) { visibility: hidden; }
body > div:nth-of-type(3) { height: 0; overflow: hidden; }
body > div:nth-of-type(4) { position: absolute; clip: rect(0,0,0,0) }
body > div:nth-of-type(5) { overflow: hidden; }
body > div:nth-of-type(5) > div { height: 0; }
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

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.

You're Missing the Point of Promises

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.
@ksafranski
ksafranski / Common-Currency.json
Last active April 22, 2024 15:16
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@joshbirk
joshbirk / passport-fdc.js
Created January 31, 2012 21:09
Basic Passport / Force.com / Node.js example
var port = process.env.PORT || 3000;
var fs = require('fs');
var express = require('express');
var passport = require('passport')
, OAuthStrategy = require('passport-oauth').OAuth2Strategy;
passport.serializeUser(function(user, done) {
done(null, user);
});