<?xml version="1.0" encoding="utf-8" ?> 


<feed version="0.3" xml:lang="zh-tw" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>
<![CDATA[ Ring's Blog ]]> 
</title>
<link rel="alternate" type="text/html" href="http://blog.ring.idv.tw/" /> 
<tagline>Information for Java, Flash and Linux</tagline>
<modified>2010-03-11 00:15:52</modified>
<copyright>Copyright 2007</copyright>


<entry>
<author>
<name>Ching-Shen Chen</name>
</author>

<title type="text/html" mode="escaped"><![CDATA[ GTK - GtkMozEmbed ]]></title>
<link rel="alternate" type="text/html" href="http://blog.ring.idv.tw/comment.ser?i=348" /> 
<id>http://blog.ring.idv.tw/comment.ser?i=348</id> 

<issued>2010-03-11 00:15:52</issued> 
<modified>2010-03-11 00:15:52</modified> 


<dc:subject>Linux</dc:subject>

<dc:subject>Open Source</dc:subject>

<dc:subject>C/C++</dc:subject>


<summary type="text/plain" mode="escaped"><![CDATA[  ]]></summary>

<content type="text/html" mode="escaped"><![CDATA[ <p><img src='http://blog.ring.idv.tw/upload/a348/348.jpg'/></p><p>本文主要實作一個透過<a href='http://www.mozilla.org/unix/gtk-embedding.html'>GtkMozEmbed</a>內嵌Browser的GTK應用程式。</p><p>先安裝<a href='http://en.wikipedia.org/wiki/Gecko_(layout_engine)'>Gecko (layout engine)</a>的開發函式庫：</p><pre class='cmd'>
sudo apt-get install libxul-dev
</pre>
<p class='title'>
範例程式
</p>
<pre class='code'>
#include &lt;gtk-2.0/gtk/gtk.h&gt;
#include &lt;gtkmozembed.h&gt;
#include &lt;mozilla-config.h&gt;
#include &lt;stdio.h&gt;

int main(int argc, char * argv[])
{
        gtk_init(&argc, &argv);
        GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
        g_signal_connect(GTK_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL);
//      gtk_moz_embed_set_comp_path("/usr/lib/mozilla");
        GtkWidget *html = gtk_moz_embed_new();
        gtk_container_add(GTK_CONTAINER(window), html);
        gtk_moz_embed_load_url(GTK_MOZ_EMBED(html), "http://www.youtube.com/watch?v=TGbwL8kSpEk");

        gtk_widget_show_all(window);
        gtk_main();
        return 0;
}
</pre>
<p class='title'>
編譯並執行它
</p>
<pre class='cmd'>
gcc test.cpp -o test `pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs xulrunner-gtkmozembed`
./test
</pre>
<p>問題來了!怎麼看不到Flash咧~ 這樣就看不到<a href='http://en.wikipedia.org/wiki/Girls%27_Generation'>Girl Generation</a>的MV了.. Orz</p><p>有人有解決方案嗎？</p> ]]></content>

</entry>

<entry>
<author>
<name>Ching-Shen Chen</name>
</author>

<title type="text/html" mode="escaped"><![CDATA[ 看泡泡 ]]></title>
<link rel="alternate" type="text/html" href="http://blog.ring.idv.tw/comment.ser?i=347" /> 
<id>http://blog.ring.idv.tw/comment.ser?i=347</id> 

<issued>2010-03-10 00:21:53</issued> 
<modified>2010-03-10 00:21:53</modified> 


<dc:subject>Camera</dc:subject>


<summary type="text/plain" mode="escaped"><![CDATA[  ]]></summary>

<content type="text/html" mode="escaped"><![CDATA[ <p><img src='http://blog.ring.idv.tw/upload/a347/347.jpg'/></p><p>上禮拜六跑去台中拍照~ 隨手捕捉了一幕。</p> ]]></content>

</entry>

<entry>
<author>
<name>Ching-Shen Chen</name>
</author>

<title type="text/html" mode="escaped"><![CDATA[ Adobe AIR - iPhone 山寨版 ]]></title>
<link rel="alternate" type="text/html" href="http://blog.ring.idv.tw/comment.ser?i=346" /> 
<id>http://blog.ring.idv.tw/comment.ser?i=346</id> 

<issued>2010-03-09 23:24:30</issued> 
<modified>2010-03-09 23:24:30</modified> 


<dc:subject>Flash</dc:subject>

<dc:subject>AIR</dc:subject>


<summary type="text/plain" mode="escaped"><![CDATA[  ]]></summary>

<content type="text/html" mode="escaped"><![CDATA[ <p><img src='http://blog.ring.idv.tw/upload/a346/346.jpg'/></p><p>下載：<a href='http://ilove.ntit.edu.tw/air/iphone.air'>Adobe AIR - iPhone 山寨版</a></p><p>好久沒有碰<a href='http://www.adobe.com/products/air/'>Adobe AIR</a>了... 今天動手做了一個Adobe AIR版的iPhone影音播放，不過這其實只是一個披著iPhone外殼的介面，外加一點仿iPhone的功能，並且只「內嵌」了一首<a href='http://www.youtube.com/watch?v=TGbwL8kSpEk'>Girl Generation - Oh!</a>歌曲~ 不過這都不是重點 XD 純粹只是想練習練習Flash而已~</p> ]]></content>

</entry>

<entry>
<author>
<name>Ching-Shen Chen</name>
</author>

<title type="text/html" mode="escaped"><![CDATA[ HBase - TableInputFormat ]]></title>
<link rel="alternate" type="text/html" href="http://blog.ring.idv.tw/comment.ser?i=345" /> 
<id>http://blog.ring.idv.tw/comment.ser?i=345</id> 

<issued>2010-03-09 21:12:28</issued> 
<modified>2010-03-09 21:12:28</modified> 


<dc:subject>HBase</dc:subject>


<summary type="text/plain" mode="escaped"><![CDATA[  ]]></summary>

<content type="text/html" mode="escaped"><![CDATA[ <p>這篇主要記錄如何將HBase(0.20.3)當作Hadoop MapReduce程式的輸入來源，下述的程式碼很單純的從一個Table取出資料並直接輸出至HDFS上：</p><pre class='code'>
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

public class TestTableInput
{
	public static class Map extends TableMapper&lt;Text, Text&gt;
	{
		@Override
		public void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException
		{
			String v = Bytes.toString(value.value());
			context.write(new Text(Bytes.toString(value.getRow())), new Text(v));
		}
	}

	public static class Reduce extends Reducer&lt;Text, Text, Text, Text&gt;
	{
		@Override
		public void reduce(Text key, Iterable&lt;Text&gt; values, Context context) throws IOException, InterruptedException
		{
			context.write(key, new Text(values.iterator().next()));
		}
	}

	public static void main(String args[]) throws Exception
	{
		if(args.length != 2)
		{
			System.out.println("Usage: hadoop jar TestTableInput.jar &lt;table&gt; &lt;output&gt;");
			System.exit(-1);
		}
		
		String tablename = args[0];
		String output = args[1];

		Configuration conf = new Configuration();
		FileSystem fs = FileSystem.get(conf);
		fs.delete(new Path(output), true);

		Job job = new Job(conf, "TestTableInput");
		Scan scan = new Scan();
		TableMapReduceUtil.initTableMapperJob(tablename, scan, Map.class, Text.class, Text.class, job);	
		job.setJarByClass(TestTableInput.class);
		job.setReducerClass(Reduce.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);
		job.setOutputFormatClass(TextOutputFormat.class);
		TextOutputFormat.setOutputPath(job, new Path(output));

		System.exit(job.waitForCompletion(true) ? 0 : 1);
	}
}
</pre>
<p><img src='http://blog.ring.idv.tw/upload/a345/345-1.png'/></p><p>這裡值得注意的有二個地方，一個是Map必須繼承HBase所提供的<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/mapreduce/TableMapper.html'>TableMapper</a>(其實TableMapper也是繼承於Mapper)，它用來指定KEYIN和VALUEIN兩個類別，它們分別為：<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/io/ImmutableBytesWritable.html'>ImmutableBytesWritable</a>、<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/client/Result.html'>Result</a>，而這兩個類別分別對應的Table資料如下：</p><p>．<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/io/ImmutableBytesWritable.html'>ImmutableBytesWritable</a> = Row Key</p><p>．<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/client/Result.html'>Result</a> = Row Key+Column+Timestamp+Value</p><p>另一個值得注意的是在main方式中用到的<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.html#initTableMapperJob(java.lang.String,%20org.apache.hadoop.hbase.client.Scan,%20java.lang.Class,%20java.lang.Class,%20java.lang.Class,%20org.apache.hadoop.mapreduce.Job)'>TableMapReduceUtil.initTableMapperJob()</a>方法，它封裝了一些設定，如下圖所示：</p><p><img src='http://blog.ring.idv.tw/upload/a345/345-2.png'/></p><p>從圖中我們可以知道該方法會幫我們設定InputFormatClass為<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/mapreduce/TableInputFormat.html'>TableInputFormat</a>，還有一些相關設定，例如：<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/mapreduce/TableInputFormat.html#INPUT_TABLE'>TableInputFormat.INPUT_TABLE</a>用來設定輸入的Table，<a href='http://hadoop.apache.org/hbase/docs/current/api/org/apache/hadoop/hbase/mapreduce/TableInputFormat.html#SCAN'>TableInputFormat.SCAN</a>用來設定Scan(由於Scan是一個物件，所以必須透過convertScanToString()方法來轉碼成<a href='http://en.wikipedia.org/wiki/Base64'>Base64</a>編碼)</p> ]]></content>

</entry>

<entry>
<author>
<name>Ching-Shen Chen</name>
</author>

<title type="text/html" mode="escaped"><![CDATA[ 林榆涵 - Ring ]]></title>
<link rel="alternate" type="text/html" href="http://blog.ring.idv.tw/comment.ser?i=344" /> 
<id>http://blog.ring.idv.tw/comment.ser?i=344</id> 

<issued>2010-02-23 00:09:03</issued> 
<modified>2010-02-23 00:09:03</modified> 


<dc:subject>General</dc:subject>


<summary type="text/plain" mode="escaped"><![CDATA[  ]]></summary>

<content type="text/html" mode="escaped"><![CDATA[ <p><img src='http://blog.ring.idv.tw/upload/a344/344.jpg'/></p><p><a href='http://tw.18dao.net/%E6%98%8E%E6%98%9F%E6%AA%94%E6%A1%88/%E6%9E%97%E6%A6%86%E6%B6%B5'>林榆涵 - Ring</a>．她和筆者一樣都是在鹿港出生的~ 簡單來說~ 本站的網域名稱也就是因她而來的。</p><p>今年過年~ 我跟隨著十幾年沒見過面的姑姑一同回到家鄉鹿港，偶然地和表姐聊到才得知，原來她是我們的遠房親戚.. Orz 大約十幾年前我還是高一的時候，從電視上看到「My Today, My Tomorrow」的MV才開始注意到她，根據「<a href='http://www.wretch.cc/blog/lifedoctor/21484054'>(懷舊) Ring----林榆涵</a>」得知，她當初是從TVBS-G主辦的小室哲哉選秀會中，由日本天王製作人小室哲哉在台灣萬人選秀，選中了當年僅13歲的林榆涵並隨即簽約出唱片(藝名：Ring)，也許是同一個家鄉~ 所以筆者那時候就很喜歡她~ 上圖是筆者十幾年前買的正版CD還有她的親筆簽名(跑去台中金莎百貨的頂樓給她簽名XD)，果然是夠喜愛..Orz 不過剛剛才得知她在去年2月已經結婚了~(<a href='http://tw.myblog.yahoo.com/ringcity.tw/article?mid=4277&sc=1'>相關資源"有結婚照"</a>)</p><p>而筆者也從那時候就開始用「<b>@Ring@</b>」這個ID在「<a href='http://zh.wikipedia.org/wiki/%E6%98%9F%E9%9A%9B%E7%88%AD%E9%9C%B8'>星海爭霸</a>」界闖蕩了幾年(<a href='http://www.starcraft2.com/'>星海2</a>終於有beta..)，也用了「Ring」在「<a href='http://www.microsoft.com/games/Age2/'>AOE II</a>」征戰了一陣子(果然是不愛唸書..Orz)，接著就申請了「Ring.idv.tw」這個網域名稱一直沿用到現在~ </p> ]]></content>

</entry>

</feed>
