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
/** | |
* Convert an object to an array. | |
* | |
* @param object $variable The object to convert. | |
* | |
* @return array | |
*/ | |
function object_to_array($variable) { | |
// Gets the properties of the given object with get_object_vars. | |
if (is_object($variable) === true) $variable = get_object_vars($variable); |
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
mongo <DB> --eval 'db.dropDatabase();' |
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 ($resultSet = array(); ($row = $result->fetch_object()) !== null; array_push($resultSet, $row)); |
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
PS1='${debian_chroot:+($debian_chroot)}[\[\033[0;37m\]\t\[\033[00m\]] \[\033[0;94m\]\u\[\033[00m\] is `if [ \$? = 0 ]; then echo -e "\[\033[32m\]happy\[\033[00m\]"; else echo -e "\[\033[31m\]sad\[\033[00m\]"; fi` in \[\033[0;36m\]\w\[\033[00m\]$( | |
s="" | |
if [[ -d ".svn" ]] ; then | |
r=`svn info 2>&1 | grep "Revision: " | cut -d " " -f 2` | |
b= | |
url=`svn info 2>&1 | awk "/URL:/ {print $2}"` | |
if [[ $url =~ trunk ]]; then | |
b="trunk" | |
elif [[ $url =~ /branches/ ]]; then |
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
DBQuery.shellBatchSize = 300 |
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
sqlite old.db .dump | sqlite3 new.db |
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 unhtmlentities($string) { | |
$string = preg_replace_callback('~&#x([0-9a-f]+);~i', function ($matches) { return chr(hexdec($matches[0])); }, $string); | |
$string = preg_replace_callback('~&#([0-9]+);~', function ($matches) { return chr((int) $matches[0]); }, $string); | |
$trans_tbl = get_html_translation_table(HTML_ENTITIES); | |
$trans_tbl = array_flip($trans_tbl); | |
return strtr($string, $trans_tbl); |
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 is_ajax() { | |
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')); | |
} |
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 registerNS(ns) { | |
var nsParts = ns.split('.'); | |
var root = window; | |
for(var i = 0; i < nsParts.length; i++) { | |
if(typeof root[nsParts[i]] == 'undefined') { | |
root[nsParts[i]] = new Object(); | |
} | |
root = root[nsParts[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
<?php | |
class SampleObject extends Doctrine_Record | |
{ | |
public function setId($value) | |
{ | |
$this->_values['id'] = $value; | |
$this->_set('id', $value); | |
} | |
} |