2010年10月6日 星期三

一些 Google 天氣氣象用 API

取得台灣區域城市的經緯度 www.google.com/ig/cities?output=xml&hl=zh-tw&country=tw

傳回結果如

<xml_api_reply version="1">
<cities>
<city><name data="台中"/><latitude_e6 data="24150187"/><longitude_e6 data="120642999"/></city>
<city default="true" ><name data="台北"/><latitude_e6 data="25091075"/><longitude_e6 data="121559834"/></city>
<city><name data="台東"/><latitude_e6 data="22984612"/><longitude_e6 data="120987632"/></city>
<city><name data="台南"/><latitude_e6 data="23005897"/><longitude_e6 data="120182022"/></city>
<city><name data="宜蘭"/><latitude_e6 data="24692947"/><longitude_e6 data="121719546"/></city>
<city><name data="花蓮"/><latitude_e6 data="23756899"/><longitude_e6 data="121354163"/></city>
<city><name data="金門"/><latitude_e6 data="24454650"/><longitude_e6 data="118380432"/></city>
<city><name data="南投"/><latitude_e6 data="23838760"/><longitude_e6 data="120987632"/></city>
<city><name data="屏東"/><latitude_e6 data="22549506"/><longitude_e6 data="120619990"/></city>
<city><name data="恆春"/><latitude_e6 data="21977337"/><longitude_e6 data="120746490"/></city>
<city><name data="苗栗"/><latitude_e6 data="24489269"/><longitude_e6 data="120941737"/></city>
<city><name data="桃園"/><latitude_e6 data="24937587"/><longitude_e6 data="121216847"/></city>
<city><name data="馬祖"/><latitude_e6 data="26158211"/><longitude_e6 data="119928474"/></city>
<city><name data="高雄"/><latitude_e6 data="22625108"/><longitude_e6 data="120308954"/></city>
<city><name data="基隆"/><latitude_e6 data="25108981"/><longitude_e6 data="121708145"/></city>
<city><name data="雲林"/><latitude_e6 data="23755852"/><longitude_e6 data="120389665"/></city>
<city><name data="新竹"/><latitude_e6 data="24803945"/><longitude_e6 data="120964687"/></city>
<city><name data="嘉義"/><latitude_e6 data="23475449"/><longitude_e6 data="120447285"/></city>
<city><name data="彰化"/><latitude_e6 data="23992974"/><longitude_e6 data="120481845"/></city>
<city><name data="澎湖"/><latitude_e6 data="23565479"/><longitude_e6 data="119615143"/></city>
<city><name data="蘭嶼"/><latitude_e6 data="22043562"/><longitude_e6 data="121548418"/></city>
</cities>
</xml_api_reply>

取得指定城市的天氣資訊 www.google.com/ig/api?weather=Taipei 傳回結果如
<xml_api_reply version="1">
 <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" >
 <forecast_information>
  <city data="Taipei"/>
  <postal_code data="Taipei"/>
  <latitude_e6 data=""/>
  <longitude_e6 data=""/>
  <forecast_date data="2010-10-06"/>
  <current_date_time data="2010-10-06 17:00:00 +0000"/>
  <unit_system data="SI"/>
 </forecast_information>
 <current_conditions>
  <condition data="陰"/>
  <temp_f data="78"/>
  <temp_c data="26"/>
  <humidity data="濕度: 63%"/>
  <icon data="/ig/images/weather/cloudy.gif"/>
  <wind_condition data="風向:  公里/小時"/>
 </current_conditions>
 <forecast_conditions>
  <day_of_week data="週三"/>
  <low data="23"/>
  <high data="28"/>
  <icon data="/ig/images/weather/cloudy.gif"/>
  <condition data="多雲"/>
 </forecast_conditions>
 <forecast_conditions>
  <day_of_week data="週四"/>
  <low data="23"/>
  <high data="30"/>
  <icon data="/ig/images/weather/cloudy.gif"/>
  <condition data="多雲"/>
 </forecast_conditions>
 <forecast_conditions>
  <day_of_week data="週五"/>
  <low data="24"/>
  <high data="30"/>
  <icon data="/ig/images/weather/rain.gif"/>
  <condition data="多雲轉陰短暫雨"/>
 </forecast_conditions>
 <forecast_conditions>
  <day_of_week data="週六"/>
  <low data="23"/>
  <high data="27"/>
  <icon data="/ig/images/weather/rain.gif"/>
  <condition data="陰短暫雨"/>
 </forecast_conditions>
 </weather>
</xml_api_reply>

也可以搭配經緯度取得城市的天氣 http://www.google.com/ig/api?hl=zh-tw&weather=,,,24150187,120642999 (台中)傳回結果如

<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" >
<forecast_information>
<city data=""/>
<postal_code data=""/>
<latitude_e6 data="24150187"/>
<longitude_e6 data="120642999"/>
<forecast_date data="2010-10-06"/>
<current_date_time data="2010-10-06 17:00:00 +0000"/>
<unit_system data="SI"/>
</forecast_information>
<current_conditions>
<condition data="陰有霾"/>
<temp_f data="83"/>
<temp_c data="28"/>
<humidity data="濕度: 69%"/>
<icon data="/ig/images/weather/haze.gif"/>
<wind_condition data="風向:  公里/小時"/>
</current_conditions>
<forecast_conditions>
<day_of_week data="週三"/>
<low data="22"/><high data="30"/>
<icon data="/ig/images/weather/cloudy.gif"/>
<condition data="多雲"/></forecast_conditions>
<forecast_conditions>
<day_of_week data="週四"/>
<low data="23"/>
<high data="31"/>
<icon data="/ig/images/weather/cloudy.gif"/>
<condition data="多雲"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="週五"/>
<low data="24"/>
<high data="31"/>
<icon data="/ig/images/weather/rain.gif"/>
<condition data="多雲轉陰短暫雨"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="週六"/>
<low data="23"/><high data="30"/>
<icon data="/ig/images/weather/rain.gif"/>
<condition data="陰時多雲短暫雨"/>
</forecast_conditions>
</weather>
</xml_api_reply>

推薦 Google Chrome Extension 教學

剛剛在找Chrome Extension如何對外做跨網域請求,google路過了這篇

[教學]學習撰寫 Google Chrome Extension

還有附範例檔,推薦有興趣的人來學習!!

2010年10月4日 星期一

監視DOM的copy, paste事件 (oncopy, onpaste event)


根據 http://en.wikipedia.org/wiki/DOM_events 的說明


Two major types of events are added by Microsoft, and in some cases can only be used in Internet Explorer. Others have been implemented as de-facto standards by other browsers.

Microsoft在自家的ie瀏覽器上,多自訂了以上兩種類型的事件,其中oncopy, onpaste這兩個,上週發現Firefox 3.6, Chrome 6都也可以支援。

document.getElementById(ElementID).addEventListener(eventType, fn);

eventType為'copy' 或是'paste', fn為function.

雖然不是W3C的規格,但這個監視剪貼簿的事件真的不錯用,省去監視keyup/keypress/keydown或是按滑鼠右鍵複製貼上這些實作。

2010年7月10日 星期六

開啟ubuntu 10.04的smplayer硬體加速vdpau

這是筆記。 在Terminal下執行。
sudo add-apt-repository ppa:nvidia-vdpau/ppa
sudo apt-get install libvdpau1 smplayer
最後到smplayer中設置視頻輸出設備為 vdpau 目前我還沒解決的問題是,影片結束時會發生錯誤訊息。


 建議smplayer/mplayer升到最新版

ps. 更新mplayer/smplayer:

sudo add-apt-repository ppa:rvm/mplayer
sudo add-apt-repository ppa:rvm/smplayer

在/etc/apt/sources.list加下面幾行:

# smplayer
deb http://ppa.launchpad.net/rvm/smplayer/ubuntu lucid main
deb-src http://ppa.launchpad.net/rvm/smplayer/ubuntu lucid main

# mplayer
deb http://ppa.launchpad.net/rvm/mplayer/ubuntu lucid main
deb-src http://ppa.launchpad.net/rvm/mplayer/ubuntu lucid main

然後再存檔,執行
sudo apt-get update
sudo apt-get upgrade




2010年2月18日 星期四

[Mac] 同步Google與MacOSX 的通訊錄

這是一篇筆記,詳細步驟我也不是很確定。

1.勾選"通訊錄" > "偏好設定" 內的"與Google 同步"

2.勾選並設定 iTunes 裡的"聯絡資訊" > "同步 Google 通訊錄" (此步驟不確定是不是必需,但剛好我也要同步iPhone的通訊錄)

3.接下來點最上面的工具列,會有一個MobileMe的同步按鈕,裡面的"立即同步"

理論上這樣就應該可以了,平常只要有改動Google通訊錄,或是Mac裡面的通訊錄,只要點步驟3的"立即同步",就會馬上同步了。

設定好這個,就先來把兩邊重複的通訊名單好好整理一下吧,可以參考前一篇: [Google] 通訊錄 - 合併重複的聯絡人


2010年2月14日 星期日

下列外掛程式已...


這就是為什麼Apple想拒Adobe的原因之一嗎…!?

Mac上的Chrome也遇到了…lol

2010年2月12日 星期五

[Google] 通訊錄 - 合併重複的聯絡人

這功能已經有好一陣子了,這兩天正好在把mac通訊錄跟google通訊錄同步,並且整理重複的部份,所以拿出來提一下。

Google 通訊錄,是GMail的一部份,可以從GMail內的連結進入,而後來也有單獨的連結可以直接開啟,網址是:http://www.google.com/contacts

合併重複的聯絡人的方法有分為自動及手動兩種方式。

自動合併:





手動合併:

以上兩種方法都蠻方便的,自動合併應該是依照email判斷,而手動合併是自己選擇,所以彈性就更大囉。

供大家使用上參考。