Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)
First one found from of
class UnionFind: | |
"""Weighted quick-union with path compression and connected components. | |
The original Java implementation is introduced at | |
https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf | |
>>> uf = UnionFind(10) | |
>>> for (p, q) in [(3, 4), (4, 9), (8, 0), (2, 3), (5, 6), (5, 9), | |
... (7, 3), (4, 8), (6, 1)]: | |
... uf.union(p, q) |
// Store ad tags in localStorage to enable reporting bad ads | |
// TODO: This doesn't work if multiple ads are shown in one placement with googletag.pubads().refresh() | |
googletag.pubads().addEventListener('slotRenderEnded', function (event) { | |
if (typeof(localStorage) !== 'object') console.log('fail'); | |
if (event.slot.getResponseInformation() === null) return; | |
var slotAdUnitPath = event.slot.getAdUnitPath(); | |
gpt_placements[slotAdUnitPath] = {}; | |
gpt_placements[slotAdUnitPath]['dfp'] = event.slot.getResponseInformation(); | |
gpt_placements[slotAdUnitPath]['dfp']['contentUrl'] = event.slot.getContentUrl(); |
Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)
First one found from of
<html> | |
<head> | |
<script> | |
var PREBID_TIMEOUT = 400; | |
var googletag = googletag || {}; | |
googletag.cmd = googletag.cmd || []; |
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
/* | |
Do not modify this version of the file. It will be copied over when any of the project's targets are built. | |
If you wish to modify mraid.js, modify the version located at mopub-sdk-common/mraid/mraid.js. | |
*/ | |
(function() { | |
var isIOS = (/iphone|ipad|ipod/i).test(window.navigator.userAgent.toLowerCase()); | |
if (isIOS) { | |
console = {}; | |
console.log = function(log) { | |
var iframe = document.createElement('iframe'); |
(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.
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |