- 2 cups sliced almonds
- 1 cup pecans, chopped
- 1 cup walnuts, chopped
- 1 cup shelled pumpkin seeds (pepitas)
- 1 cup shelled sunflower seeds
- 1/4 cup ground flax seed or flax seed meal
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.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. | |
// “Safe” but retain cycle. | |
[self setCompletionBlock:^{ | |
NSLog(@"1: %@", self->_foo); | |
}]; | |
// 2. | |
// Unsafe. Could dereference nil. | |
__weak BCThing *weakSelf = self; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Portable & reusable Events object, not too different from what is found | |
// in Backbone. | |
// | |
// (Credits @visionmedia) & Modified from: | |
// https://raw.github.com/component/emitter/master/index.js | |
var Events = { | |
// Cache all callbacks. | |
callbacks: {}, | |
// Listen on the given `event` with `fn`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend(destination) { | |
var prop, source; | |
var index = 0; | |
var length = arguments.length; | |
while (++index < length) { | |
source = arguments[index]; | |
for (prop in source) { | |
destination[prop] = source[prop]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var elemDisplays = {}, | |
// Store the iframe outside the function to reuse it | |
iframe, | |
iframeDoc; | |
function defaultDisplay( nodeName ) { | |
if ( !elemDisplays[ nodeName ] ) { | |
// Try the classical method first, which is far faster | |
var elem = document.createElement( nodeName ), | |
display; |