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 | |
/** | |
* Log memory usage. | |
* | |
* Makes use of {@link https://gist.github.com/1849563 _log} and {@link https://gist.github.com/2880386 formatMemory}. | |
* | |
* @author Craig Anderson <[email protected]> | |
* @link https://gist.github.com/3336985 | |
*/ | |
protected function _logMemoryUsage() |
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
/** | |
* Get the ID of an element. | |
* | |
* Get the ID of an element, generating one if none exists and the second | |
* parameter is set to true. | |
* Makes use of {@link https://gist.github.com/craiga/4075392 randomString}. | |
* | |
* @author Craig Anderson <[email protected]> | |
* @link https://gist.github.com/3279884 | |
*/ |
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 | |
/** | |
* 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. | |
* |
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 | |
/** | |
* 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 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
# 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 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 | |
/** | |
* 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 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 | |
/** | |
* 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 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 | |
/** | |
* 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 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 | |
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 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 | |
/** | |
* 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 |