Go to the egghead website, i.e. Building a React.js App
run
$.each($('h4 a'), function(index, video){
console.log(video.href);
});
<?php | |
/** | |
* Number generator | |
* | |
* Generates random numbers with weighting. | |
* Pass in an associative array, such as | |
* | |
* array( | |
* 'A' => 10, // 10% chance | |
* 'B' => 30, // 30% chance |
/** | |
* Callbag loves TypeScript | |
* | |
* Copy-paste this into http://www.typescriptlang.org/play/index.html | |
*/ | |
// A Callbag dynamically receives input of type I | |
// and dynamically delivers output of type O | |
type Callbag<I, O> = { | |
(t: 0, d: Callbag<O, I>): void; |
Go to the egghead website, i.e. Building a React.js App
run
$.each($('h4 a'), function(index, video){
console.log(video.href);
});
The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.
However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on
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.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
elem.clientLeft
, elem.clientTop
, elem.clientWidth
, elem.clientHeight
elem.getClientRects()
, elem.getBoundingClientRect()
The diff output is more specific:
[I]f a whole block of text is moved, then all of it, rather than just the beginning and end, is detected as changed.
>The algorithm described here avoids these difficulties. It detects differences that correspond very closely to our intuitive notion of difference.
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
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.
// easy retina-ready images | |
// http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss | |
@mixin image-2x($image, $width, $height) { | |
@media (-webkit-min-device-pixel-ratio: 2), | |
(min--moz-device-pixel-ratio: 2), | |
(-o-min-device-pixel-ratio: 2/1), | |
(min-device-pixel-ratio: 2), | |
(min-resolution: 192dpi), | |
(min-resolution: 2dppx) { | |
/* on retina, use image that's scaled by 2 */ |