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
/** make_flat(Array) | |
* Simple method for flattening a multidimensional array | |
* @example make_flat([[1,2,[3]],4]) == [1, 2, 3, 4] | |
**/ | |
function make_flat(arr) { | |
// simply make use of `reduce` method to to reduce each element to a single val | |
return arr.reduce(function(a, b) { | |
// if val is array, rerun thru, else, move on | |
return a.concat( Array.isArray(b) ? make_flat(b) : b ); | |
}, |
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() { | |
/** | |
* AssociativeArray( { key: value } ) | |
* AssociativeArray( key, value ) | |
* AssociativeArray( [keys], [value] ) | |
**/ | |
function AssociativeArray() { | |
var args = Array.prototype.slice.call(arguments), | |
arr = []; | |
switch (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
/** isEmpty(varried) | |
* Simple method for testing if item is "empty" | |
**/ | |
;(function() { | |
/** | |
* !a Basic empty check. Takes care of 90% of items passed through. | |
* 0 >= a Catchs '0' strings and empty Arrays | |
* | |
* /\{\}/.test(JSON.stringify(a).replace(/"[^"]*":(0|"0*"|false|null|\{\}|\[(null(,)?)*\]),?/g, '').replace(/"[^"]*":\{\},?/g, '')) // to determine Blank Object | |
* /|\[(null(,)*)*\]/.test(JSON.stringify(a).replace(/(0|"0*"|false|null|\{\}|\[(null(,)?)*\]),?/g, '')) // to determine Blank Array |
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() { | |
function createOpenLink(href, oType) { | |
var objStyle = { | |
'padding': '1em', | |
'text-align': 'center' | |
}, | |
strStyle = $.map(objStyle, function(v, k) { return k + ': ' + v; }).join('; ') + ';', | |
attrs = { 'href': href, 'style': strStyle, 'target': '_blank', 'text': 'Open ' + oType }, | |
lnkOpen = $('<a />', attrs); | |
return lnkOpen; |
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() { | |
if (/(\/$)|\/(hot|trending)/.test(location.href)) { | |
var art = $('article:first').clone(), | |
/* REPLACEMENTS MADE BELOW */ | |
title = "YOU'RE AWESOME!", // replace between "" with what you want it to say | |
picLink = 'http://some.picture.com/pic.png', // replace this with a link to a pic you want on hots | |
profileLink = 'http://9gag.com/u/your_username'; // replace this with link to your profile | |
/* REPLACEMENTS MADE ABOVE */ | |
img = $('<img />', { 'alt': "Your pic link is incorrect.", 'src': picLink }).addClass('badge-item-img'); | |
art.find('.badge-item-title a').text(title); |
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
[ | |
{ | |
"District of Columbia": { | |
"sqmi":6825, | |
"sqkm":17675 | |
} | |
}, | |
{ | |
"Alaska": { | |
"sqmi":663267, |
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($) { | |
$.extend({ | |
outerHTML: function() { | |
var $ele = arguments[0], | |
args = Array.prototype.slice.call(arguments, 1) | |
if ($ele && !($ele instanceof jQuery) && (typeof $ele == 'string' || $ele instanceof HTMLCollection || $ele instanceof Array)) $ele = $($ele); | |
if ($ele && $ele.length) { | |
if ($ele.length == 1) return $ele[0].outerHTML; | |
else return $.map($("div"), function(ele,i) { return ele.outerHTML; }); | |
} |
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 bob() { | |
$("article div > img:not(.atagged), article div > video:not(.atagged)").each(function(i) { | |
var href = this.src, | |
oType = this.tagName.toLowerCase(); | |
oType = oType.charAt(0).toUpperCase() + oType.substr(1); | |
$(this).addClass("atagged").closest("article").children("header+div") | |
.append($("<a />", { href: href, style: "padding:1em;text-align:center;", target: "_blank", text: "Open "+oType })); | |
}).length; | |
} | |
bob(); |
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 cjsSelector = ''; | |
;(function() { | |
var iDoIt = 1; | |
function doIt() { | |
/* ↓↓↓ DO WORK IN HERE ↓↓↓ */ | |
jQuery(cjsSelector).remove(); | |
/* ↑↑↑ DO WORK IN HERE ↑↑↑ */ | |
iDoIt = iDoIt < 10 ? iDoIt + 1 : 1; | |
setTimeout(doIt, iDoIt * 1000); | |
} |
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() { | |
var hrefUI = { open: "https://ajax.googleapis.com/ajax/libs/jqueryui/", close: "/themes/smoothness/jquery-ui.css" }, | |
srcJQ = { open: "https://ajax.googleapis.com/ajax/libs/jquery/", close: "/jquery.min.js" }, | |
srcUI = { open: "https://ajax.googleapis.com/ajax/libs/jqueryui/", close: "/jquery-ui.min.js" }, | |
jQVers = ["2.2.4","2.2.3","2.2.2","2.2.1","2.2.0","2.1.4","2.1.3","2.1.1","2.1.0","2.0.3","2.0.2","2.0.1","2.0.0","1.12.4","1.12.3","1.12.2","1.12.1","1.12.0","1.11.3","1.11.2","1.11.1","1.11.0","1.10.2","1.10.1","1.10.0","1.9.1","1.9.0","1.8.3","1.8.2","1.8.1","1.8.0","1.7.2","1.7.1","1.7.0","1.6.4","1.6.3","1.6.2","1.6.1","1.6.0","1.5.2","1.5.1","1.5.0","1.4.4","1.4.3","1.4.2","1.4.1","1.4.0","1.3.2","1.3.1","1.3.0","1.2.6","1.2.3"], | |
jQUIVers = ["1.11.4","1.11.3","1.11.2","1.11.1","1.11.0","1.10.4","1.10.3","1.10.2","1.10.1","1.10.0","1.9.2","1.9.1","1.9.0","1.8.24","1.8.23","1.8.22","1.8.21","1.8.20","1.8.19","1.8.18","1.8.17","1.8.16","1.8.15","1.8.14","1.8.13","1.8.12","1.8.11","1 |
NewerOlder