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
// {{#nl2br}} replace returns with <br> | |
Handlebars.registerHelper('nl2br', function(options) { | |
var nl2br = (options.fn(this) + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + '<br>' + '$2'); | |
return new Handlebars.SafeString(nl2br); | |
}); | |
/** | |
* {{#ifGt}} greater than helper | |
* | |
* @param1 int param1 |
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 | |
/** | |
* Used to give the full hyperlink for dynamic items | |
* | |
* @param $type string - events/news | |
* @param $id int - ID of item for link | |
* @param $title string - item title for link to strip bad chars | |
**/ | |
function seo_slug ( $type, $id, $title ) | |
{ |
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 get_alphabet() | |
{ | |
$alphabet = ''; | |
// Loop through ASCII characters until reaching 90 | |
for ($i=65; $i<=90; $i++) { | |
// store the character | |
$letter = chr($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 | |
function replace_links( $text ) | |
{ | |
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); | |
$ret = ' ' . $text; | |
// Replace Links with http:// | |
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret); | |
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
# Backup mysql databases into seperate files | |
USER="mysql-username" | |
PASSWORD="mysql-password" | |
OUTPUTDIR="/path/to/db/backup/dir" | |
MYSQLDUMP="/usr/bin/mysqldump" | |
MYSQL="/usr/bin/mysql" | |
NOW=$(date +"%m-%d-%Y") | |
MSG="Just to let you know that a full backup of db has been made onto the VPS.Kind Regards" | |
# Remove previous backups |
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
# USEFUL PLESK COMMANDS | |
# restart plesk | |
/etc/init.d/psa restart | |
# reload plesk configs (useful for vhost.conf) | |
/usr/local/psa/admin/sbin/websrvmng -a -v | |
# restart qmail | |
service qmail restart |
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
SELECT artist_name | |
FROM artists | |
ORDER BY TRIM( | |
LEADING "A " | |
FROM TRIM( | |
LEADING "An " | |
FROM TRIM( | |
LEADING "The " | |
FROM LOWER( artist_name ) ) ) ) | |
LIMIT 30 |
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
DELETE FROM table1 | |
USING table1, table1 AS vtable | |
WHERE vtable.id > table1.id | |
AND table1.field_name = vtable.field_name |
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
/** | |
* Round up to the nearest multiple of your choice. | |
* | |
* @param int $number | |
* @param int $near | |
* @return int | |
*/ | |
function get_nearest_multiple( $number, $near ) | |
{ | |
$nearest = round($number/$near)*$near; |
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
# inline | |
mail -s "Subject of Message" [email protected] < /dev/null | |
# variables as parameters | |
$MSG="This is the body of the email address" | |
$SUBJET="Test Email Subject" | |
$ADDRESS="[email protected]" | |
echo $MSG | mail -s $SUBJECT $ADDRESS |
OlderNewer