2012年11月26日 星期一

台灣免費網路電視清單 @ Mac OS X、iPad、iPhone

因為一些因素,需要免費的網路電視(直播電視)來解悶,一開始看到"壹電視"網路新聞台還滿黑皮的,只是看久了就發現台灣的新聞播報方式幾乎憂多於喜,看久了會不爽快,漸漸地又想找一些其他台來看看,最後才想起偉大的中華電信 hichannel 頻道,但 hichannel 多只能用 Windows 平台配 IE 瀏覽器 + Windows Media Player 才能觀看,頓時又讓人倒退幾步。


慶幸的找了一會兒,終於找到 iPad 版 XD 看來台灣廠商都對 iPad 比較有愛,像壹電視、Hinet Hichannel 部分頻道有支援 iPad (Safari瀏覽器),但在 Android 上,點開不是不支援,不然就是要用 Flash player (手機 Flash player 已經在 2012.08 月份被 Adboe 拋棄了),真不知該說什麼。


總結一下,免費的網路電視及頻道:



簡單來說,若你是用 Windows 作業系統,那網路上免費的正版網路電視都可以觀看(壹電視+hichannel),若你是用 iPad 的話,那有部分可以觀看(壹電視+部分hichanel,且必須先從hichannel ipad 版廣播進去,不能直接連[須有 http reference 的機制]),最後,若你是用 Mac OS X 系統,用 Safari 則可以透過 iPad 網頁可以看的節目。至於 Linux 的系統就沒研究了 XD 不知裝一下 Safari 瀏覽器行不行。我個人是新聞播膩了,就播播東森亞洲衛視,偶爾有娛樂性質。


至於其他非正統版權的來源,則可以逛逛 justin.tv -> Live Channel > Language (繁體中文) 找找了 :P


2012年11月15日 星期四

[Linux] 快速架設 IMAP/IMAPs/POP3/POP3s - 使用 Dovecot @ Ubuntu 12.04

之前都寫漏漏長的 FreeBSD 架設方式,這次用 Ubuntu 12.04 架一下,果真快上許多(以下設定應該沒有符合 Ubuntu /etc/* 的規範 XD)。


$ sudo apt-get install dovecot-imapd dovecot-pop3d
$ sudo vim /etc/dovecot/dovecot.conf
protocols = pop3 pop3s imap imaps
mail_location = mbox:~/mail:INBOX=/var/mail/%u
$ sudo /etc/init.d/dovecot restart 


 可以用 telnet 和 openssl 測試自家機器:


測試 POP3:


$ telnet localhost 110   (或 openssl s_client -connect localhost:995)
...
+OK Dovecot ready
user username 
+OK
pass password
+OK Logged in.
list
+OK 1 messages:
1  ###
.
quit
+OK Loggin out. 


測試 IMAP:


$ telnet localhost 143 (或 openssl s_client -connect localhost:993)
* OK ... Dovecot ready.
- login username password
- OK .... Logged in
- select INBOX
...
* OK
* 1 EXISTS
...
- OK ... Select completed.
- logout
* BYE Logging out
- OK Logout completed. 


此外,有可能一開始剛裝完後,使用上述指令測試時出現錯誤訊息,這樣的現象是因為使用的帳號尚未有信件進來,以致於 /var/mail/username 並未建立,故只需先寄信給 username 後,系統就會幫你建立對應的 mail service 資料,如此就可以測試了。


[Linux] 設定 static ip @ Ubuntu 12.04

每次要用都又查了一次 Orz 筆記一下吧


$ sudo vim /etc/network/interfaces


auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 10.0.0.180
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1
dns-nameservers 8.8.8.8


$ sudo /etc/init.d/networking restart


最後一行 dns-nameservers 若不加的話,從開機時 /etc/resolv.conf 會被清空。


2012年11月10日 星期六

iOS 開發筆記 - 使用 Xcode 4 編譯 facebook-ios-sdk 3.1

buildfbsdk01


最近摸摸 facebook-ios-sdk,發現它已經更新到 3.1,且從 3.0 開始架構有不少的變化,像是要求權限時,開始分 read 跟 write 的要求,例如登入時只能要求 read 或 write 類權限,而不能一次要求 read + write 權限,接著要再要求另一類權限時,可以在用 reauthorizeWithPermissions:defaultAudience:completionHandler: 再繼續要求。雖然 Facebook 有打包好一份 FacebookSDK 可下載到 Mac OS X 安裝使用,但有些好玩的架構 hack 則需要 source code (不見得要改 source code,可能是擴充架構時需要參考),所以就來編譯吧!編譯的概念很簡單,一種是編 app 時,要能夠找到 FacebookSDK header,另一種則是 link 時要能找到 FacebookSDK。


[Xcode] -> [Project] -> [iOS Application] -> [Empty Application] -> 隨便一個名字(此例StudyBuildFBSDK(由於個人習慣自己管記憶體,所以我就取消 Automatic Reference Counting)


接著從 github.com 下載 facebook-ios-sdk.git 回來,在此擺在 ~/facebook-ios-sdk-3.1


接著就用 Finder 開起 facebook-ios-sdk-3.1 後,把 src/facebook-ios-sdk.xcodeproj 拖到 StudyBuildFBSDK 裡頭


buildfbsdk01


接著依照 Facebook 的教學,點選 TARGETS-> StudyBuildFBSDK -> Build Phases -> Link Binrary With Libraries 中,在把需要的系統函式庫選一選(AdSupport, Accounts, Social 和 libfacebook_ios_sdk.a),接著再到 TARGETS-> StudyBuildFBSDK -> Build Settings 搜尋 other link -> 新增 -lsqlite3.0


buildfbsdk02


buildfbsdk03


接下來則是新增 header search 位置,即 ~/facebook-ios-sdk-3.1,TARGETS-> StudyBuildFBSDK -> Build Settings 搜尋 header search -> 新增 ~/facebook-ios-sdk-3.1 並設為 recursive


buildfbsdk04


如此一來應該就可以編譯成功了 :P 例如在 AppDelegate.m 中添加 FacebookSDK 相關程式碼:


#import "facebook.h"
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];


   if( [[FBSession activeSession] state] == FBSessionStateCreatedTokenLoaded ) {
      NSLog(@"test in");
   }

   // Override point for customization after application launch.
   self.window.backgroundColor = [UIColor whiteColor];
   [self.window makeKeyAndVisible];
   return YES;
}


此外,執行還是會出錯,因為還要去 Supporting Files -> SutdyBuildFBSDK-info.plist 中,新增 FacebookAppID 後才能確保程式可以跑,只是還要補上額外的東西才能正式使用囉(參考 Facebook 教學)。


buildfbsdk05


2012年11月9日 星期五

Android 開發筆記 - 使用 Canvas 畫圖

android_canvas


一年前,我的好同事就一直在用 HTML5 Canvas 做出很多很讚的作品,但那時我的方向不一樣,一直沒有接觸。最近則開始想要在 android 畫畫圖,除了很底層的 OpenGL ES 外,就想到 Canvas 啦。


在這邊簡單筆記 Android 上 Canvas 的使用(最偷懶的使用方式):


public class MainActivity extends Activity {


   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //setContentView(R.layout.activity_main);
      setContentView( new View(this) {
         Paint mPaint = new Paint();
         Path mPath = new Path();


         @Override
         protected void onDraw(Canvas canvas) {
            // TODO Auto-generated method stub
            super.onDraw(canvas);


            // env init
            int width = this.getWidth();
            int height = this.getHeight();
            int radius = width > height ? height/2 : width/2;
            int center_x = width/2;
            int center_y = height/2;


            // prepare a paint
            mPaint.setColor(Color.BLACK);
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setStrokeWidth(5);
            mPaint.setAntiAlias(true);

            // draw a circle
            canvas.drawCircle(center_x, center_y, radius, mPaint);

            // draw a rectangle
            mPaint.setColor(Color.GREEN);
            canvas.drawRect(center_x - radius, center_y - radius, center_x + radius, center_y + radius, mPaint);

            // draw a triangle
            mPaint.setColor(Color.MAGENTA);
            mPath.moveTo(center_x, center_y - radius);
            mPath.lineTo(center_x - radius, center_y);
            mPath.lineTo(center_x + radius, center_y);
            mPath.lineTo(center_x, center_y - radius);
            canvas.drawPath(mPath, mPaint);

            // draw some text and rotation
            mPaint.setTextSize(50);
            mPaint.setTextAlign(Paint.Align.CENTER);
            mPaint.setTypeface(Typeface.create(Typeface.SERIF, Typeface.ITALIC));
            mPaint.setColor(Color.RED);


            canvas.save();
            canvas.rotate(45, center_x, center_y);
            canvas.drawText( "Android Canvas" , center_x , center_y, mPaint);
            canvas.restore();


            mPaint.setColor(Color.BLUE);
            canvas.drawText( "changyy.pixnet.net" , center_x , center_y + 70, mPaint);
         }
      });
    }
}