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 | |
/** | |
* Returns all img tags in a HTML string with the option to include img tag attributes | |
* | |
* @author Joshua Baker | |
* | |
* @example $post_images[0]->html = <img src="example.jpg"> | |
* $post_images[0]->attr->width = 500 | |
* |
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
/** | |
* jQuery.rgbToHex - Converts an RGB string to a HEX string (forces length 6) | |
* @author Joshua Baker | |
* @version 1.0.0 | |
*/ | |
;(function($){ | |
$.extend({ | |
rgbToHex: function(rgbString) { | |
var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); | |
if ( ! parts) { |
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 is_mobile() | |
{ | |
return preg_match('/(ACER\ E101|Android|BlackBerry7230|BlackBerry7730|Blazer|LG\/U8120|LG\/U8130|LG\/U8138|LG\/U8180|LG\/U880|MIDP-2\.|Maemo\ Browser|MobilePhone|NetFront|Obigo|ObigoInternetBrowser|Opera\ Mini|SAMSUNG-SGH-i900|SymbianOS|UP\.Browser|WAP|Windows\ CE\;\ IEMobile|Windows\ CE\;\ PPC|Windows\ Phone|acer_S200|iPhone|iPod|webOS)/i', $_SERVER['HTTP_USER_AGENT']); | |
} |
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
$number = 10; | |
echo ($number & 1) ? "odd" : "even"; |
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 | |
$number = 5; | |
echo sprintf('%02s', $number); // 05 | |
echo sprintf('%03s', $number); // 005 | |
echo sprintf('%02s', 453); // 453 | |
// sprintf is faster than str_pad |
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
$.fn.invert = function () { return this.end().not(this); }; |
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
$.fn.inlineCSS = function() { | |
var self, style, prop, props; | |
return this.each(function() { | |
self = $(this); | |
style = this.style; | |
props = []; | |
for (prop in style) { | |
if (self.css(prop)) | |
props.push(prop + ':' + self.css(prop)); |
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 hereDoc(f) { | |
return f.toString(). | |
replace(/^[^\/]+\/\*!?/, ''). | |
replace(/\*\/[^\/]+$/, ''); | |
} | |
// usage | |
var tennysonQuote = hereDoc(function() {/*! | |
Theirs not to make reply, |
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 parseTweet(str) { | |
return str | |
.replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi, '<a href="$1" target="_blank" class="tweet-link">$1</a>') | |
.replace(/(^|[\W])@(\w+)/gi, '$1@<a href="http://twitter.com/$2">$2</a>') | |
.replace(/\#([a-zA-Z0-9-_]+)/gi, '<a href="http://twitter.com/search/%23$1" target="_blank" class="tweet-hash">#$1</a>'); | |
} |
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
// Responsive.css | |
// ------------------------------------------------------------- | |
// UP TO LANDSCAPE PHONE | |
// --------------------- | |
@media (max-width: 480px) {} |
OlderNewer