九月 27, 2015
» How to detect foreground process name in Android with Lollipop

(Katwijk.Holland)

Android 一直改版,原本可以用的功能,因為安全性,因為有的 app 會亂搞,所以把許多流程和功能不是改得變複雜,就是直接拿掉了。

原本一個很單純的抓取前景正在執行的程式名稱的功能,也變得愈來愈複雜。之前只需要抓一下getRunningTasks() 就可以找到想要的結果,但是現在得要為 application 加上新的 permission PACKAGE_USAGE_STATS,然後還要要求使用者進到 Settings > Security > User Apps with access to usage data , 勾選該 application 後才可以。

這種小功能還需要使用者大費周章的做一堆事,實在是很麻煩。

下面的程式碼,是透過 user stats去取得這資料。另外,如果使用者還沒有在 Settings 中勾選 app 的話,出來的 runningTask 會是空的,這時應該要用程式碼中最下面的 startActivity 去把設定的畫面叫起來,叫使用者打勾。使用者不打勾,你還是抓不到資料的。



八月 13, 2014
» 在 Pebble 上顯示中文的 Android 通知,和開發 Pebble 的簡單程式

(Lyon)

想在 Pebble 上顯示中文的話,iOS手機可以裝 PebbleCC ,Android手機的話可以裝 YaNC。不過 YaNC 在 Android 的 PlayStore 是要錢的。目前用 YaNC 的感覺還不錯。只是,如果一天下來訊息比較多的話,手錶變得比較快沒電。因為它是把訊息的內容傳成圖檔,然後把圖檔發到手錶上呈現。

另外,在 Mac 上下載了 Pebble SDK ,試著用 command-line 開發 pebble 上的 app。目前只試了一下 persistent storage 的 API,寫了個手動的 counter,還沒仔細看它 UI 的架構和其他功能的 library。希望有空可以逐漸熟悉,看能有什麼樣的應用方式。

https://developer.getpebble.com/2/guides/


七月 22, 2014
» AutoScreenOnOff 再升級

(Dansui.Taiwan)

前幾天花了半天加入 app 黑名單的功能後,評價還不錯,至少止血了。今天趁著明天颱風要來早點回家,花了一個多小時,把一個單純的 screen off widget 給加了進去。

花的時間比預料的快很多,因為本來在 notification 的互動中就已經有這個 intent 和處理邏輯在了,今天只是照著原本的 widget 再生一個出來,然後設定個 pendingIntent 給它,就收工了。

另外,還隨手將 changelog 的輸出方式改了一下,改成每個版本都會是一個新的 string ,如果其他語言沒有翻譯的話,那自然會抓到預設英文的版本,省下我每次升級都要把同樣的字串貼到每個語系的changelog_html中。

六月 22, 2014
» 如何讓 Android 中的 Activity 不要顯示任何畫面

(ShinShan.Dream Lake.Taipei)

北部難得可以找到人少一點的景點。
之前來路跑竟然沒有看到。

*****
最近又在寫小 app,但總是在畫面上卡關,一直無法很順利的進行。
今天早上起床,順手又改了幾個自己在使用上覺得不夠方便的地方,
然後,就是這麼自然地,在網路上逛到了如何解決自己試了很久都沒成功的功能。

根據 app 的需求,我在 AndroidManifest.xml 中透過 intent filter來接收某些事件。當事件發生時,被叫起的 Activity 其實並不需要顯示畫面,我只是要將事件再傳給 Servic,讓 Service 把事情處理掉。但是卻老是卡在 Activity 或多或少會秀一下白畫面,或黑畫面,或是閃一下,才會乖乖的不見。即使在 onCreate() 中呼叫了 finish()也解決不了這個問題。

今天在網路上找到的解法,很簡單。只需要設定一個 theme 就好了。雖然這方法自己也試過,但應該是少了些什麼其他的設定吧。好吧,答案就是:

            android:theme="@android:style/Theme.NoDisplay"

REF:
http://stackoverflow.com/questions/4551868/how-to-completely-get-rid-of-an-activitys-gui-avoid-a-black-screen



一月 17, 2014
» FFT in Python

想知道一段訊號的頻譜,實務上我們會運用數位訊號處理,對這段訊號抽樣,得到一段時間序列;並計算時間序列的離散傅立葉轉換(Discrete Fourier transform, DFT)。然後據以估算出離散時間傅立葉轉換(Discrete-time Fourier transform, DTFT),最後再視需要,將頻域橫軸由離散時間的數位頻率(Ωk = ωkTs = 2π fk/Fs)換算回連續時間的訊號頻率(fk)。 張智星老師的 on-line book《音訊處理與辨識》〈離散傅立葉轉換〉這個章節,有許多運用快速傅立葉轉換(Fast Fourier transform, FFT)的教學, FFT 其實就是 DFT 的快速算法。張老師是以 Matlab 作為程式範例;經實際嘗試,我發現可以很容易轉成 Python code ,以下就看看執行結果截圖: 其程式如下:

十二月 16, 2013
» The Art of Design

為甚麼好的設計會來自於差的設計呢? Scott 在 Why Good Design Comes from Bad Design 提到攻讀 CMU Computer Science 博士時選了門介面設計課,第一堂課上他發現一位年輕人素描著隨身聽的各種變異版本,而且圖紙上已經堆積了三、四十種不同考量的版本了。 Scott 於是湊過去問這個小伙子「幹嘛費勁畫那麼多草稿?」,小伙子發楞了好一會才笑著回說: I don't know what a good idea looks like until I've seen the bad ones. 經過時日洗煉, Scott 後來也體會到當初認為多餘的作法,其背後的精神,他提到: Each new idea I sketched out was more informed than the last. Each bad idea

六月 10, 2013
» 在Lime HD中快速啟動語音輸入法

(富貴角.Taiwan)

剛剛試了一下谷歌的語音輸入,覺得有些時候應該蠻實用的。所以打算幫它在Lime HD中加個快速切換的功能。在Lime HD中原本就有開啟Google語音輸入法的方式,只是我覺得有點太麻煩了。原本的方式是:
1. 長按左下方的設定鈕,這時會跳出一個對話視窗,可以設定輸入簡繁中文的切換,分割鍵盤等一些選擇。畫面最下方則是切換成語音輸入法。

通常會想用語音輸入的時機,都是在手不方便慢慢點螢幕的時候,所以,操作步驟愈多,就愈麻煩。原本我是打算在長按(中/En)按鈕時,直接啟動語音輸入。目前這個按鈕的長按並沒有預設的作用,所以很適合。

可惜的是,我不知道怎麼debug InputMethodService,所以沒有辦法短時間內看清楚在LIMEService中的長按功能,是怎麼前後串起來的。一直找不到好的interception point。

無意中卻發現了,原來Lime有針對輸入的整個面版實作swipe的key listener!!做為一個多年的Lime HD愛用者,竟然不知道有這麼一回事。看了原始碼後,它的目前對應功能是:
滑上:開啟設定對話窗(跟長按設定按鈕一樣)
滑下:關閉輸入法
滑左:模擬刪除鍵
滑右:送出目前選擇的候選字

既然設定對話窗已經可以很方便地長按設定鍵來開啟,我把"滑上"給改成呼叫Google語音輸入法。程式碼很簡單,在LIMEService中的swipeUp(),把原本的code換成StartVoiceInput()就可以了。

六月 6, 2013
» Some hacking articles about IdeaVIM under Intellij

 (Leiden.Netherlands)

IdeaVIM is a vim-like input plugin for intellij IDE, good for text editing but not so powerful if you want to use it for other IDE tasks, for example accessing menu actions by defining keyboard shortcuts.

Fortunately, someone in Japan branched the source codes on GitHub, and wrote some tweaks to make it possible to configure all kinds of Intellij menu items to keyboard shortcuts as you wish in a config file.

Tried downloading the modified codes and built it in Intellij; installed the plugin in my Android Studio environment. Working like a charm~

my settings in _ideavim.groovy


REF:
http://d.hatena.ne.jp/masanobuimai/20120720/1342764219
http://d.hatena.ne.jp/masanobuimai/20080323#1206277040


六月 4, 2013
» How to make testing work under Android Studio

(Geneve.Swiss)

It's such a pain to look for solutions for tasks on Android Studio. When can it be mature enough and more well documented for developers?

I would like to write some test cases for my small app, but I couldn't find a way for adding test cases into Android Studio project and have it run successfully.

After wandering around on the internet for a long time, eventually I found a link that did helped me out (see reference below). As Google I/O 2013 video said, a new android build system made of gradle is released, which will be more flexible, more powerful, more etc, etc. However, currently, it 's not well integrated into Android Studio. Some modification in Android Studio won't be directly reflected in gradle build scripts. Well... then, how do I know when I should modify build scripts my self? And to write it by myself, I have to learn groovy first, because that's the language Gradle used to write its build configuration files. How could I master these things in a short time...

Anyway, the solution for my pain point above is to modify build.gradle under the root directory of app project, and make sure all the instrument source folders are well set up. Now I can use cradle to run test cases and generate report files. However, I can't make it work in Android Studio still. orz...


REF:
http://blog.crowdint.com/2013/05/24/android-builds-on-travis-ci-with-gradle.html

六月 1, 2013
» Gradle build error in comman line for Android Studio app projects

I saw someone met the same problem on StackOverflow. Fortunately,  I found out how to make it work. So leave some notes here:
1. upgrade Gradle version to 1.6
2. Afterward, running "gradle build --stacktrace", you will see that ANDROID_HOME environment variable is required to be set up.
3. on Mac, add following line to your ~/.bash_profile
export ANDROID_HOME="/Applications/Android Studio.app/sdk/"

Now it should work like a charm!

五月 29, 2013
» [雜談] 程式中的命名風格

很久以前一直在規劃要弄個雜談區,方向大概就是放一些「看起來雜亂無章,不曉得能做什麼的嘴砲文」… 其實就是把一些放在D槽多年的資料移到雲端備份XD 但既然要丟上雲端,還是會盡量讓內容看起來有條理一點。作為系列的第一篇,先來個時事文吧。


前幾天在 BBS 上看到命名風格的討論,由於持續了幾天,就稍微看了一下大家在聊些什麼。那一串的原點是有人提到對專案中出現「型別前綴」這種參數命名原則不太滿意,結果很多人就爆炸了XD

工作或專案上的 coding rule 通常沒有什麼對錯可言,就是一組大家都能接受的規則而已。在團隊成員對於程式碼的表達有一致的認知,而不是各自表述時,才有機會繼續談後面的合作。而「命名風格」雖然帶有不少藝術與美感(順眼)等主觀成份,也不是因此就沒有討論的空間。

編寫程式不完全是讓電腦系統可以運作那麼單純,也是程式設計師們傳達自己想法的管道。程式的編寫跟寫作一樣,雖然不必使用到華麗的詞藻,但我相信一份敘事簡明的程式,閱讀起來也是賞心悅目。作為個人能力的養成,還是值得花一點時間研究… 至於在團隊中使用,以及成員間的溝通協調,就真的是政治問題或人品問題啦~

通常在決定依循哪一種風格時都有很多考量,可能是客戶的要求、團隊的傳統、被什麼書籍文章洗腦、或是開發平台與程式語言的影響。不過在實際的開發中,我的經驗是命名只要不是太誇張的縮寫或使用冷僻的英文單字,對可讀性的影響微乎其微。曾經遇過比較誇張例子是用德文來命名變數,這對於完全不懂德文的我還真的是「不夠直覺」的命名。除了那次經驗外,即使接觸到好幾種不同風格也不會真的造成什麼困擾。

那為什麼還要寫這篇文章呢?雖然這種風格觀點是很容易被戰到爆的萬年戰文,而且我也討厭寫個程式還要有一堆規約來限制自己,但最近也常常需要向別人說明為什麼程式會寫成某種樣子,就趁這個機會整理一下,順便也檢視一下自己的習慣。其實程式寫久了通常會慢慢有自己的習慣,例如我私底下愛用的縮寫風格已經蠻固定了,就算現在看到多年前的變數命名,還是可以直覺理解用途。會需要特別留意命名方式主要還是為了和別人溝通,以及維護性與一致性吧。

順帶一提,整理這篇文章其實花了好幾天時間,因為一直以來都是覺得有問題就自動調整一下,完全沒特別選擇要用什麼風格,只好把手邊的程式都抓出來整理一下XD


一般提到「型別前綴」的命名風格通常會直接聯想到「(系統)匈牙利命名法」(Systems Hungarian Notation),對於以前接受過微軟平台技術洗禮的人多半不陌生。到了現在的 .Net Framework Naming convention 則改為建議 DO NOT use 了。我個人並不討厭加上綴字,命名時適當地加上綴字其實是有助於理解的。匈牙利命名法這種風格,最早也曾經嘗試使用過一陣子,但隨著 C 以外的語言越用越多,尤其是在可以大量創造型別的語言中(例如 C++ 和 Python),型別要怎麼加上去就會是個大問題;再加上後來覺得這樣的命名其實也曝露了實作細節,遇到要改型別時很麻煩,就漸漸地不再使用了。真的需要在命名中說明型別時,也會盡量以抽象型別為主,避免直接使用基礎型別。

除了團隊和專案的規範外,我私底下慣用的命名風格應該還算單純,沒什麼麻煩的規定。大部份情況都是很隨性地命名,整理一下大概就是幾個規則是比較固定會使用的:

命名

原則上只要沒有特別限制,使用全小寫、hyphen 分隔的命名方式,不支援的時候則改用 camel case。在可能的範圍內盡量用不影響可讀性或比較通用的縮寫,以字少的優先。主要是在使用不同語言時可能會有一些差異。舉例來說,在符號使用限制少的 forth 或 scheme / lisp 中可以用全小寫、hyphen 或斜線符號區隔的命名風格:

(define module-do-something ...)

(defun module/do-something ...)

而在 C 中只能用底線(underscore)分隔 namespace / module name 與 tag name:

RetType Module_Method(ArgType ...);

遇到需要標明存取控制範圍的時候,例如 private,在 C 中是在前面或後面加底線,在 Emacs lisp 這種沒有模組概念的語言可能改成在 module name 後面寫成 --,Python 則是在前面加上底線… 大概也是依語言而異。

型別

可以的話盡量定義抽象型別來使用:例如在 C 裡透過 typedef 定義新型別,通常會加上 _t 作為後綴。新的 C++11 也可以定義 type alias。命名時盡量以大寫字母開頭,以前在 Io 中接觸到這種風格,覺得還不錯就繼續用了。

變數

全部小寫,有必要時使用 lower camel case。全域變數會加前綴,大概會是 g_ 之類的,不過通常很少出現全域變數所以不常用。

遇到代表容器的變數,通常以英文的複數型式命名,例如 users。有需要的話可以加上輔助說明用的前綴,例如表達數量時用 numBooks

需要特別提醒操作方式或用途的時候,可能會加上一點修飾,例如一個暫時使用的變數可能會加上 tmp 前綴;另外就是在 C/C++ 中被 wild pointer 戳死的機會太多了,這時也會特別在前面加上 p 提醒自己。

常數

包括列舉(enum)用的常數,通常全部以大寫命名。因為沒辦法 camel case 所以單字之間可能會使用 hyphen 或底線分隔。不過在 scheme 或 lisp 中多半還是小寫。

函式

通常是動詞開頭的型式,例如 do-create-send-。如果是判斷用的函式則看各語言風格,一般是 is 開頭的型式,這也是從 Io 來的風格,但在 forth 和 scheme 中則是在最後加上 ? 後綴:

(if (buffer-empty? ...)

寫 lisp 時則改用 -p

(if (buffer-empty-p ...)

其他還有像轉換資料用的函式命名,依語言的不同可能會用 >->-to- 等分隔。

談這種東西很容易混到其他撰寫風格的討論,命名的部份大概就是這樣吧。各語言的細節太多了,一時也講不完,原則上我會盡量先參考語言慣例,這樣在搭配標準函式庫使用時才不會變成混合風格。至於很多人建議的底線,因為輸入實在很麻煩,對可讀性好像也沒有什麼決定性的幫助… 自從我改用 emacs 寫程式後就盡量少用了,反正編輯可以靠 subword,閱讀時真的不行就開 glasses-mode 吧 :-p

不過說到命名,在規則受限的語言中還真的很麻煩,我覺得與其用底線,還不如用 hyphen(可以少按一個 shift),但在 C 連 - 都不准用。在 forth 中只要不是空白字元都可以用,命名時的表達力就豐富多了,適時使用 ->>>? 等符號對可讀性還是有些幫助的。單就這一點來看,haskell 很不錯,可以用符號設計很多可愛的運算子XD

這樣整理下來,我的適應力應該還算不錯吧,大概都是語言慣例就用了XD 但實際上在寫的時候,除了團隊要求的情況外也不是很嚴格地要求自己遵守啦,反正寫久變成習慣的,不必太要求就會成形;真的需要違反原則時,大概也不會出現太誇張的命名。硬是要規定套用某些規定反而失去發揮的空間,我想一般寫程式的人並不是單純的打字員,應該都不會喜歡的吧。


Filed under: Programming, Talk

五月 28, 2013
» OrientationEventListener on Android to get current rotation degree

(Central Park.New York)

Strangely, it's not possible to get current rotation angle in android directly, except for getting the fixed 4 rotation modes: 0, 90, 180, 270. In order to get precise rotation degrees instead of rotation modes, OrientationEventListener can be used. Once it's implemented, you can get the rotation degree in onOrientationChanged(). It's a lot easier than manipulating values from all the sensors like gyroscope, accelerator, etc.

REF:
http://android-er.blogspot.tw/2010/08/orientationeventlistener-detect.html





五月 24, 2013
» Tips for using AdMod module in Android Studio

(Geneva.Swiss)
It's pain in the ass to use Android Studio now, since it's just published, which implies bugs appear every now and then, and you're not sure it's due to your misunderstanding of this IDE, or it's really an issue. In addition, it's  relatively hard to find How-to answers comparing to ADT plugin with Eclipse.

While trying to set up AdMob module in my project on Android Studio, it took me some time to fix some external library import errors that should be clearly mentioned in online AdMob doc, or even better, just integrate it into "Android Studio".  Isn't Android Studio meant to make Android developers' life easier?

Problem 1: Add com.google.ads.AdView element  in my layout xml as doc says, but it generates compilation error.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
             
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
             
android:orientation="vertical"
             
android:layout_width="fill_parent"
             
android:layout_height="fill_parent">
 
<com.google.ads.AdView android:id="@+id/adView"
                         
android:layout_width="wrap_content"
                         
android:layout_height="wrap_content"
                         
ads:adUnitId="MY_AD_UNIT_ID"
                         
ads:adSize="BANNER"
                         
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
                         
ads:loadAdOnCreate="true"/>
</LinearLayout>
Anser: Pay attention!! You also have to add the red line attributes to the container layout!! It's not clearly mentioned in document. What I just did in adding com.google.ads.AdView component. Obviously, it told me that it can't compile.

Question 2: Don't know how to add the AdMob library to my project in Android Studio. The AdMob doc only has flows for eclipse. I always meet "NoClassDefFoundError" during runtime. This took me most time to wandering on the internet, looking for a right answer.

Answer: it's a bit tedious. Please just check detail information in reference link below. In brief:
1. Put the jar into the libs folder
2. Right click it and hit 'Add as library'
3. Do a clean build (you can probably do this fine in Android Studio, but to make sure I navigated in a terminal to the root folder of my app and typed gradlew clean (I'm on Mac OS X, the command might be different on your system)

Question 3: sometimes, even questions above are all fixed, you still can't get the AdMob View. Why? You have to declare a specific Activity for it including configChanges. This is mentioned in Introduction, but ... I just have ignored it, since who would have thought that creating a View in my own activity needs to declare a specific Activity for it?

    <activity android:name="com.google.ads.AdActivity"
             
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
 

REF:
Add a jar library








五月 20, 2013
» Enhance Reading Experience for Android Dev website


Recently I spend most of my time reviewing documents on google's android official site. It annoys me that the left side of the screen is always occupied by the content index; however, I just need to change articles once in a while by using it. It makes me feel bad that one third of the screen is wasted. In addition, it also distracts me while I was reading.

As a consequence, I searched internet to see if there's any extension, plugin, or script to help me hide the navigation panel when I want to do so. Out of luck, no. Maybe it's too tiny to have someone work on it.

Therefore, I decided to write one by myself, after reading a book about jQuery. My choice is to write a userscript for greasemonkey, which is supported on Chrome now as well. The logic is very simple and the lines of codes are few, although it still took me sometime to find right APIs to implement this feature.

Here's the screenshots:

The userscript is uploaded to following site:
http://userscripts.org/scripts/show/167980

三月 31, 2013
» AVPlayer and AVAudioPlayer on iOS

(Polderpark.Netherlands)
I like the bright color in this picture. Although this photo was taken almost 10 years ago, the image quality is so great that I still can't believe it's taken by a cheap camera at that time.

****
It's easy to play and control local mp3 files by using AVAudioPlayer. However, if someone wants to stream playing mp3 files from the internet, he should try AVPlayer instead.

Spend most of my time trying to find a remote mp3 for testing. Too bad that I just can't even find one. Eventually, I gave up searching on the internet. Instead, I use following python command to create a simple http server locally on my mac:

python -m SimpleHTTPServer
 
 

二月 28, 2013
» Big Data and Hadoop

 Spring.Taiwan

Read the book "Understanding Big Data" today. Half way done.
Here's some excerpts from the book:

Understanding Big Data

2013-02-28 15:45:37
the term Big Data applies to information that can’t be processed or analyzed using tradi-tional processes or tools
2013-02-28 15:46:12
An IBM survey found that over half of the busi-ness leaders today realize they don’t have access to the insights they need to do their jobs
2013-02-28 15:48:45
Even if every bit of this data was relational (and it’s not), it is all going to be raw and have very different for-mats, which makes processing it in a traditional relational system impractical or impossible
2013-02-28 15:49:05
variety combining to create the Big Data problem
2013-02-28 15:51:31
Three characteristics define Big Data: vol-ume, variety, and velocity.
2013-02-28 15:54:17
the opportunity exists, with the right technology platform, to ana-lyze almost all of the data (or at least more of it by identifying the data that’s useful to you) to gain a better understanding of your business, your customers, and the marketplace
2013-02-28 15:55:35
a fundamental shift in analysis require-ments from traditional structured data to include raw, semis-tructured, and unstructured data as part of the decision-making and insight process
2013-02-28 15:56:27
To capi-talize on the Big Data opportunity, enterprises must be able to analyze all types of data, both re-lational and nonrelational: text, sensor data,
2013-02-28 15:56:50
Dealing effectively with Big Data requires that you perform analytics against the volume and variety of data while it is still in motion, not just after it is at rest
2013-02-28 15:58:11
Hadoop-based platform is well suited to deal with semistructured and unstructured data, as well as when a data discovery process is needed
2013-02-28 16:07:26
it is about dis-covery and making the once near-impossible possible from a scalability and analysis per-spec-t
2013-02-28 16:09:19
creator Doug Cutting’s son gave to his stuffed toy elephant
2013-02-28 16:09:44
duce)—more on these in a
2013-02-28 16:10:23
this redundancy provides fault toler-ance and a capability for the Hadoop cluster to heal itself
2013-02-28 16:10:55
Some of the more notable Hadoop-related projects include: Apache Avro (for data serializa-tion), Cassandra and HBase (databases), Chukwa (a monitoring sys-tem spe-cifically designed with large distributed systems in mind), Hive (provides ad hoc SQL-like queries for data aggregation and summariza-tion), Mahout (a machine learning library), Pig (a high-level Hadoop programming language that provides a data-flow language and execution framework for parallel computation), ZooKeeper (provides coordination services for distributed ap-plications), and more
2013-02-28 16:12:23
throughout the cluster
2013-02-28 16:13:54
For Hadoop deployments using a SAN or NAS, the extra network commu-nica-tion overhead can cause performance bottle
2013-02-28 16:14:59
an individual file is actually stored as smaller blocks that are repli-cated across multiple servers in the entire cluster
2013-02-28 16:16:09
default size of these blocks for Apache Hadoop is 64 MB
2013-02-28 16:21:41
All of Hadoop’s data placement logic is managed by a special server called NameNode
2013-02-28 16:28:14
All of the NameNode’s infor-mation is stored in memory, which allows it to provide quick response times
2013-02-28 16:30:33
Any data loss in this metadata will result in a permanent loss of corresponding data in the cluster
2013-02-28 16:32:25
devel-oper doesn’t have to deal with the concepts of the NameNode and where data is stored—Hadoop does that for you
2013-02-28 16:38:42
The first is the map job, which takes a set of data and converts it into another set of data, where individual elements are broken down into tuples
2013-02-28 16:38:51
reduce job takes the output from a map as input and combines those data tuples into a smaller set of tuples
2013-02-28 16:41:20
All five of these output streams would be fed into the reduce tasks, which combine the in-put results and output a single value for each city, producing a final result set
2013-02-28 16:43:08
MapReduce program is referred to as a job. A job is executed by subse-quently breaking it down into pieces called tasks
2013-02-28 16:43:45
An application submits a job to a specific node in a Hadoop cluster, which is running a daemon called the JobTracker
2013-02-28 16:44:39
In a Hadoop cluster, a set of continually running daemons, referred to as TaskTracker agents, monitor the status of each task
2013-02-28 16:46:39
This direct-ing of records to reduce tasks is known as a Shuffle, which takes input from the map tasks and directs the output to a specific re-duce task
2013-02-28 16:47:29
under Hadoop are written in Java, and it is the Java Archive file (jar) that’s distributed by the JobTracker to the various Hadoop cluster nodes to execute the map and reduce tasks
2013-02-28 16:48:00
BigDataUniversity.com and download Info-Sphere BigInsights Basic Edi-tion (www.ibm.com/software/data/infosphere/ biginsights/basic.html
2013-02-28 16:49:58
Hadoop Common Components are a set of libraries that support the var-ious Hadoop subprojects
2013-02-28 16:50:50
When you delete an HDFS file, the data is not actually gone (think of your MAC or Windows-based home computers, and you’ll get the point). Deleted HDFS files can be found in the trash, which is automatically cleaned at some later point in time
2013-02-28 16:52:46
we cover three of the more popular ones, which admit-tedly sound like we’re at a zoo: Pig, Hive, and Jaql
2013-02-28 16:53:09
Pig was initially developed at Yahoo
2013-02-28 16:56:02
you can FIL-TER out rows that are not of interest, JOIN two sets of data files, GROUP data to build aggrega-tions, ORDER results, and much more
2013-02-28 16:58:01
There are three ways to run a Pig program: embedded in a script, embedded in a Java program, or from the Pig command line, called Grunt
2013-02-28 16:58:51
Some folks at Face-book developed a runtime Hadoop sup-port structure that allows anyone who is already fluent with SQL (which is commonplace for rela-tional data-base developers) to leverage the Hadoop platform right out of the gate. Their cre-ation, called Hive
2013-02-28 16:59:50
You can use the Hive Thrift Client within applications written in C++, Java, PHP, Python, or Ruby
2013-02-28 17:01:19
Hive is read-based and therefore not appropriate for transaction processing
2013-02-28 17:03:11
JSON is built on top of two types of struc-tures. The first is a collection of name/value pairs
2013-02-28 17:03:35
The sec-ond JSON structure is the ability to create an or-dered list of values much like an array, list, or se-quence you might have in your existing applica-tion
2013-02-28 17:09:13
The operand used to signify flow from one operand to another is an arrow: ->. Unlike SQL, where the output comes first (for example, the SELECT list)
2013-02-28 17:15:16
Jaql is a flexible infras-tructure for managing and analyzing many kinds of semistructured data such as XML, CSV data, flat files, relational data, and so on

REF:
http://www.ibm.com/developerworks/wikis/display/db2oncampus/FREE+ebook+-+Understanding+Big+Data

二月 21, 2013
» 在未參加iOS developer program的前提下,在iPhone/iPad實機上測試開發中app

(Taipei.Taiwan)

該做的正事不認真,寫程式倒是花了不少時間。
今天總算有了點進展,先是把addTags的功能搞定,
再來是加上了Favorites的頁面,可以顯示自己加過特定tags的照片。

有了這些自己想要的功能之後,光是在emulator上測試,
就開始覺得不大過癮,想找辦法把程式放到iPhone上玩。
為了要把app deploy到手機上開發測試,
一般來說,得要加入US$99/year的developer program才可以。
加入了這個program之後,除了可以在真機上測試,
還可以發佈app到AppStore上去。
不過,目前我還沒有這樣的需求也沒有這打算,
因此實在是很不想花這筆錢。
而且,也不確定自己之後是不是還有時間研究iOS...

由於我的手機已經JB了,想說總會有辦法藉此到達我的目的吧。
果不其然,網路上從很早以前就有很多教學在講怎麼設定和patch xcode。
但是…全都好複雜呀:
又要加certificate,又是改plist,還要加入scripts。
只要其中哪個步驟沒弄好,應該就不行了吧。

好在,找到有人直接提供了懶人包的程式,
只要輕鬆按幾個按鈕就可以把所有的patch給搞定。
步驟如下:
1. 下載JailCoder,在Mac上執行它
2. 根據畫面最上方的Guide button操作,把certificate先搞定
3. 按左下方的patch xcode
4. 再按右下方的patch project,選擇自己想要deploy的project
5. 替自己的iOS device裝上AppSync (前提是要先JB)
    AppSync的source repo path下面有,
    把它加到Cydia的軟件源中,再尋找AppSync這支app就可以了

REF:
JailCoder
AppSync Installaion Source:
http://cydia.myrepospace.com/Bl00dra1n

二月 20, 2013
» iOS Programming

(Chamonix.France)

看了幾課教學後,總算是有點小進度了。
不看還不曉得,原來xcode的開發環境這麼完整和方便,
是我太久沒有接觸開發環境了嗎?
感覺上eclipse的android開發環境還是那麼地原始呀。

不過,寫程式常會遇到鬼打牆…
需要花時間…

REF:
Stanford CS193p

» 難搞的oAuth Process和文件不夠清楚的flickr Developer Documentation

(JingMei Bridge.Taipei)

試圖為抓下來的圖片加上一個tag,查了flickr api dev guide,對於這種request應該要使用post method才行。可是flickr上的api explorer還是用舊的token方式,而api說明頁又說得不清不楚,只說舊版的token要deprecated,要用新版的oAuth。卻沒說清楚oAuth的signature要怎麼生出來。

後來又回頭看了幾次oAuth signature的生法,並且在我原本找來做oAuth認識的class中找到相關的code;這才把它們改了一下搬到我需要的logic中。

結果發現用post method還是會有問題,可是我把整串request直接貼給browser竟然可以了!這是說如果用oAuth機制的話,不需要用post method也可以嗎?那我又何必大費周章的去改用NSURLConnection呢?再改回原本的[NSString URLWithString]]就好了。

REF:
gitk documentation
oAuth 簡介

二月 23, 2011
» 追求神乎其技的程式設計之道(番外篇)

biggo.com.tw

A Django site.