2014年12月13日 星期六

Introduction to REST & JSON

What is REST?

Representational State Transfer (REST) is a style of software architecture for distributed systems.

 使用 REST 為設計架構的系統我們就稱為 RESTful系統

 RESTful Web Services(或稱RESTful Web API)是以HTTP為基礎,必且有以下三個特色
  1. 所有的API或是以Resource的形式存在,例如 htttp://www.test.com/examples/12345
  2. 這個服務可以接受與返回某個MIME-TYPE,最常見的是JSON格式,也可以回傳PNG/JPG/TXT等格式。
  3. 對資源的操作會支援各種請求方法 (例如GET, POST, PUT, DELETE)

What is JSON?

JavaScript Object Notation (JSON) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate” – JSON.org


JSON
XML
Data Structure
Data Structure
No validation system
XSD
No namespaces
Has namespaces (can use multiples)
Parsing is just an eval
Fast
Security issues
Parsing requires XML document parsing using things like XPath
In JavaScript you can work with objects – runtime evaluation of types
In JavaScript you can work with strings – may require additional parsing
Security: Eval() means that if the source is not trusted anything could be put into it.
Libraries exist to make parsing safe(r)
Security: XML is text/parsing – not code execution.

2014年9月4日 星期四

Machine Type Communication

Machine Type Communication (MTC) is a form of data communication which involves one or more entities that do not necessarily (or not much) need human interaction. The MTC is also known as Machine to Machine Communication (M2M) and Internet of Things (IoT).

What are the MTC applications?

Sensor 
Smart Meter
Actuator

What are the MTC features?

Different market scenarios (smart meter v.s. phone)
Data communications (low traffic v.s. burst traffic)
Lower costs and effort
Potentially very large number of communicating terminals
Low Mobility
Time Controlled
Infrequent Mobile Terminated (Mostly MO)
MTC Monitoring
Secure Connection
Group Based MTC Features (Policing, Addressing)


MTC is benefit to both telecom operators and vendors. Vendors are expected to profit from selling M2M-capable devices, and operators earn profit by increased throughput at non-rush hour. For service providers, MTC is an opportunity for fast deploying service onto the current user services network.

2014年8月24日 星期日

MTP on Android

What is MTP?

MTP stands for “Media Transfer Protocol.” After Android 3.x, Android uses this protocol, it appears to the computer as a “media device.” The media transfer protocol was widely promoted as a standardized protocol for transferring audio files to digital music players using Windows Media Player and similar applications. It was designed to allow other media player companies to compete with Apple’s iPod and iTunes.

The Problem in MTP

File dir = Environment.getExternalStoragePublicDirectory("TempDir");
File file = new File(dir, "test.txt");
FileUtils.writeStringToFile(file, "Hello World");

If you’d execute the code above, the file would be created but it wouldn’t show up in the Windows Explorer (or whatever tool you’re using the view the device’s contents).
To make the file show up, after closing it use the following code (API documentation):
MediaScannerConnection.scanFile(ctx, new String[] { file.getAbsolutePath() }, null, null);

Notes:
The external storage is scanned automatically when the Android device is booting (e.g. after a restart).
If you pass a directory (instead of a file) to scanFile(), the directory will show up as file in Window Explorer, so don’t do this.

2014年7月15日 星期二

Standard for National Communications Commission in Taiwan

Certification Standard

  1. LP0002
  2. PLMN01 (GSM and DCS Mobile Phone Standard)
  3. PLMN02
  4. PLMN08
  5. PLMN09 (3G Mobile Phone Standard)
  6. PLMN10 (4G LTE Mobile Phone Standard)
  7. IS2032-1
  8. IS2045-0
  9. IS2037-0
  10. IS2050
  11. CNS14958-1
  12. CNS14959

 PLMN10 (2013/10/15)

5.14 Public Warning System,PWS
 5.14.1 本項測試適用手持式行動臺設備。
 5.14.2 公眾告警廣播簡訊功能應具有下列通道:
  5.14.2.1 通道4370為顯示中文公眾告警廣播簡訊,且不可關閉。
  5.14.2.2 通道4380為業者測試公眾告警廣播簡訊。
  5.14.2.3 通道4383為顯示英文公眾告警廣播簡訊,且不可關閉。
 5.14.3 設備應具有告警聲響信號,並符合下列規定:
  5.14.3.1 告警聲響信號型式為2段聲響,並間隔0.5秒。每段聲響為2秒聲響後有2次1秒聲響,每次聲響間隔0.5秒。
  5.14.3.2 告警聲響信號須符合下列第5.14.3.2.1節或第5.14.3.2.2節之規定:
   5.14.3.2.1 設備具有混音能力,必須同時以基頻853Hz和960Hz混音產生聲響傳送。
   5.14.3.2.2 設備只有單音能力,必須以960Hz單音產生聲響傳送。
  5.14.3.3 告警聲響信號僅限使用於公眾告警廣播簡訊功能。
 5.14.4 設備應具有告警振動信號,並符合下列規定:
  5.14.4.1 告警振動信號型式為2段振動,並間隔0.5秒。每段振動為2秒振動後有2次1秒振動,每次振動間隔0.5秒。
  5.14.4.2 告警振動信號僅限使用於公眾告警廣播簡訊功能。
  5.14.4.3 告警聲響信號與告警振動信號間得不同步。
5.14.5 公眾告警廣播簡訊之接收處理必須優先於設備其他功能。

2014年7月14日 星期一

Patentable Invention

Copyright- Expression of idea
Patent- Embodiment of idea


Patentability and Patent Eligible

35 U.S.C. 101 Inventions patentable. “Whoever invents or discovers any new and useful process, machine, manufacture, or composition of matter, or any new and useful improvement thereof, may obtain a patent therefor, subject to the conditions and requirements of this title.”

MacKay Co. v. Radio Corp., 306 U.S. 86,94(1939).

A.MT Test (Machine-or-Transformation Test)
Process  is tied to a particular machine or apparatus
Process ransforms a particular article into a different state or thing




Non-Patentability

1. abstract ideas

"principle, in the abstract, is a fundamental truth; an original cause; a motive; these cannot be patented, as no one can claim in either of them an exclusive right.", LeRoy v. Tatham, 14How.156,175 (1853).

Rubber-Tip Pencil Co. v. Howard, 20wall.498,507(1874).

2. natural phenomena
Association for Molecular Pathology v. Myriad Genetics, 569 U.S. 12-398 (2013).

3. natural products

4. laws of nature
Mayo Collaborative Services v. Prometheus Laboratories, Inc. 566 U.S. 10-1150(2012).


2014年7月1日 星期二

Modify OpenCV Tutorial Project

OpenCV Tutorial 2 – Mixed Processing




1. Enter the src folder, and then open Tutorial2Activity.java

2. At the top of the file, add:

private static final int VIEW_MODE_THRESH = 3;
private MenuItem mItemPreviewThresh;


3.In the method “onCreateOptionsMenu”, add:

mItemPreviewThresh = menu.add(“Thresh.”);

4.In the method “onCameraFrame”, add:


case VIEW_MODE_THRESH:
mRgba = inputFrame.rgba();
       int maxValue = 255;
       int blockSize = 61;
       int meanOffset = 15;
       Imgproc.adaptiveThreshold(
              inputFrame.gray(),
              mIntermediateMat,
              maxValue,
              Imgproc.ADAPTIVE_THRESH_MEAN_C,
              Imgproc.THRESH_BINARY_INV,
              blockSize,
              meanOffset );
       Imgproc.cvtColor( mIntermediateMat, mRgba, Imgproc.COLOR_GRAY2RGBA, 4 )


5.In the method “onOptionsItemSelected”, add:
else if (item == mItemPreviewThresh) {
mViewMode = VIEW_MODE_THRESH;
}

2014年6月27日 星期五

3GPP Supplementary Service

Reference


SPEC NumberTitleNote
TS 24.010Mobile radio interface layer 3; Supplementary services specification; General aspects
TS 24.030Location Services (LCS); Supplementary service operations; Stage 3
TS 24.072Call Deflection (CD) supplementary service; Stage 3
TS 24.080Mobile radio interface layer 3 supplementary services specification; Formats and coding
TS 24.081Line Identification supplementary services; Stage 3
TS 24.082Call Forwarding (CF) supplementary services; Stage 3
TS 24.083Call Waiting (CW) and Call Hold (HOLD) supplementary services; Stage 3
TS 24.084Multi Party (MPTY) supplementary service; Stage 3
TS 24.085Closed User Group (CUG) supplementary service; Stage 3

Example: Call Forwarding when not Reachable (CFNRc)

當手機正處於無法與基地台聯絡的狀況, 例如荒郊野外, 關機, 地下室, 樓梯間,速度大於150km/hr的載具(高速鐵路), 有人打這隻手機, 透過CFNRc服務便會被轉接到所指定的號碼. 至於這個轉接的號碼, 是可由使用者隨意設定與取消的,並不具有監聽的效果.
 

CFNRc服務可以藉由 *#62#指令來進行設定, 下面是一些實驗流程, 可以自己設設看, 本文設計了一個實驗流程, 請跟著步驟一步步試試看
1. 準備三支手機(或至少一支手機與一台市內電話), 裡面要有能通話的SIM卡(或者PHS也可以),電話號碼分別是 A, B, C(或者
一支手機A與一台市內電話B)
2. 在手機A 上按 **62*(號碼B)#[SEND], 撥號出去之後, 如果A這個號碼的運營商有支援CFNRc, 你會看到手機的完成訊息:來電轉接已啟動
恭喜你, 設定成功了
3. 把手機A 關機, 然後拿起手機C(或用公用電話), 打給手機A
4. 因為這個號碼是設定在基地台, 所以當C call A, 基地台找不到手機A, 他就會根據之前設定的號碼, 把這通電話轉給手機B
(或市內電話)
5. 所以手機B 就會響起來了, 接了它吧, 不是什麼詐騙電話, 更不是監聽電話
6. 如果要取消設定, 很簡單, 你只要把手機A 拿到有收訊的地方, 按 ##62#[SEND], send 出去之後, 你會看到手機的完成訊息:
來電轉接已取消, 這樣就成功取消轉接功能並刪掉設定的號碼了

其實62這個 SC (service code) 只是 call forwarding 的四種條件其中之一, 這四種條件分別是
1. SC=21, call forwarding unconditional, 無論如何都轉接給指定的號碼
2. SC=67, call forwarding on busy subscriber, 當手機正在忙線中, 轉接給指定的號碼
3. SC=61, call forwarding on no reply, 當來電沒有被接起來到達指定的秒數, 轉接給指定的號碼
4. SC=62, call forwarding when not reachable, 當手機沒有在任何基地台的範圍之內

至於操作的指令, 其實一共有五種:
1. *#SC#, 可隨時查詢此服務的狀態, 放心使用, 不會改變服務的狀態(check the service state)
2. **SC*PHONENUMBER#, (set and enable the service forward call to the PHONENUMBER)設定並啟動此服務
3. ##SC#,
(disable the service forward call and erase the PHONENUMBER)取消並將設定的號碼刪除掉
4. *SC##, (enable call forwarding)啟動此服務
5. #SC#,
(disable call forwarding)取消此服務

聽起來很複雜, 但真的很簡單, 假設鄉親已經使用 **SC*(電話號碼)# 設定並啟動轉接服務, 可以使用 #SC# 暫時取消,
稍後藉 *SC# 再度啟動, 若一旦藉由 ##SC#
刪掉掉註冊在基地台的轉接號碼, 則 *SC##SC# 皆無法作用.

以下列出台灣前三大行動網路運營商CFNRc服務設定申請的相關網頁供大家做進一步的參考:
The following links are about call forwarding application in the Taiwan top 3 operator:
1. 中華電信(
Chunghwa Telecom): 首頁 > 個人/家庭>行動服務>基本服務 
2. 遠傳電信(FarEasTone): 首頁 > 網路客服 > 基本功能說明 > 基本功能 > 指定轉接
3. 台灣大哥大(Taiwan Mobile):
首頁 » 用戶服務 » 我的服務/優惠»指定轉接


2014年6月26日 星期四

OpenCV on Android

I: Install OpenCV for Android

Downloading and Installing Android NDK

The NDK is a toolset that allows you to implement parts of your app using native-code languages such as C and C++.

1. Download the latest version of the NDK from this website:
    http://developer.android.com/tools/sdk/ndk/index.html
2. Unzip the downloaded file to a location without spaces in the path, for example:
    C:\\Development\android-ndk-r9d
3. Define NDKROOT as a new environment variable pointing to the unzipped location from
    the previous step.

Updating Tools in Android SDK

1. In Eclipse, click Help > Install New Software. Then, click Add.
2. In the Add Repository dialog, enter “ADT Plugin” for the Name and the following URL for
    the Location, and click OK:
    https://dl-ssl.google.com/android/eclipse/
3. In the Available Software dialog, select all listed components. Click Next. Accept all license agreements. Click Finish.
4. Restart Eclipse after all the tools have been downloaded and installed.

Downloading and Installing OpenCV SDK

1. Download version 2.4.4 (or higher) of the SDK from this website:
    http://sourceforge.net/projects/opencvlibrary/files/opencv-android/
2. Unzip the downloaded file to a location without spaces in the path, for example:
    C:\\Development\OpenCV-2.4.9-android-sdk
3. In Eclipse, select File > Switch Workspace > Other. Specify a location associated with OpenCV projects, for example:
C:\\Development\OpenCV-2.4.9-android-sdk
4. Right-click in the Package Explorer panel and choose Import > General > Existing Projects into Workspace. Select “Specify root directory” and input the location where the SDK contents were unzipped, for example:
C:\\Development\OpenCV-2.4.9-android-sdk
5. After seeing the OpenCV library and sample projects appear in the “Projects” box, click Finish. It may take a minute for all the projects to be loaded and initialized. Thereafter, you have the projects imported into the workspace

II: Run OpenCV Applications on Physical Phone

Running OpenCV Samples

1. Connect your phone to PC via USB Cable
2. Make sure your device manager shows (Android Composite) ADB Interface, if no please check driver installation

3. Install the OpenCV Manager app from the Google Play Market onto your phone
link: https://play.google.com/store/apps/details?id=org.opencv.engine
4.In Eclipse, click on any of the sample OpenCV projects. Then, click Run > Run As > Android Application. You can monitor the installation status in the Console.

Troubleshooting 

Ref:
http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/android_dev_intro.html#development-in-java 


1."The container 'Android Dependencies' references non existing library 'C:\Project\android-sdk-windows\tools\support\annotations.jar'.



Sol:change the target API version from 11 to 19


2. OpenCV in not ready (OpenCV Manager app not be install)


 
Sol: Download App's apk file on Google Play without Google account

a. get the app's link from Google Play page
Ex:https://play.google.com/store/apps/details?id=org.opencv.engine

b. go to App Downloader website
http://apps.evozi.com/apk-downloader/?id=org.opencv.engine

c. post link get from step a in website
d. get the apk file org.opencv.engine.apk
e. cmd adb install org.opencv.engine.apk

2014年6月19日 星期四

Introduction to Cryptocurrency Authentication Protocol

      A cryptocurrency is a medium of exchange designed around securely exchanging information which is a process made possible by certain principles of cryptography. The first cryptocurrency to begin trading was Bitcoin in 2009. Since then, numerous cryptocurrencies have been created. Fundamentally, cryptocurrencies are specifications regarding the use of currency which seek to incorporate principles of cryptography to implement a distributed, decentralized and secure information economy.

Proof of work

A proof of work is a piece of data which was difficult (costly, time-consuming) to produce so as to satisfy certain requirements. It must be trivial to check whether data satisfies said requirements. Producing a proof of work can be a random process with low probability, so that a lot of trial and error is required on average before a valid proof of work is generated. Bitcoin uses the Hashcash proof of work.

Proof of Stake

Proof of Stake is a proposed alternative to Proof of Work. Like proof of work, proof of stake provides a mechanism for determining who signs bitcoin transactions.

 "PPCoin: Peer-to-Peer Crypto-Currency with Proof-of-Stake". http://barkingshibes.com/wp-content/uploads/2014/02/ppcoin-paper.pdf, 
19-08-2012. Sunny King, Scott Nadal.

Proof-of-Stake-Velocity

Proof-of-Stake-Velocity (PoSV) replace the current Proof-of-Work (PoW).
PoSV builds on the strength of Proof-of-Stake (PoS) but introduces crucial features to address the flaws of both PoW and PoS.
PoSV is specifically designed to help Reddcoin grow as the digital social currency.
FAQs, such as PoSV's impact on mining and halving schedule, are covered here: Proof of Stake Velocity: FAQs

2014年6月17日 星期二

RoR Hello World

MVC Model in Rails

1. Generator a controller

rails generate controller welcome

      create  app/controllers/welcome_controller.rb
      invoke  erb
      create    app/views/welcome
      invoke  test_unit
      create    test/controllers/welcome_controller_test.rb
      invoke  helper
      create    app/helpers/welcome_helper.rb
      invoke    test_unit
      create      test/helpers/welcome_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/welcome.js.coffee
      invoke    scss
      create      app/assets/stylesheets/welcome.css.scss



2.Add new setting in routing file (config/routes.rb)

get "welcome/say_hello" => "welcome#say"


3. edit controller fileopen app/controllers/welcome_controller.rb, and then ass a say method.

class WelcomeController < ApplicationController 
    def say 
    end
end


4.add app/views/welcome/say.html.erb

<h1>Hello, World!</h1>


以CRUD方式開始RoR應用

CRUD means the four basic type: Create, Read, Update and Delete for data operation.

1.build work space

$ mkdir projects
$ cd projects

2. build new app project

$ rails new blog
$ cd blog
$ ls -al




檔案/目錄用途
Gemfile設定Rails應用程式會使用哪些Gems套件
README專案說明:你可以用來告訴其他人你的應用程式是做什麼用的,如何使用等等。
Rakefile用來載入可以被命令列執行的一些Rake任務
app/放Controllers、Models和Views檔案,接下來的內容主要都在這個目錄。
config/應用程式設定檔、路由規則、資料庫設定等等
config.ru用來啟動應用程式的Rack伺服器設定檔
db/資料庫的結構綱要
doc/用來放你的文件
lib/放一些自定的Module和類別檔案
log/應用程式的Log記錄檔
public/唯一可以在網路上看到的目錄,這是你的圖檔、JavaScript、CSS和其他靜態檔案擺放的地方
script/放rails這個指令和放其他的script指令
test/單元測試、fixtures及整合測試等程式
tmp/暫時性的檔案
vendor/用來放第三方程式碼外掛的目錄

3. Start the server

$ cd projects/demo
$ rails server

4. check the default web page
open browser and then goto http://localhost:3000

2014年6月16日 星期一

Innovation System

TRIZ的含義是發明問題解決理論,其中TRIZ拼寫是由俄文單詞теории решения изобретательских задач 的英文音譯Teoriya Resheniya Izobreatatelskikh Zadatch的縮寫,其英文全稱是Theory of the Solution of Inventive Problems(發明問題解決理論)。在歐美國家也可縮寫為TIPS

QFD是品質機能展開(Quality Function Deployment的縮寫),QFD是將客戶的需求轉換成產品設計的方法,著重在傾聽客戶的聲音,回應顧客的需求。

2014年6月14日 星期六

Install RoR on Ubuntu 10.04 x86_64


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Install Ruby Using apt-get (Out of date)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

1. Install Ruby interpreter

$sudo apt-get install ruby
$ruby -v (make sure the install sucess, ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux])
$sudo apt-get install ruby-dev
$sudo apt-get install libopenssl-ruby (Solution for "no such file to load -- net/https (LoadError)")
2. Install Ruby Package Management program
$sudo apt-get install rubygems
$gem -v (make sure the install sucess 1.3.5)

#speed up by setting no doc files download for each pakage install
$vim ~/.gemrc
insert the content "gem: --no-ri --no-rdoc"

3.Install Rails
$gem install rails

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Install Ruby Using RVM

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$\curl -sSL https://get.rvm.io | bash -s stable --ruby

$ source /home/stanley3/.rvm/scripts/rvm
(or add "source ~/.rvm/scripts/rvm" in the ~/.bashrc)
$ruby -v
(ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux])
$gem -v (2.2.2)

$rvm list known (查看可安裝的 Ruby 實作)

$rvm use ruby_version (can switch between the Ruby versions)

add the following line into .bashrc to load rvm

# This loads RVM into a shell session.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

Install Node.js

Since Rails 3.1, a JavaScript runtime has been needed for development on Ubuntu Linux. The JavaScript runtime is required to compile code for the Rails asset pipeline. For development on Ubuntu Linux it is best to install the Node.js server-side JavaScript environment.

Note: the following green key is from the output of $apt-get update
$sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B9316A7BC7917B12
$sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get install nodejs
$ which node (expected output: /usr/bin/node)


Rails Installation


$gem install rails (the most recent stable release)
$rails -v

2014年4月19日 星期六

接案的藝術

SOHO族接案的問題可能有千百種,為了避免接了案子以後發生糾紛,在接案初期就做好過濾是必須的,以下分為四個重點來做說明

1) 洽談時期先問預算
預算是很基本的問題,有案子想外包, 怎可能會沒預算? 尤其當客戶說預算無上限,或就是不肯清楚說明的,我認為十之八九都有問題。雖然站在客戶立場,一開始就講出預算, 好像就露了底牌。 但換個角度想,若我們本身是真正想發案的客戶,遇到適合的工程師,怎麼會不想講預算。

2) 問希望的時程
基本上,只要是那種擺明就是要廠商 "趕工" 的專案,最好不要接,除非手邊剛好有現成的東西符合客戶需求。

3) 確定這是個 "賺錢"的系統
我說的 "賺錢"不是指接案者能賺多少錢,而是承作的這套系統是否真正為客戶賺錢。若客戶其實是統包, 一開始就擺明他們也是賠錢, 沒賺多少, 那麼不要猶豫,不要理他。如果客戶就是系統的直接使用者, 仔細地評估出該系統可能供獻給客戶的效益, 通常這種案子的成交價會容易皆大歡喜。

4) 確認客戶的 "動機"
有的客戶其實是有工程師, 甚至是一整個開發團隊, 卻又為何要發包? 不要懷疑, 尤其客戶本身也是在承作IT系統專案開發的, 這類客戶的發包動機有些其實很不單純。騙報價,騙計劃書, 騙技術,甚至耍賴不給錢!!