Skip to content

Instantly share code, notes, and snippets.

@joshsmith
joshsmith / mysqlbackup.php
Created October 30, 2010 22:16
A PHP script for emailing and saving MySQL backups with mysqldump.
<?
// Creates a mysqldump and emails the resulting dump file
// Edit the following values
$dbhost = "DBHOST"; // usually localhost
$dbuser = "DBUSER";
$dbpass = "DBPASS";
$dbname = "DBNAME";
$sendTo = "[email protected]";
$sendToName = "SEND_TO_EMAIL";
@joshsmith
joshsmith / crontab
Created October 30, 2010 22:18
Crontab
0 2 * * * curl -O temp http://www.mysite.com/path/to/mysqlbackup/backup.php
// Get 100 interest recommendations from Directed Edge
$de = new DirectedEdgeRest();
$item = "user".$uid;
$limit = 100;
$tags = "interest";
$recommendedInterests = $de->getRecommended($item, $tags, $limit);
$recommendedInterestsCount = count($recommendedInterests);
if($_SESSION['last_directed_edge_request'] < time() - 600) {
// Get 100 interest recommendations from Directed Edge
$de = new DirectedEdgeRest();
$item = "user".$uid;
$limit = 100;
$tags = "interest";
$recommendedInterests = $de->getRecommended($item, $tags, $limit);
$recommendedInterestsCount = count($recommendedInterests);
@joshsmith
joshsmith / de_curl_multi.php
Created November 22, 2010 07:13
DirectedEdge Bindings curl_multi for parallel cURL requests
class DirectedEdgeRest
{
/**
* Gets multiple simultaneous recommendations from Directed Edge
* @param array $queryArray Array of the form array(0 => (array('item' => (string) $item, 'tags' => (string) $tags, 'limit' => (int) $limit))
*
* @return array Multi-dimensional array containing responses to
* queries in the order they were passed in the array
*/
public function getMultiRecommended($queryArray)
public function notifyAdviceGiverOfComment($uid, $aid, $cid, $body)
{
$advice = new Advice();
$adviceArray = $advice->getAdvice($aid);
$usersArray = array(array("first_name" => $adviceArray['first_name'], "last_name" => $adviceArray['last_name'], "email" => $adviceArray['email']));
// Return true if the commenter and adviceer are the same
// ... we don't want to send an email
if($uid == $adviceArray['uid']) {
<select>
<option>Select your timezone...</option>
<option value="376">[UTC-12] Niue Time</option>
<option value="376">[UTC-12] Samoa Standard Time</option>
<option value="52">[UTC-11] Hawaii-Aleutian Standard Time</option>
<option value="52">[UTC-11] Cook Island Time</option>
<option value="375">[UTC-9:30] Marquesas Islands Time</option>
<option value="53">[UTC-9] Alaska Standard Time</option>
<option value="53">[UTC-9] Gambier Island Time</option>
<option value="129">[UTC-8] Pacific Standard Time</option>
/*
Return URL for validation and making pay requests
array
'signature' => string 'lyOR0dvgfv0nW36/LExYn58/J4FNZRqqkzXNwjezm80VTbTCjtRcbs0HNbTI/uhMTybjblnWn5Az
USaPYErzoazPP7CNAfjT4mKKzxRwUAukvRL70+tMyHiGwwM1O6mAW0/hM/RiTafSx8TzC5UIvKq1
1H07ndhTp0m/7qETZ4w=' (length=174)
'expiry' => string '06/2016' (length=7)
'signatureVersion' => string '2' (length=1)
'signatureMethod' => string 'RSA-SHA1' (length=8)
<?php
require_once(str_replace('//','/',dirname(__FILE__).'/') .'../models/UsersFacebookStore.php');
require_once(str_replace('//','/',dirname(__FILE__).'/') .'../controllers/UsersGoal.php');
require_once(str_replace('//','/',dirname(__FILE__).'/') .'../controllers/User.class.php');
require_once(str_replace('//','/',dirname(__FILE__).'/') .'../helpers/URL.php');
/**
* @owner Josh Smith <[email protected]>
*