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
/* jshint browser: true, devel: true */ | |
/** | |
* preg_replace (from PHP) in JavaScript! | |
* | |
* This is basically a pattern replace. You can use a regex pattern to search and | |
* another for the replace. For more information see the PHP docs on the original | |
* function (http://php.net/manual/en/function.preg-replace.php), and for more on | |
* JavaScript flavour regex visit http://www.regular-expressions.info/javascript.html | |
* |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
// target.addEventListener shim, hat tip [mdn](http://mzl.la/18ELrGJ) | |
(function() { | |
if (!Event.prototype.preventDefault) { | |
Event.prototype.preventDefault=function() { | |
this.returnValue=false; | |
}; | |
} | |
if (!Event.prototype.stopPropagation) { | |
Event.prototype.stopPropagation=function() { | |
this.cancelBubble=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
function removeTrailingWhitespace(string $string) : string | |
{ | |
return preg_replace('/[ \t]+(\r?)$/m', '$1', $string); | |
} | |
// PHPUnit testcase for method | |
// public function testTestInternalRemoveTrailingWhitespace() | |
// { | |
// $this->assertSame( | |
// "\n some\r\n string\n\n\r\nto remove trailing\n whitespace from.\n\n", |
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 getAverageColor = (function(window, document, undefined){ | |
return function(imageURL, options}){ | |
options = { | |
// image split into blocks of x pixels wide, 1 high | |
blocksize: options.blocksize || 5, | |
fallbackColor: options.fallbackColor || '#000' | |
}; | |
var img = document.createElement('img'), | |
canvas = document.createElement('canvas'), |
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
$spacer: 1rem; | |
$tooltip-border-radius: ( 0.333 * $spacer ); | |
[data-tooltip] { | |
position: relative; | |
&::before, | |
&::after { | |
opacity: 0; | |
pointer-events: none; |
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
// turning the markdown feature into a one line include for kits. | |
// wicked closure pattern w/ hat tip to Paul Irish [source](https://gist.github.com/paulirish/315916) | |
(function(window, document, undefined){ | |
// check if Showdown is loaded already or not... if not, then load it | |
// once we have Showdown run the converter | |
if(!window.Showdown){ | |
var script = document.createElement('script'); | |
script.src = '//cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js'; | |
script.onload = extendAndConvert; |
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 request = require('request'); | |
var data = { | |
saturday: { | |
total_sessions: 0 | |
}, | |
sunday: { | |
total_sessions: 0 | |
}, | |
format: {}, |
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
// utility function to parse/use query strings | |
window.query = document.query = (function(window, document, undefined){ | |
var pairs = window.location.search.slice(1).split('&'), | |
result = {}; | |
pairs.forEach(function(pair){ | |
pair = pair.split('='); | |
result[pair[0]] = decodeURIComponent(pair[1] || ''); | |
}); |
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
/* | |
* Javascript Diff Algorithm | |
* By John Resig (http://ejohn.org/) | |
* Modified by Chu Alan "sprite" | |
* | |
* Released under the MIT license. | |
* | |
* More Info: | |
* http://ejohn.org/projects/javascript-diff-algorithm/ | |
*/ |
NewerOlder