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 | |
/** | |
* varLog | |
* | |
* Logs messages/variables/data to browser by creating custom console/floating window at bottom | |
* | |
* @param $name | |
* @param $data | |
* @author Sarfraz | |
*/ |
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 | |
// include the following at the top of your script | |
define( '_JEXEC', 1 ); | |
define('JPATH_BASE', dirname(dirname(__FILE__))); | |
define( 'DS', DIRECTORY_SEPARATOR ); | |
require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php'); | |
require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php'); | |
$mainframe = JFactory::getApplication('site'); | |
//From there you can do normal development as if you were inside of Joomla's framework |
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 shortURL($url) | |
{ | |
$url = urlencode($url); | |
$ch = curl_init('http://api.bitly.com/v3/shorten?login=sarfraznawaz2005&apiKey=R_182a565c28e4eafd0e23aa113464e73e&longUrl=' . $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$result = curl_exec($ch); | |
$resultArray = json_decode($result, true); | |
$shortURL = $resultArray['data']['url']; |
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 toggleEncryption($text, $key = '') { | |
// return text unaltered if the key is blank | |
if ($key == '') { | |
return $text; | |
} | |
// remove the spaces in the key | |
$key = str_replace(' ', '', $key); |
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 benchmark($function, $args = null, $iterations = 1, $timeout = 0) | |
{ | |
set_time_limit($timeout); | |
if (is_callable($function) === true) { | |
list($usec, $sec) = explode(" ", microtime()); | |
$start = ((float)$usec + (float)$sec); |
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 img2html($image, $letters='') { | |
/* | |
img2html: | |
takes an image as an array of data that is created by PHP | |
for uploaded files. | |
*/ | |
$suffix = preg_replace('%^[^/]+/%', '', $image['type']); | |
$getimagefunc = "imagecreatefrom$suffix"; |
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 | |
backup_tables('localhost','root','','lores_new'); | |
/* backup the db OR just a table */ | |
function backup_tables($host,$user,$pass,$name,$tables = '*') | |
{ | |
$link = mysql_connect($host,$user,$pass); |
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.prototype.extends = function(parent) { | |
var sConstructor = parent.toString(); | |
var aMatch = sConstructor.match( /\s*function (.*)\(/ ); | |
if ( aMatch != null ) { this.prototype[aMatch[1]] = parent; } | |
for (var m in parent.prototype) { | |
this.prototype[m] = parent.prototype[m]; | |
} | |
}; | |
// Note not Dog = Dog.extends(Animal) | |
Dog.extends(Animal); |
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 | |
/** | |
* | |
* @flatten multi-dimensional array | |
* | |
* @param array $array | |
* | |
* @return array | |
* | |
*/ |
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
var foo = [1, 2, 3, 4, 5, 6]; | |
foo.length = 3; | |
foo; // [1, 2, 3] |
OlderNewer