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
// http://stackoverflow.com/questions/13743058/how-to-access-the-angular-scope-variable-in-browsers-console | |
angular.element($0).scope() | |
// Access whole scope | |
angular.element(myDomElement).scope(); | |
// Access and change variable in scope | |
angular.element(myDomElement).scope().myVar = 5; | |
angular.element(myDomElement).scope().myArray.push(newItem); |
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
/** | |
Walk directory, | |
list tree without regex excludes | |
http://stackoverflow.com/questions/23809897/node-js-glob-pattern-for-excluding-multiple-files | |
*/ | |
var fs = require('fs'); | |
var path = require('path'); | |
var walk = function (dir, regExcludes, done) { |
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 getScopes(root) { | |
var scopes = []; | |
function traverse(scope) { | |
scopes.push(scope); | |
if (scope.$$nextSibling) | |
traverse(scope.$$nextSibling); | |
if (scope.$$childHead) | |
traverse(scope.$$childHead); | |
} | |
traverse(root); |
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
// Create IE + others compatible event handler | |
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; | |
var eventer = window[eventMethod]; | |
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; | |
// Listen to message from child window | |
eventer(messageEvent,function(e) { | |
console.log('parent received message!: ',e.data); | |
},false); |
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
// http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript | |
Math.random().toString(36).substring(7) |
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
return (/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/).test(valor); | |
// http://www.mkyong.com/regular-expressions/how-to-validate-date-with-regular-expression/ | |
// revisado | |
^(0?[1-9]|[12][0-9]|3[01])\/(0?[1-9]|1[012])\/((19|20)\d\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
Object.prototype.extend = function(obj) { | |
for(i in obj) | |
this[i] = obj[i]; | |
}; | |
var o = { member: "some member" }; | |
var x = { extension: "some extension" }; | |
o.extend(x); |
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
// http://jondavidjohn.com/extend-javascript-functions/ | |
Array.prototype.join = (function(_super) { | |
// return our new `join()` function | |
return function() { | |
console.log("Hey, you called join!"); | |
return _super.apply(this, arguments); | |
}; | |
// Pass control back to the original join() |
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 menu = document.querySelector('.menu') | |
var menuPosition = menu.getBoundingClientRect().top; | |
window.addEventListener('scroll', function() { | |
if (window.pageYOffset >= menuPosition) { | |
menu.style.position = 'fixed'; | |
menu.style.top = '0px'; | |
} else { | |
menu.style.position = 'static'; | |
menu.style.top = ''; | |
} |
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 docWidth = document.documentElement.offsetWidth; | |
[].forEach.call( | |
document.querySelectorAll('*'), | |
function(el) { | |
if (el.offsetWidth > docWidth) { | |
console.log(el); | |
} | |
} | |
); |