This file contains hidden or 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 getStyle(node, property, camel) { | |
| var value; | |
| if (window.getComputedStyle) { | |
| value = document.defaultView | |
| .getComputedStyle(node, null) | |
| .getPropertyValue(property); | |
| } else if (node.currentStyle) { | |
| value = node.currentStyle[property] ? | |
| node.currentStyle[property] : | |
| node.currentStyle[camel]; |
This file contains hidden or 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 makeRequest(url, method) { | |
| var xhr; | |
| if (typeof XMLHttpRequest === "undefined") { | |
| return null; | |
| } | |
| xhr = new XMLHttpRequest(); | |
| if ("withCredentials" in xhr) { | |
| xhr.open(method, url, true); | |
| return xhr; |
This file contains hidden or 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, 5, 9, 2, 5, 0 ].reduce(function(p, c, i, a){ return c > p ? c : p; }); |
This file contains hidden or 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(global, undefined) { | |
| // name, prefix, depth | |
| var print = function(n, p, d) { | |
| var b = p[n]; | |
| // Allow base indenting based on the depth | |
| var response = '\n' + | |
| (new Array(d).join(' ')) + | |
| n + | |
| ' (' + (typeof b) + ')'; |
This file contains hidden or 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(global, undefined) { | |
| var MAXDEPTH = 10; | |
| // name, prefix, depth | |
| var print = function(n, p, d) { | |
| if (d > MAXDEPTH) { | |
| return new Error('MAXDEPTH exceeded'); | |
| } | |
| console.log(n, p, d); | |
| var b = p[n]; |
This file contains hidden or 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 getNavTiming(name) { | |
| if (!window.performance || !window.performance.timing) return 'unsupported'; | |
| var t = window.performance.timing; | |
| var startName = name + 'Start', endName = name + 'End'; | |
| if (name.indexOf('dom') == 0 && name.indexOf('domain') == -1) { | |
| startName = 'responseStart'; endName = name; | |
| } | |
| switch (name) { | |
| case 'load': startName = 'responseStart'; endName = 'loadEventEnd'; break; | |
| case 'connect': |
This file contains hidden or 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 page = require('webpage').create(), | |
| address, output, size; | |
| if (phantom.args.length < 2 || phantom.args.length > 3) { | |
| console.log('Usage: ' + phantom.scriptName + ' URL filename'); | |
| phantom.exit(); | |
| } | |
| var start = new Date(); |
This file contains hidden or 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(global, undefined) { | |
| // Protect and log errors | |
| try { | |
| var log = (typeof console.log === 'function') ? | |
| console.log : | |
| function(m) {}; | |
| var MAXDEPTH = 2; | |
| // name, prefix, depth | |
| var print = function(n, p, d) { |
This file contains hidden or 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
| <h1>Summary</h1> | |
| <p>My example project</p> | |
| <h1>Code</h1> | |
| <div style=""> | |
| <script src="https://gist.github.com/3094001.js"> </script> | |
| </div> |
This file contains hidden or 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
| $(element) |