Archive for July 22nd, 2007

Google Maps + Google Ditu Mashup

Sunday, July 22nd, 2007

转到 Google 地图 主页Go to Google Maps Home

Some days ago I wrote a small bookmarklet to switch between Google Maps and Google Ditu, now I have a simple maskup which add google ditu as a customized layer in Google Maps.

The reason why Google Ditu in China can’t contain a satellite layer is the goverment’s policy. There are so many unbelieveable policies here in China, this one is just a simple example.

The satellite images and the maps don’t match well, actually that’s also a policy and requirement by China goverment… :(

 

Here is page with the code,use browser’s “view source” to see how this implemented.

Popularity: 15% [?]

Get google reader’s UID

Sunday, July 22nd, 2007

 

Playing with Google Reader API, in some API it need a UID.

Google Reader users are assigned a 20-digit user ID used throughout Google’s feed system. No cookies or session IDs are required to access this member-specific data. User-specifc data is accessible using the google.com cookie named “SID.”

Open Google reader, in address bar, input following and hit return:

javascript:if (prompt(”Google Reader ID”, _USER_ID)) {};

What you get a 20 digits, that’s google reader’s UID, and can be used in Google Reader API.

Unfortunately, many of the APIs only return a 500 internal error page. :( 

Popularity: 11% [?]

A elegant simple cache class for PHP 5

Sunday, July 22nd, 2007

I am using a simple cache class for PHP5 by phpguru.

Output Cache

The OutputCache class is used for caching the generated output of your scripts, or certain sections of them. It has Start and End methods, and is used like this:

<?php
if (!OutputCache::Start(”myGroup”, “myID”, 600)) {
// Generate some output (as you do)…
OutputCache::End();
    }

?>

Data Cache

The DataCache is used to cache data structures, as opposed to script output. This allows you to cache the creation of large arrays for example, or the results of slow queries. This is helpful if your pages are rather dynamic, though some areas aren’t. Or in a recently experienced situation of mine: You have one central DB server, and multiple front end webservers. A common setup. If the load is getting high on the database, you might want to move some portion of queries (ORDER BY RAND() is a good example) to the webservers instead of the database server. Thus randomisation (eg using shuffle()) happens on one of 5 webservers, instead of your single resource limited database server. Anyway, some code:

<?php
if (!$data = DataCache::Get(”myGroup”, “myOtherID”)) {
$result = $db->query(”SELECT BIG_ASS_QUERY()”);
DataCache::Put(”myGroup”, “myOtherID”, 600, $result);
    }
// Do something useful with $result
?>

Miscellaneous Bits

There’s a few configuration bits and bobs you can twiddle with if you like twiddling. setPrefix() as you can well imagine sets the prefix used in the cache data filenames. This defaults to “cache_”. setStore() sets where the data files themselves are stored. This defaults to “/dev/shm/”, since this is a convenient way to store the data files in shared memory. If you don’t have this, try changing the path to “/tmp/”. Must be given with a trailing slash.

And last, and least (so as not to be a corny ass), there’s the static variable Cache::$enabled.

Popularity: 10% [?]

A twitter based social network inside wordpress

Sunday, July 22nd, 2007

image

I am now working on an experiment: a wordpress plugin to turn wordpress into a social network, you can have friends lists, the latest updates of friends, the lastest posts of friends in your wordpress page.

This social network is based on Twitter, and it was inspired by AlexKing’s TwitterTools.

I will tweak it these days, when it’s ready I will release it so every one can play with it.

The original idea was here: Twitter+wordpress = SNS enabled wordpress

Popularity: 13% [?]

Close
E-mail It
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.