feeds, gmail, google, gtd, json, kde, kwallet, php, python, qt
In QueryTemplates, Snippets, Workflow on 19.03.2009 at 2:53
Since i’ve implemented GTD in my Gmail account i always find myself in need to see a specific query result, outside gmail interface. Such functionality was one of the main reasons of using Remember The Milk, where queries was really powerful. IMAP wasn’t an answer, since it was able to export only one label.
Meanwhile i’ve found out about libgmail, a Gmail API for Python. After couple of minutes i’ve got a custom search results inside my terminal :) This could allow to embend it almost everywhere and mainly in conky. After that i’ve decided to build an RSS feeds, scheduled in cron which send them to external server. Problem was that i didn’t want to store the password inside the script nor type it in each time.
As i’m (un)happy user of KDE4 and i know that it comes with quite wide range of language binding so why not try them out. That was PyKDE4 and PyQt4 modules. This one took some more time, since for example every app communicating with KWallet needs to have a window instance, even if it’s windowless. But there were also good sides. I’ve already had my username and password inside KWallet – i’ve configured kopete before. So basically, script doesn’t need any account information. After some struggling i’ve ended up with something like this (gmail-search.py):
Read the rest of this entry »
ajax, dom, google, html, php, phpQuery, scraping
In phpQuery on 05.10.2008 at 3:05
phpQuery can connect to Google Code’s wiki editing form, authorize itself, replace page contents and finally submit the form.
// declare main variable
$pq = null;
// create dummy document as start point
phpQuery::newDocument('
<div>')
// authorize your google account
->script('google_login')
// redirect authorized XHR component to googlecode's wiki form
->location('http://code.google.com/p/phpquery/w/edit/test')
// save result as $pq, althought we could continue the chain
// but it would break in case of error...
->toReference($pq);
if ($pq) {
// read about CallbackReference later in this post...
$pq->WebBrowser(new CallbackReference($pq))
->find('textarea:first')
->val('lorem ipsum')
->parents('form')
// first submit is Preview, so fire up second
->find(':submit:eq(1)')
// triggering submit event thought input[type=submit]:click
// is a way to choose which submit is send
->click();
if ($pq) {
// print without tags
print $pq->script('safe_print');
}
}
You can notice hot new feature – new CallbackReference($pq). Such callback sets first callback parameter to passed variable, by reference. Such pattern works with all methods accepting callbacks. Thanks to that, we can use if statements instead of function callbacks. In above example, CallbackReference object is called when click event is triggered.
Presented code snippet makes use of new Script plugin, particularly google_login.
Now it can be combined with automated XML documentation to wiki script, but this maybe for jQuery 1.3…