Skip to content

Instantly share code, notes, and snippets.

View TastyToast's full-sized avatar

Donnie Conner TastyToast

View GitHub Profile
Array.prototype.max = function() {
return Math.max.apply(Math, this);
}
Array.prototype.min = function() {
return Math.min.apply(Math, this);
}
@TastyToast
TastyToast / simple-async-test-suite.html
Last active August 29, 2015 14:08
Simple async test
<!doctype html>
<html>
<head>
<title>Simple Test Suite</title>
<script>
(function(){
var queue = []
var paused = false
var results;
@TastyToast
TastyToast / enumFromObject.js
Created June 25, 2014 23:33
Create Enum From Object
/**
* Creates and enum from the object based on key values
*
* @param {object} Object
* @return {object} enum from object
*/
function buildEnumFromObject_(obj){
var createdEnum = {};
var i = 0;
@TastyToast
TastyToast / colorhover.css
Created December 3, 2013 00:13
Color Toggle on Hover
img {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\' filterRes=\'800\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
-webkit-backface-visibility: hidden; /* Fix for transition flickering */
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
@TastyToast
TastyToast / urlify.js
Created September 9, 2013 23:50
Change links to urls
function urlify(text){
var urlRegex = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&amp;]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\s+|$)/gi;
return text.replace(urlRegex, function(url){
return '<a href="' + url + '">' + url + '</a>';
});
};
@TastyToast
TastyToast / youtube-api-helper.js
Created September 4, 2013 00:32
YouTube JS API Helper
/**
* @author Rob W <[email protected]>
* @website http://stackoverflow.com/a/7513356/938089
* @version 20120724
* @description Executes function on a framed YouTube video (see website link)
* For a full list of possible functions, see:
* https://developers.google.com/youtube/js_api_reference
* @param String frame_id The id of (the div containing) the frame
* @param String func Desired function to call, eg. "playVideo"
* (Function) Function to call when the player is ready.
@TastyToast
TastyToast / youtube_parser.js
Created August 14, 2013 16:09
Youtube Video Id Parser
<script type="text/javascript">
function youtube_parser(url){
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
if (match&&match[7].length==11){
return match[7];
}else{
alert("Url incorrecta");
}
}
@TastyToast
TastyToast / liveupdate.js
Created August 2, 2013 20:24
Live update
// FROM http://orderedlist.com/blog/articles/live-search-with-quicksilver-style-for-jquery
(function($) {
var self = null;
$.fn.liveUpdate = function(list) {
return this.each(function() {
new $.liveUpdate(this, list);
});
};
@TastyToast
TastyToast / preloader.js
Created July 3, 2013 21:51
Tiny Preloader
$.preloadImages = function(){
for(var i = 0; i < arguments.length; i++){
$("<img />").attr("src", arguments[i]);
}
};
@TastyToast
TastyToast / siaf.js
Created May 23, 2013 23:57
self invoking anonymous function
(function($){
})(jQuery);