This file contains 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 svgSupport = !!(document.createElementNS && document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect); |
This file contains 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
require('font-awesome/css/font-awesome.css'); | |
document.body.innerHTML = '<i class="fa fa-fw fa-question"></i>'; |
This file contains 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 obj = { | |
foo: function() { | |
// do awesome things | |
}, | |
bar: function() { | |
// do magic stuff | |
} | |
}; | |
var collection = Backbone.Collection.extend({}); |
This file contains 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 copyTextToClipboard(text) { | |
var textArea = document.createElement("textarea"); | |
// | |
// *** This styling is an extra step which is likely not required. *** | |
// | |
// Why is it here? To ensure: | |
// 1. the element is able to have focus and selection. | |
// 2. if element was to flash render it has minimal visual impact. | |
// 3. less flakyness with selection and copying which **might** occur if |
This file contains 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
//for positive integers | |
/^\+?[1-9]\d*$/.test(); | |
//for positive integers and zero | |
/^\+?(0|[1-9]\d*)$/.test(); | |
//for positive/negative integers and zero | |
/^\-?(0|[1-9]\d*)$/.test(); | |
//to match specific chars |
This file contains 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
A = []; | |
// This is perfect if you don't have references to the original array A anywhere else because this actually creates a brand new (empty) array. | |
A.length = 0; | |
// This will clear the existing array by setting its length to 0 | |
A.splice(0,A.length); | |
// Using .splice() will work perfectly, but since .splice() function will return an array with all the removed items, it will actually return a copy of the original array. Benchmarks suggests that this has no effect on performance whatsoever. | |
while(A.length > 0) { |
This file contains 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 indexOf = function(needle) { | |
if(typeof Array.prototype.indexOf === 'function') { | |
indexOf = Array.prototype.indexOf; | |
} else { | |
indexOf = function(needle) { | |
var i = -1, index = -1; | |
for(i = 0; i < this.length; i++) { | |
if(this[i] === needle) { | |
index = i; |
This file contains 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
window.onresize = function() { | |
if ( this.resizeTimer ) clearTimeout( this.resizeTimer ); | |
this.resizeTimer = setTimeout ( function() { | |
/* Your code here */ | |
}, 500 ); | |
} |
This file contains 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 script element */ | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = 'https://gist.github.com/7544705.js'; | |
/* Backup document.write function */ | |
if(!document._write) document._write = document.write; | |
/* Override document.write function */ | |
document.write = function (str) { | |
document.getElementById('scriptCont').innerHTML += str; | |
}; |
This file contains 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
// Remember to prototype your own custom Date | |
var customDate = Date | |
// Date extension to to make monday day 0 (week start on monday) | |
customDate.prototype.getDayL = function () { | |
if ( this.getDay() == 0 ) { | |
return 6; | |
}else{ | |
return this.getDay() - 1; | |
} |
NewerOlder