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 | |
//2.x | |
function queryToDos(SS_Query $qry) { | |
$dos = new DataObjectSet(); | |
while ($record = $qry->next()) { | |
$dos->push(new {$record['ClassName']}($record)); | |
} | |
return $dos; |
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 queryToJSON(SS_Query $qry) { | |
//the keys you want to code into JSON, this is to white list your array | |
$jsonKeys = array( | |
'ID' => 'ID', | |
'Title' => 'Title', | |
'Content' => 'Content' | |
); | |
$dataToEncode = array(); |
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 doAJAXForm($form,$replaceEl,extraData) { | |
var replaceSelf = false; | |
if (extraData) { | |
extraData = '&' + extraData; | |
} | |
else { | |
extraData = ''; | |
} | |
if (!$replaceEl) { | |
$replaceEl = $form; |
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 | |
if ($geocode) { | |
$qry = new SQLQuery( | |
array( | |
'*', | |
'DistanceFrom' => "(6371 * acos(cos(radians(".$geocode['lat'].")) * cos(radians(Latitude)) * cos(radians(Longitude) - radians(".$geocode['lng'].")) + sin(radians(".$geocode['lat'].")) * sin(radians(Latitude))))" | |
), | |
'Store' | |
); |
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
/** | |
* AJAX Q | |
* | |
* The AJAX queue object that will handle storing, queing and execution of ajax | |
* requests. | |
* | |
* This was built to handle the circumstance where you'd need to make a lot of | |
* requests to the server repeatedly, but didn't want to flood the server or the | |
* subsequent requests relied on the responses of the earlier requests. | |
* |
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
/** | |
* Add selector for clients when viewing invoices / estimates | |
* | |
* uri: /invoices | |
* url: /estimates | |
* | |
* todo: Allow selection by project name | |
* todo: Allow sorting to work properly | |
* todo: Allow 'per page' dropdown to work / have more options | |
*/ |
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
#!/bin/bash | |
# To do: | |
# - Force install (regardless of installed tarsnap version) via flag | |
# - Set version via flag | |
# - Set TMP_DIR via flag | |
# - Skip software insall via flag | |
# - Check signature automatically | |
VERSION=1.0.37 | |
TMP_DIR=/tmp/tarsnap | |
REMOVE_DIR=false |
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
//iterate over all inputs | |
$(':input').each(function() { | |
var $this = $(this); | |
//eliminate invalid input types | |
if (!$this.is(':button,:checkbox,:file,:image,:radio,:reset,:submit')) { | |
var placeHolder = $this.attr('placeholder'); | |
//if there's a placeholder | |
if (placeHolder) { | |
//create a label | |
var $label = $('<label for="' + $this.attr('id') + '">' + placeHolder + '</label>'); |
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
#!/bin/bash | |
## | |
## | |
## This scipt was inspired by http://serverfault.com/questions/65365/disable-local-delivery-in-sendmail/128450#128450 | |
## It stops webservers sending mail that is addressed to the local hostname to localhost and instead looks remotely for a mail server | |
## | |
## | |
# Install sendmail-cf as this is required to customise the config |
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
#!/bin/bash | |
# Run the command to check the status and pipe it to grep | |
/etc/init.d/mysqld status | grep -vqs 'running\.\.\.' | |
# Use the last exit code to evaluate if mysqld needs restarting | |
if [ $? -eq 0 ]; then | |
echo `date` | |
/etc/init.d/mysqld restart | |
fi |
OlderNewer