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
/* | |
Copyright (c) 2014 Rohit Vighne | |
License: The MIT License (MIT) | |
*/ | |
var crop = (function(document) { | |
"use strict"; | |
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext('2d'); |
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 shuffle(v){for(var j,x,i=v.length;i;j=~~(Math.random()*i),x=v[--i],v[i]=v[j],v[j]=x);} |
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 now; | |
try { | |
now = performance.now.bind(performance); | |
} catch (e) { | |
if (Date.now) { | |
if (Date.now.bind) { | |
now = Date.now.bind(Date); | |
} else { | |
now = function() { | |
return Date.now(); |
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 markthru (str, char) { | |
char = String.fromCharCode(char || 822); | |
return char + str.split('').join(char); | |
} | |
// A.K.A. "strikethrough" when second argument is omitted. |
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
<!DOCTYPE html> | |
<title>A Perfectly Valid HTML Document</title> | |
<meta charset="utf-8"> | |
<p>A paragraph | |
<p>Another paragraph | |
<p>The last paragraph | |
<ul> | |
<li>A list | |
<li>Green eggs |
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
if (!('startsWith' in String.prototype)) | |
Object.defineProperty(String.prototype, 'startsWith', { | |
value: function (searchString, position) { | |
if (Object.prototype.toString.call(searchString) === "[object RegExp]") | |
throw new TypeError("The search string cannot be a regular expression."); | |
if (position === undefined) | |
position = 0; | |
else | |
position = Math.min(Math.max(position, 0), this.length); | |
return this.lastIndexOf(searchString, position) === position; |
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
/* | |
The MIT License (MIT) | |
Copyright (c) 2014 Rohit Vighne | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
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
Object.defineProperty(Date.prototype, 'isWeekday', { | |
value: function(UTC) { | |
var day = (UTC ? this.getUTCDay : this.getDay)(); | |
if (day === 0 || day === 6) | |
return false; | |
else | |
return true; | |
}, | |
writable: true, configurable: true |
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
Object.deepFreeze = function deepFreeze(obj) { | |
this.freeze(obj) | |
for (var key in obj) { | |
var prop = obj[key] | |
if (obj.hasOwnProperty(key) && prop instanceof this && !this.isFrozen(prop)) | |
this.deepFreeze(prop) | |
} | |
return obj |
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
/* | |
The MIT License (MIT) | |
Copyright (c) 2014 Rohit Vighne | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
OlderNewer