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) | |
*/ | |
Object.defineProperty(Object.prototype, "extend", { | |
value: function() { | |
for (var i = arguments.length; i--;) { | |
var obj = arguments[i]; | |
for (var j in 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
/* | |
Copyright (c) 2014 Rohit Vighne | |
License: The MIT License (MIT) | |
*/ | |
(function (window, document) { | |
function select () { | |
this.select(); | |
} |
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 pixelPerfect(ctx) { | |
ctx.translate(0.5, 0.5); // so pixels with odd coordinates snap to nearest physical pixel | |
ctx.imageSmoothingEnabled = false; // may need polyfill for safari | |
} | |
// Call pixelPerfect with your canvas context (obtained by getContext) as argument, and happy whole-pixel drawing! |
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 |