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
/* | |
html5doctor.com Reset Stylesheet | |
v1.6.1 | |
Last Updated: 2010-09-17 | |
Author: Richard Clark - http://richclarkdesign.com | |
Twitter: @rich_clark | |
*/ | |
html, body, div, span, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, |
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
// Alternative way to create a multi-line strings for ES < 6 | |
var text = (function () {/* | |
<html> | |
<body> | |
<div> | |
</div> | |
</body> | |
</html> | |
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; | |
console.log('text', text); |
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
// Helper function to convert JSON to it's string representation | |
var jsonStringify = typeof JSON !== 'undefined' ? JSON.stringify : function(obj) { | |
var arr = []; | |
$.each(obj, function(key, val) { | |
var next = key + ': '; | |
next += (val === Object(val)) ? jsonStringify(val) : val; | |
arr.push(next); | |
}); | |
return '{ ' + arr.join(', ') + ' }'; | |
}; |
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
/** | |
* Simple templating, replaces occurrence of replacements in passed template | |
* against the values in passed replacements, where the key of replacements will be | |
* mapped to the items to be replaced. | |
* | |
* Usage: | |
* <code><pre> | |
* var template = '<a href="{url}" title="{title}">{text}</a>'; | |
* var replacements = { | |
* url: 'http://www.google.com', |
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
<?php | |
/** | |
* Regular expression to validate different types of phone numbers | |
*/ | |
// simple pattern | |
$pattern = '/^[0-9\-\(\)\/\+\s]*$/'; | |
// example phone numbers | |
$phoneNumbers = ' |
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
/** | |
* Simple profiler, used to measure time taken by processes. | |
* Usage: | |
* <pre> | |
* var profile = new mpProfiler("Measuring async loop"); | |
* i; | |
* for (i = 0; i < 10; i++) { | |
* // do something really cpu expensive | |
* doExpensiveJob(i, 10, function(pos, total){ | |
* profile.addStep("Step " + cur + " from " + total + " done!"); |
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
/** | |
* Extracts all url definitions (e. g. urls to background images) in CSS. | |
* | |
* This snippet could be usefull within a build process where css files are | |
* distributed in different folder during development and should be merged together. | |
* Existing url definitions could be invalid in some cases. | |
*/ | |
// example css content, could be read from a file | |
$cssFileContent = <<<CSS |
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 PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<title>Example Cross-Browser tooltip with CSS</title> | |
<style type="text/css"><!-- | |
body { | |
padding-top:130px; | |
} | |
#box { |
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>How to center a div vertically and horizontally</title> | |
<style type="text/css"> | |
#centerBox { | |
position: absolute; | |
width: 600px; |
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
/** | |
* Checks, if passed string is utf-8 encoded or not. | |
* | |
* @param string $string String to check | |
* @return int Number of found UTF-8 character | |
*/ | |
function mp_detectUTF8($string) | |
{ | |
return preg_match('%(?: | |
[\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte |
NewerOlder