This file contains hidden or 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 | |
function cleanse($string, $allowedTags = array()) | |
{ | |
if (get_magic_quotes_gpc()) { | |
$string = stripslashes($stringIn); | |
} | |
// $string = kses($string, $allowedTags); // For kses {@see http://sourceforge.net/projects/kses/} | |
// ============ |
This file contains hidden or 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
// Protected self calling pattern. | |
(function(window,document,$,undefined){ | |
})(this,this.document,this.jQuery); | |
// setInterval replacement, async recursion. | |
// setInterval doesn't wait for completion even if the function is longer than the timeout, below does. | |
(function foobar() { // Recursive but doesn't fire before completed. | |
doStuff(); |
This file contains hidden or 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(window, document, $, undefined){ | |
var SDK = function () { | |
var id, | |
cb, | |
key, | |
secret, | |
v = 1, | |
blacklabel_id = 2, | |
url = 'http://example.com/restserver.php', | |
canCache = (("localStorage" in window) && |
This file contains hidden or 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
applicationCache.onUpdateReady = function () { | |
applicationCache.swapCache(); | |
alert('New version of site available please refresh'); | |
} | |
window.onOnline = function () { | |
// Fire an update to the cache. | |
applicationCache.update(); | |
} |
This file contains hidden or 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
// Feature detection rocks. | |
// But what if you want to display something different on a different browser? | |
// You still need to know what browser the client is in. | |
// | |
// For example thanks to modernizr I know geoLocation exists, but I also know that FF's | |
// Allow location bar isn't very obvious to the user and I want to provide some help. | |
// Thus I need to make sure I style the helper in the correct place. Using .firefox .geo-helper | |
// I place it top right but in chrome I can place it somewhere else. | |
window.BrowserDetection = (function (window,document,undefined) { | |
var browser, |
This file contains hidden or 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 | |
function dorphin_rss_item() | |
{ | |
global $post; | |
$d = get_post_custom(); | |
if (!empty($d['thumb_image'])) | |
{ | |
?> | |
<enclosure url="<?php echo(CDN_IMAGE.$d['thumb_image'][0]); ?>" type="image/jpeg" /> |
This file contains hidden or 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 | |
function fbOg() | |
{ | |
if (is_single()) | |
{ | |
global $post; | |
$images = preg_split("/\"/", get_the_post_thumbnail( $post->ID, 'thumbnail' )); | |
$first_image = isset($images[5]) ? $images[5] : 'http://example.com/blogLogo.jpg'; // Hardcoded fallback. | |
This file contains hidden or 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 | |
/** | |
* PHP Singleton pattern (same as Java singleton). | |
* | |
* Analytics::incrementView(this); // Within the photo class for example. | |
*/ | |
class Analytics | |
{ | |
private static $instance; |
This file contains hidden or 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 | |
function _cmpAscA($m, $n) { | |
if ($m->unixstart == $n->unixstart) | |
return 0; | |
return ($m->unixstart < $n->unixstart) ? -1 : 1; | |
} | |
function _cmpDescA($m, $n) { | |
if ($m->unixstart == $n->unixstart) |
This file contains hidden or 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 | |
require_once 'test_integration_html_HTML.php'; | |
/** | |
* Suite of tests for the home page. | |
* | |
* @usage | |
* 1. Just define more functions, any functions starting with the name test will be run. | |
* 2. Each test function should have one or more asserts. Try not too have too many. | |
* 3. Each function should test a bunch of similiar stuff for this page like, banners or spot list. |