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 utf8_strlen ($s) | |
{ | |
$c = strlen($s); $l = 0; | |
for ($i = 0; $i < $c; ++$i) | |
if ((ord($s[$i]) & 0xC0) != 0x80) | |
++$l; | |
return $l; | |
} |
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 file_get_contents_curl($url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. | |
curl_setopt($ch, CURLOPT_URL, $url); | |
$data = curl_exec($ch); | |
curl_close($ch); |
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 get_twitter_status ($twitter_id, $hyperlinks = true) | |
{ | |
$c = curl_init (); | |
curl_setopt ($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1"); | |
curl_setopt ($c, CURLOPT_RETURNTRANSFER, 1); | |
$src = curl_exec ($c); | |
curl_close ($c); | |
preg_match ('/<text>(.*)<\/text>/', $src, $m); | |
$status = htmlentities ($m[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
<?php | |
header('Content-type: text/css'); | |
ob_start("compress"); | |
function compress($buffer) { | |
/* remove comments */ | |
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); | |
/* remove tabs, spaces, newlines, etc. */ | |
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); | |
return $buffer; | |
} |
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 | |
//Create a variable for start time | |
$time_start = microtime(true); | |
// Place your PHP/HTML/JavaScript/CSS/Etc. Here | |
//Create a variable for end time | |
$time_end = microtime(true); | |
//Subtract the two times to get seconds | |
$time = $time_end - $time_start; |
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 generateSlug($phrase, $maxLength) | |
{ | |
$result = strtolower($phrase); | |
$result = preg_replace("/[^a-z0-9\s-]/", "", $result); | |
$result = trim(preg_replace("/[\s-]+/", " ", $result)); | |
$result = trim(substr($result, 0, $maxLength)); | |
$result = preg_replace("/\s/", "-", $result); |
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 | |
/* decide what the content should be up here .... */ | |
$content = get_content(); //generic function; | |
/* AJAX check */ | |
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { | |
/* special ajax here */ | |
die($content); | |
} |
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
.pagination { | |
word-spacing: -1em !important; | |
text-align:center !important; | |
} | |
.pagination li { | |
display: -moz-inline-box !important; | |
display: inline-block !important; | |
word-spacing: normal !important; | |
vertical-align: top !important; | |
margin-left:0px !important; |
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
# for posting data only | |
curl --data "param1=value1¶m2=value2" http://example.com/resource.cgi | |
# for posting files | |
curl --form "fileupload=@filename.txt" http://example.com/resource.cgi |
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
.anim { | |
-webkit-transform: translate3d(0,0,0); | |
-moz-transform: translate3d(0,0,0); | |
-ms-transform: translate3d(0,0,0); | |
-o-transform: translate3d(0,0,0); | |
transform: translate3d(0,0,0); | |
} |
OlderNewer