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
/** | |
* Performs an XMLHttpRequest. There are several ways in which to pass the data, each producing it's own key/value output on the server. | |
* Using urlencoded (the default) or JSON will send the all the data in key/value pairs. However, sending the data using form-data will cause | |
* all the data, aside from files, to be send as one parsable string inside the "data" key. | |
* @param Object args The arguments for the Ajax call. The args object can contain the following arguments: | |
* String method required The method to use (mainly GET/POST/UPDATE/DELETE). | |
* String url required The URL to send the HTTP request to. | |
* String type Optional The content type to send the request as. Possible values are: | |
* - application/x-www-form-urlencoded (default) | |
* - application/json |
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 | |
class PDOHandler{ | |
private $serverName; | |
private $dbName; | |
private $username; | |
private $password; | |
private $pdo; | |
private $stmt; | |
public function __construct($serverName, $dbName, $username, $password) |
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
/** | |
* Merge two objects. Warning: this function permanently changes obj1 due to it being passed by reference. | |
* If a property/method exists in both objects obj2's will overwrite the value that existed in obj1. | |
* @param obj1 The object to merge into. | |
* @param obj2 An object with properties to add to obj1. | |
* @return NULL | |
**/ | |
function mergeObjects(obj1, obj2) | |
{ | |
Object.keys(obj2).forEach(function(key) { obj1[key] = obj2[key]; }); |
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 decapitalize(str) | |
{ | |
return str.charAt(0).toLowerCase() + str.substr(1); | |
} |
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
//The function | |
Object.prototype.foreach = function(callback) | |
{ | |
for (var key in this) { | |
if (this.hasOwnProperty(key)) { | |
callback(key, this[key]); | |
} | |
} | |
}; |
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 | |
/** | |
* Check whether the user is using a mobile device. | |
* @param NULL | |
* @return Boolean $is_mobile True if this is a mobile device. Otherwise FALSE. | |
**/ | |
function is_mobile() | |
{ | |
if ( empty($_SERVER['HTTP_USER_AGENT']) ) $isMobile = false; | |
elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.) |
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 | |
/** | |
* Dump Data function. Used for debugging. | |
* @param Mixed $data | |
* @param Boolean $pretty Set to TRUE to show a prettified version of the output. Only works in Chrome with the PHPView extension. | |
* @return NULL | |
**/ | |
function dd($data, $pretty = FALSE) | |
{ | |
if ($pretty) print_r($data); |
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 | |
/** | |
* Natively create an array from an XML object | |
* @param obj $xmlObject The XML object to process. | |
* @param arr $out The generated array. This parameter is used nodes back to the function recursively. | |
* @return arr $out The XML object as an array. | |
**/ | |
function xml_to_array ( $xmlObject, $out = array () ){ | |
foreach ( (array) $xmlObject as $index => $node ) | |
$out[$index] = ( is_object ( $node ) ) ? xml_to_array ( $node ) : $node; |