Skip to content

Instantly share code, notes, and snippets.

View schnogz's full-sized avatar

Andrew Schneider schnogz

View GitHub Profile
@schnogz
schnogz / javascript-global-scope.js
Created May 14, 2015 03:58
Examples of JavaScript global scoping.
//globals
var x = 4;
function Dog() {
alert("Woof");
}
// 3rd party libraries use the global scope
// making them accessible from anywhere an app
jQuery("#myDiv").empty();
@schnogz
schnogz / html5-download-attr.html
Last active August 29, 2015 14:20
Examples of HTML5's Download Attribute
<!-- must always supply an href to file -->
<a href="/file/somethingreallylongandobscure234211.pdf" download>
<!-- if a value is passed to download attr, it will be the name of the file when downloaded -->
<a href="/file/generated-budget-1293.pdf" download="Weekly Budget Recap">
@schnogz
schnogz / count-watchers-angularjs.js
Last active August 29, 2015 14:20
Count All Watchers Currently Running on an AngularJS Page
(function () {
// Change root to point at your ng-app in HTML
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers,
function (watcher) {
watchers.push(watcher);