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 | |
trait Logging { | |
/** | |
* Write a log message. | |
* | |
* Write a log message to $this->_logCallback, $this->_logFile and/or | |
* syslog. | |
* Parameters are as for {@link http://php.net/sprintf sprintf}, except | |
* that a syslog priority (LOG_EMERG to LOG_DEBUG; see http://php.net/syslog) |
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 | |
/** | |
* Dump the output of var_dump to a log file. | |
* | |
* Dump the output of var_dump to a log file. Requires {@link https://gist.github.com/1849563 this _log function}. | |
* | |
* @author Craig Anderson <[email protected]> | |
* @link https://gist.github.com/gists/2699763 | |
*/ | |
protected function _logDump($var) |
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 | |
/** | |
* Slugify a string. | |
* | |
* Convert "Hello, world! It's Craig in 2012." to "hello-world-its-craig-in-2012". | |
* See test_slugify for more examples. | |
* | |
* @author Craig Anderson <[email protected]> | |
* @link https://gist.github.com/2716157 |
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 | |
require_once("GetUrlHttpErrorException.php"); | |
include_once(dirname(__FILE__) . "/../removeOldFiles/removeOldFiles.php"); | |
/** | |
* Get a URL. | |
* | |
* Get a URL, optionally caching the response. Will remove old cached files if {@link https://gist.github.com/craiga/3161529 removeOldFiles} is present. | |
* |
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 | |
/** | |
* Format a number of bytes. | |
* | |
* Format a number of bytes into a readable string in either IETF (kibibyte, | |
* 1024 bytes) or SI (kilobyte, 1000 bytes) units. | |
* Produces output like "1 byte", "28 bytes", "4 MB" or "22 GiB". | |
* | |
* @param $memory The number of bytes to format. The result of |
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 | |
/** | |
* Print some XML. | |
* | |
* FIXME: This probably doesn't do a good job at prettifying whitespace when supplied with a DOMNode. | |
* | |
* @author Craig Anderson <[email protected]> | |
* @link https://gist.github.com/2934093 | |
*/ |
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 | |
/** | |
* Normalise a URL. | |
* | |
* Normalise a URL. Returns null if the URL couldn't be normalised. | |
* | |
* @author Craig Anderson <[email protected]> | |
* @link https://gist.github.com/2986522 | |
*/ |
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
# get ip address to put into your workstation's /etc/hosts | |
sudo ifconfig eth0 | |
# set up ssh (courtesy of Doug) | |
sudo aptitude install openssh-server | |
sudo sed -i 's/^ChallengeResponseAuthentication.*$/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config | |
sudo service ssh restart | |
# tab completion | |
sudo aptitude install bash-completion |
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 | |
/** | |
* Remove old files. | |
* | |
* Remove files older than one day (or the age specified). Will not remove old directories. | |
* | |
* @param $directory The directory to remove files from. | |
* @param $recursive Whether to remove files from subdirectories as well. False by default. | |
* @param $age The minimum age of a file before it is removed. One day by default. |
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 | |
/** | |
* Format a number of seconds. | |
* | |
* Format a number of seconds into a number of seconds, minutes, hours and days. | |
* Produces output like "1 second", "110 seconds", "4 hours" or "123 microseconds". | |
* The accuracy gets a little rough once it gets into months, but it's only meant | |
* as an approximation. | |
* |
OlderNewer