Skip to content

Instantly share code, notes, and snippets.

View hjr3's full-sized avatar

Herman J. Radtke III hjr3

View GitHub Profile
@hjr3
hjr3 / gearman-client-batch-example.php
Created August 20, 2011 22:27
Gearman client batch job example
<?php
$complete = 0;
$fail = 0;
$gmc = new GearmanClient;
$gmc->addServer();
$gmc->setCompleteCallback(function() use (&$complete) {
$complete++;
@hjr3
hjr3 / gearman-worker-exception.php
Created August 20, 2011 21:38
pecl/gearman worker exception
<?php
$gmw = new GearmanWorker();
$gmw->addServer();
$gmw->addFunction('test', function(GearmanJob $job) {
throw new Exception('Boom');
});
while(1) $gmw->work();
@hjr3
hjr3 / gearman-client-exception-callback.php
Created August 20, 2011 21:35
pecl/gearman client exception callback example
<?php
$gmc= new GearmanClient();
$gmc->addServer();
$gmc->setExceptionCallback(function(GearmanTask $task) {
$m = $task->data();
echo "Exception: {$m}\n";
@hjr3
hjr3 / gearmand-exception
Created August 20, 2011 09:36
gearmand exception handling
INFO [ main ] Accepted connection from 127.0.0.1:38684
INFO [ 2 ] Received CON wakeup event
DEBUG [ 2 ] Received OPTION_REQ 127.0.0.1:525643377 -> libgearman-server/thread.c:294
DEBUG [ proc ] 'exceptions' -> libgearman-server/server.c:360
DEBUG [ 2 ] Received RUN wakeup event -> libgearman-server/gearmand_thread.cc:409
DEBUG [ 2 ] Sent OPTION_RES to 127.0.0.1:525643377 -> libgearman-server/thread.c:339
DEBUG [ 2 ] Received CAN_DO 127.0.0.1:525643377 -> libgearman-server/thread.c:294
DEBUG [ 2 ] Received GEARMAN_COMMAND_GRAB_JOB_ALL 127.0.0.1:525643377 -> libgearman-server/thread.c:294
DEBUG [ proc ] Jobs available 0 -> libgearman-server/job.c:462
DEBUG [ 2 ] Received RUN wakeup event -> libgearman-server/gearmand_thread.cc:409
@hjr3
hjr3 / google-reader-subscriptions.php
Created August 5, 2011 15:31
List subscriptions from Google Reader API
<?php
$email = '[email protected]';
$password = 'secret';
$url = "https://www.google.com/accounts/ClientLogin?service=reader&Email={$email}&Passwd={$password}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);