2008/08/29


Atompub使うと簡単。
use strict;
use warnings;

use Atompub::Client;
use XML::Atom::Entry;
use utf8;

my $username = 'xxxxxxxxxxxxxxxxxx';
my $password = 'xxxxxxxxxxxxxxxxxx';
my $uri = "http://d.hatena.ne.jp/$username/atom/draft";

my $client = Atompub::Client->new;

$client->username($username);
$client->password($password);

# 下書きを一覧
my @entries = $client->getFeed($uri);
for my $entry (@entries) {
    next if not $entry->id;
    warn $entry->link->href."\n".$entry->title."\n\n";
}

# 新規下書きエントリ
my $entry = XML::Atom::Entry->new;
$entry->title('下書きテスト');
$entry->content('はてダで下書き');
my $entry_uri = $client->createEntry($uri, $entry);
warn $client->errstr||'\n';

# 下書きを上書き
$entry->content('はてダで下書きを上書き');
$client->updateEntry($entry_uri, $entry);

# 下書きを削除
$client->deleteEntry($entry_uri);

# 公開用に新規下書きエントリ
$entry = XML::Atom::Entry->new;
$entry->title('下書き公開テスト');
$entry->content('はてダの下書きを公開してみるテスト');
$entry_uri = $client->createEntry($uri, $entry);
warn $client->errstr||'\n';

# 下書きを公開
$client->ua->default_header('X-HATENA-PUBLISH' => 1);
$client->updateEntry($entry_uri, $entry);
ゴミのエントリは、適当に消して下さい。
ところで1つも下書きエントリがない状態で、getFeedするとルートのlinkが取れてしまうのだけど、これは仕様だろうか。
Posted at by



2008/08/22


APIs for Finding Location

Google launched two APIs for finding the location of a user from a web application. The most simple way, which is also the least precise, is to derive some information about location from the IP. Google AJAX API has an object named google.loader.ClientLocation that includes "metro-level granularity properties": country, region, city, low resolution latitude and longitude. This could be useful if you want to customize a web page for a specific country or to prefill information about location. You probably noticed that google.com automatically redirects to the appropriate international domain and that when you create a Google account your country is already selected.

http://googlesystem.blogspot.com/2008/08/apis-for-finding-location.html

Developer's Guide - Google AJAX APIs - Google Code

When an application makes used of the AJAX API loader, the loader attempts to geo locate the client based on it's IP address. If this process succeeds, the client's location, scoped to the metro level, is made available in the google.loader.ClientLocation property. If the process fails to find a match, this property is set to null.

http://code.google.com/apis/ajax/documentation/#ClientLocation http://code.google.com/apis/gears/api_geolocation.html
試しにやってみたら"google.loader.ClientLocation.address.region"で"「大阪府」って出た。
あと"ClientLocation.latitude"と"ClientLocation.longitude"で緯度経度が得られるので、setCenterで中心位置を変更出来る。
google.load("maps", "2");
google.load("search", "1");
google.setOnLoadCallback(function() {
    var map = new google.maps.Map2(document.getElementById("map"));
    map.setCenter(new google.maps.LatLng(
        google.loader.ClientLocation.latitude,
        google.loader.ClientLocation.longitude), 10);
});
実行結果は以下

続きを読む...

Posted at by




Booで。
class _X:
  s as string

  def constructor():
    s = "ひだまり"

  static def op_LessThan(x as _X, v as string):
    print x.s, v
    return x
 
  static def op_Division(x as _X, v as object):
    if v.GetType() == typeof(int):
      x.s += "スケッチ"
    else:
      x.s += "365"
    return x

X = _X()
_ = 1

X / _ / X < "来週も見てくださいね!"
実行は
C:¥temp> booi yuno.boo
ひだまりスケッチ365 来週も見てくださいね!
でインタプリタ起動するか
C:¥temp> booc yuno.boo
Boo Compiler version 0.8.2.2960 (CLR v2.0.50727.832)

C:¥temp> yuno.exe
ひだまりスケッチ365 来週も見てくださいね!
でコンパイル実行。
boo初めて使ってみたけど、これいいかも。
monoでの実装とかあるのかな?

ちなみにpythonに似てるけど、静的型付けです。あとオペレータの判断順番がpythonと違うので、pythonのまま移植すると「ひだまり365スケッチ 来週も見てくださいね!」になるので要注意

Posted at by