Fork me on GitHub

11/26/2009

[C#] 移除 List 當中重複的物件

Private List<string> removeDuplicates(List<string> inputList) {
   
    Dictionary<string, int> uniqueStore = new Dictionary<string, int>();
    List<string> finalList = new List<string>();
  
    foreach (string currValue in inputList) {
        if (!uniqueStore.ContainsKey(currValue)) {
            uniqueStore.Add(currValue, 0);
            finalList.Add(currValue);  
        }
    }
   
    return finalList;
}

[FB API] indexable column myth, lol

FQL wiki 頁面說: Another key restriction is that your query must be indexable.

也就是說在用 FQL 下條件的時候 (WHERE 後面的欄位) 必須要是 indexable 的才可以,該欄位是否可以 indexable 在 FQL table 當中有註明

測試過後,如果在非 indexable 的欄位前面加上 可以 indexable 的欄位, 有時候會行的通 lol

11/24/2009

[note] 091123

Q: 如何得知上一次 User 已經看過哪些 updated item ?

A: 介面以單張呈現的話,依 舊 -> 新 的順序呈現,並記住 user 離開介面的時候該張圖片的 updated_time,下一次撈 updated 就從該時間點開始。

11/20/2009

[FB API] FQL 欄位筆記 091120

用 FQL 抓 album 的 object_id 可行,抓到 object_id 就可以針對該相簿把該相簿的所有 comment 抓出

var query = string.Format("SELECT object_id FROM album WHERE owner IN ({0})", self.uid);

var query1 = string.Format("SELECT text FROM comment WHERE object_id IN ({0})", query);
var result = service.Api.Fql.Query(query1);

考慮到要針對特定 Album 或 Photo 加 comment 的話,利用 Comment.Add 的方法,需要參數 post_id,但是透過 FQL 去 SELECT post_id 這個欄位的時候,會是空的,起初以為是沒有發布到 Stream 上面的相簿所以沒有,經查證後結論是 comment 的 post_id 欄位全都抓不到

轉而利用 FQL 抓取 stream,利用 updated_time 和 created_time 的差異來得知該 post 有備更新過 (wiki 上面的說法是只要被 comment 或 like 都算是 update),但經驗證後發現,只有 comment 會讓 updated_time 欄位更新

11/18/2009

Unix Time 轉 .Net DateTime

透過 Facebook API 拿到 Stream 當中的時間單位是 Unix Time 格式
因此對應到 .Net 上必須轉換,這樣搜尋時才會 locate 到正確的時間點
參考資料: http://www.snippetit.com/2009/04/c-unix-time-to-net-datetime-and-vice-versa/

using System;

namespace snippetit.sample
{
struct UnixTime
{
private static DateTime BEGIN_UTC = new DateTime(1970, 1, 1);
private long utValue;

public UnixTime(long seconds)
{
utValue = seconds;
}

public UnixTime(DateTime dateTime)
{
this.DateTime = dateTime;
}

public long Value
{
get { return utValue; }
set { utValue = value; }
}

public DateTime DateTime
{
get { return BEGIN_UTC.AddSeconds((long)utValue); }
set { utValue = (long)((TimeSpan)(value - BEGIN_UTC)).TotalSeconds; }
}

public override string ToString()
{
return DateTime.ToString("yyy-MM-dd HH:mm:ss"); ;
}
}
}

將 UnixTime 轉成 long: http://www.digitalcoding.com/Code-Snippets/C-Sharp/C-Code-Snippet-Convert-Unix-timestamp.html

11/17/2009

[memo] webcam 分析膚色輔助化妝

妝要畫的好是一門深奧學問,過與不及都是失敗

如果有一個專家評等系統,可以透過 webcam 的影像來評估

提示什麼區域可能需要加強或減少,不知道有沒有賣點