2011年12月22日 星期四

[PHP] Warning: date(): ... date_default_timezone_set() ...

如果在code裡面用到date()或time()相關函式,出現以下warning:
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /path/to/code.php on line xx

解決方法就是在php.ini設定timezone
$ vim /path/to/php.ini
date.timezone = "Asia/Taipei"
或是在code裡面date()/time()呼叫前指定timezone
$ vim /path/to/code.php
date_default_timezone_set('Asia/Taipei');

2011年12月13日 星期二

[PHP] XML to Array

網路上找到的,用起來這個最順手,順便備份一下

2011年11月29日 星期二

[Tips] HTTP Proxy

由於有時候會需要測一些鎖IP的應用程式,例如Pandora,Hulu,Netflix等,大概不外乎使用VPN或是proxy取得國外的IP後才能開心的使用...

網路上的proxy一狗票,不外乎是先透過HTTP連線到對方的proxy再幫你轉導或是直接在本機瀏覽器指定對方的proxy兩種方法,可是常常不是因為對方的Proxy服務斷線,就是有時候連線到一半就會斷掉...

而還有一種可以先建立ssh連線的服務就很方便,大致上就是用10分鐘郵件在ssh center註冊一個帳號,就可以透過ssh tunnel快樂的使用24小時免費proxy服務

2011年11月22日 星期二

[Android] Native + Web on Android

今天在找一些Webkit的資料時,發現對岸的分享《淘宝客户端 for Android》项目实战, 先做個紀錄

2011年11月10日 星期四

[Embedded] Arduino

wiki上的介紹:
Arduino是一個基於開放原始碼的軟硬體平台,構建於開放原始碼simple I/O介面版,並且具有使用類似Java,C 語言的Processing/Wiring開發環境

最近在COSCUP看到這好玩的東西,而本次的COSCUP也邀請了David Cuartielles (Co-Funder of Arduino Platform)做Keynote:Arduino in the DIY Classroom,相關的演講還有使用Arduino開放平台建置智慧型插座,羊逃成熟時-以Arduino開發的互動設計商品與RepRap 3D Printer

網路上有許多不錯的資源,目前我看到繁體中文講得最詳細應該是arduino.tw台灣使用者社群和Arduino入門教學這一系列的文章吧,未來有其他資訊再繼續補充吧

reference:
* arduino.tw台灣使用者社群
* Arduino入門教學
* INTERACTIVE2GO

2011年10月25日 星期二

2011年10月14日 星期五

[Tips] Ubuntu WiFi: SIOCSIFFLAGS: Operation not possible due to RF-kill

我工作是使用阿宅專用IBM x系列的記事本,最近在同的網路切換過程中,常會切換底下的無線網路開關,但是最近遇到一個狀況是,在關閉無線網路後再打開,無線網路的driver就會掛不進來...

無線網路消失... 先試著重新啟動wlan0
$ sudo ifconfig wlan0 up
SIOCSIFFLAGS: Operation not possible due to RF-kill

查詢一下目前radio的狀態
$ sudo rfkill list all
1: tpacpi_bluetooth_sw: Bluetooth
 Soft blocked: no
 Hard blocked: no
2: phy0: Wireless LAN
 Soft blocked: no
 Hard blocked: yes
7: hci0: Bluetooth
 Soft blocked: no
 Hard blocked: no
Soft blocked: no是目前並沒有被軟體禁用,而Hard blocked: yes表示目前被硬體禁用,例如有些laptop有做硬體的radio switch可控制wifi和bluetooth的開啟/關閉,看來除了重開機以外重新載入無線網路模組也許可行

先查詢模組名稱
$ sudo lshw -class network
  *-network DISABLED      
       description: Ethernet interface
       product: 82566MM Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 19
       bus info: pci@0000:00:19.0
       logical name: eth0
       version: 03
       serial: 00:1d:72:94:8c:xx
       capacity: 1GB/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=1.0.2-k4 firmware=0.3-0 latency=0 link=no multicast=yes port=twisted pair
       resources: irq:42 memory:fe000000-fe01ffff memory:fe225000-fe225fff ioport:1840(size=32)
  *-network DISABLED
       description: Wireless interface
       product: PRO/Wireless 4965 AG or AGN [Kedron] Network Connection
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: wlan0
       version: 61
       serial: 00:1f:3b:82:b7:xx
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=iwlagn driverversion=2.6.35-28-generic firmware=228.61.2.24 latency=0 link=yes multicast=yes wireless=IEEE 802.11abg
       resources: irq:44 memory:fdf00000-fdf01fff

重新掛載
$ sudo modprobe -r iwlagn

再試著重新啟動wlan0
$ sudo ifconfig wlan0 up
wlan0: ERROR while getting interface flags: No such device

看來模組沒有重新安裝成功,重新掛載
$ sudo modprobe iwlagn

再試著重新啟動wlan0
$ sudo ifconfig wlan0 up

重新啟動NetworkManager自動抓取無線網路
$ sudo service network-manager restart

搞定收工