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 parse($tweet) | |
{ | |
$regex = array | |
( | |
'#([a-z]{3,9}://[a-z0-9-_./\\\?&\+]*)#i', | |
'#[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}#i', | |
'#@([a-z0-9-_]+)#i', | |
'#\#([a-z0-9-_]+)#i' | |
); |
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 relative($timestamp, $format = 'M jS \of Y') | |
{ | |
$difference = time() - $timestamp; | |
if($months = floor($difference / 2592000)) | |
{ | |
return date($format, $timestamp); | |
} | |
$difference -= $months * 2419200; |
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 generate_osid($length) | |
{ | |
$rand = ''; | |
for($i = 0; $i < $length; $i++) | |
{ | |
$number = mt_rand(0, 61); | |
if($number < 10) | |
{ |
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
/** | |
* Completely strips a string of carriage returns and line feeds. | |
* | |
* @param $string String to parse | |
* @return String | |
*/ | |
function stripReturns($string) | |
{ | |
return str_replace(array("\r\n", "\r", "\n"), array("\n", "\n", ''), $string); | |
} |
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 chunkFile($file, $chunks = 2) | |
{ | |
$handle = fopen($file, 'rb'); | |
$count = 1; | |
while(false == feof($handle)) | |
{ | |
if($data = fread($handle, round(filesize($file) / $chunks))) | |
{ | |
file_put_contents(basename($file) . "-chunk-{$count}.txt", $data); |
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
[ | |
{"US":"United States"}, | |
{"CA":"Canada"}, | |
{"AF":"Afghanistan"}, | |
{"AL":"Albania"}, | |
{"DZ":"Algeria"}, | |
{"DS":"American Samoa"}, | |
{"AD":"Andorra"}, | |
{"AO":"Angola"}, | |
{"AI":"Anguilla"}, |
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
jQuery.fn.outerHTML = function() { | |
return $('<div>').append(this.eq(0).clone()).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
(function($){ | |
$.fn.disableSelection = function() { | |
return this.each(function() { | |
$(this).attr('unselectable', 'on') | |
.css({ | |
'-moz-user-select':'none', | |
'-webkit-user-select':'none', | |
'user-select':'none' | |
}) | |
.each(function() { |
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 | |
function getCategories(Mage_Catalog_Model_Category $ParentCategory) { | |
$return = array(); | |
foreach(explode(',', $ParentCategory->getChildren()) as $categoryId) { | |
$Category = Mage::getModel('catalog/category')->load($categoryId); | |
$return[$categoryId] = array( | |
'id' => $Category->getId(), | |
'name' => $Category->getName(), | |
'slug' => $Category->getUrlKey(), | |
'url' => $Category->getUrl(), |
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
$.fn.getPureRotation = function(element) { | |
var degrees = null; | |
$.each(['-webkit-transform', '-moz-transform', '-o-transform', '-sand-transform', '-ms-transform', 'transform'], function(index, value) { | |
var matrix = $(element).css(value); | |
if(degrees == null || Boolean(matrix)) { | |
var arrMatrix = matrix.match(/[\-0-9.]+/g); | |
if( | |
(parseFloat(arrMatrix[1]) == (-1 * parseFloat(arrMatrix[2]))) || | |
(parseFloat(arrMatrix[3]) == parseFloat(arrMatrix[0])) || | |
((parseFloat(arrMatrix[0]) * parseFloat(arrMatrix[3]) - parseFloat(arrMatrix[2]) * parseFloat(arrMatrix[1])) == 1) |
OlderNewer