October
2nd,
2015
前言與心得整理 進入到第三週,前兩個章節都是在介紹可以透過RE(Regular Expression)來表示的語言.這一次就是無法透過RE來表示的語言(CFG: Content-Free Grammar)還有相關的定義與運算. 相關文章 [Coursera][Automata] 自動機理論-Automata筆記-第一週Finite Automata [Coursera][Automata] 自動機理論-Automata筆記-第二週: Regular Expression [Coursera][Automata] 自動機理論-Automata筆記-第三週: Context-Free Grammars and Pushdown Automata [Coursera][Automata] 自動機理論-Automata筆記-第四週: Pushdown Automata and Properties of Context-Free Languages [Coursera][Automata] 自動機理論-Automata筆記-第五週: Turing Machines and Undecidability [Coursera][Automata] 自動機理論-Automata筆記-第六週(上): Intractable Problems and NP-completeness [Coursera][Automata] 自動機理論-Automata筆記-第六週(下): Intractable Problems and NP-completeness 第三週課程內容: Context-Free Grammar Content-Free Grammar(以下簡稱CFG) 是一種可以透過符號來敘述語言,可以表達比RE更多的語言(但是不是全部).特別是在表現巢狀結構的語言. 以下只介紹正式的定義: Terminals: 定義好的符號,類似語言中的alphabet. Variables: 又稱為non-terminals,有限集合的符號,另一種表示語言的方式. Start Symbol:類似於RE中的start state. Production(投射): 也就一種對應的關係,通常表示為 ->. 其中左邊是 variables 右邊是 terminals跟variables的字串. ex: S-> {0, 1} Derivations(推導): 主要就是將CFG由start symbol開始,並且開始將variable投射出相對應的variables或是terminals其中的代表符號是=>. S->01 S->0S1 則 S=>0S1(將S->0S1)=>00SS11(將一個S->0, 另一個S->1)=>000111 Iterated Derivation: 符號為 =>* 如同Kleene Star定義一樣,這個代表推導為0或是更多. a =>* a (就是代表任意個a) a =>* b and b=> c 則 a=>* c Sentential Forms (句型): 指的是字串可以由Start Symbol加上 terminal 或是 variables. S =>* a 那麼 a就可以被稱為 sentential form (因為a是一start symbol,而且加上variable a組合而成.) 以下是一個簡單的範例: CFG : { 0^n 1^n | n >=1 } terminals: {0, 1} variables: {S} start symbol: S product: S -> {01} S -> 0S1 關於Iterated Derivation範例: S -> 01; S->0S1 則 S=>...
繼續閱讀
October
1st,
2015
##前言
這次的Golang Taipei Gathering #15 我有參與閃電秀.
###Gobot
講者: kerkerj
slide:
Golang Taipei Gathering #15 - 進擊的 Gobot! from kerkerj
主要是講姐Gobot的一些指令,Gobot提供相當好的介面可以直接去控制GPIO跟一些相關的機器. RPI/Ardurino甚至提供指令直接控制Sphero. Gobot 提供直接的方式可以控制COM port 與RS232直接對Ardurino與其他設備來溝通.
閃電秀: Project 52
不好意思~~我的閃電秀….
Project52 from Evan Lin
###Go Microserver Use Case
講者: David Hernandez
針對Microservice 講者注重的是:
How to handle big request in short time
What if some service down –> circuit breaker
有展示Goconvey的測試,感覺很酷.
繼續閱讀
September
26th,
2015
前言與心得整理 進入到第二週,不知道會不會有更困難的主題出現.寫筆記寫著寫著,發現自己筆記內容比原本老師講的還要多,代表自己不懂得真的太多,需要不斷的補充資料來讓自己更清楚. 相關文章 [Coursera][Automata] 自動機理論-Automata筆記-第一週Finite Automata [Coursera][Automata] 自動機理論-Automata筆記-第二週: Regular Expression [Coursera][Automata] 自動機理論-Automata筆記-第三週: Context-Free Grammars and Pushdown Automata [Coursera][Automata] 自動機理論-Automata筆記-第四週: Pushdown Automata and Properties of Context-Free Languages [Coursera][Automata] 自動機理論-Automata筆記-第五週: Turing Machines and Undecidability [Coursera][Automata] 自動機理論-Automata筆記-第六週(上): Intractable Problems and NP-completeness [Coursera][Automata] 自動機理論-Automata筆記-第六週(下): Intractable Problems and NP-completeness 第二週課程內容: Regular Express 基本定義 與 運算 符號定義: 通常顯示E來表達一個regular expression,而L(E) 就表示一個regular expression 能表達出來的語言(language). Language的運算: (Union/Concatenation/Kleene Star) Union (U): 就是把兩個language做一個簡單的聯集. ex: {01, 11, 101} U {10, 11, 101} = {01, 10, 11, 101} Concatenaion (LM): 把兩個language做一個連接,但是注意這裡跟字串的concatenation是不同的.基本定義而顏,把語言L跟語言M連接在一起就稱為LM. LM = wx | w in L and x in M. ex: L = { 01, 11} M = { 10, 11} LM = { 0110, 0111, 1110, 1111} 也就是 第一個L元素配上第一個M元素,第二個L元素配上第一個M元素.繼續類推. Kleene Star (*): 就是regex裡面的*,表達任何子集合在L中與空集合或是一個以上的子集合的聯集. L* = {ε} U L U LL ... ex: L = {01, 11} L*= {} or {01, 11} or {0101, 0111, 1101, 1111} .... Regular Expression定義 a是一個symbol, 如果a是一個regular express(記作RE),則 L(A) = {a} L{ε} = {ε} L(empty set)...
繼續閱讀
September
24th,
2015
前言 其實Go 1.5的正式公布後,最吸引人的就是與其他語言的相互合作.透過的可能是編譯成c-shared library.但是其實我個人最期待的,當然就是使用go mobile. 最近他們把相關的範例跟工具都弄的差不多,並且有一了份相當詳細的教學在這裡. 簡單流程: 由於教學寫得很清楚,我這裡簡單的把事情都跑過一次.注意:你需要有Go1.5. //抓取go mobile tool go get golang.org/x/mobile/cmd/gomobile //初始化gomobile,可能會花一點時間 gomobile init //編譯gomobile裡面的範例 //這會在本地端直接編譯出 basic.app 只要透過xcode 複製到手機上即可(需要有開發者付費帳號) gomobile build -target=ios golang.org/x/mobile/example/basic //如果要把go package編譯成iOS可以用的framework //這會在本地端編譯出一個hello.framework cd $GOPATH/src/golang.org/x/mobile/example/bind gomobile bind -target=ios golang.org/x/mobile/example/bind/hello //直接在xcode拿來使用即可 open ios/bind.xcodeproj 來個iOS簡單範例 (11/17更新) 這裡提供一個簡單的範例,主要也是測試一下幾個主要的疑慮: 簡單的範例程式碼在這裡,這裡有直接的playgroud package gomobile01 import ( "fmt" ) type Goomobile struct { Data string } //記得要有constructor 不然到時候你無法自行透過 NSObject init 來建立這個物件 func New() *Goomobile { return &Goomobile{Data: "Default test"} } func (g *Goomobile) GetData() string { fmt.Println("test go ") return g.Data } 這時候建立這個iOS framework 指令是 (假設專案寫在kkdai/gomobile01) $ gomobile bind -target=ios github.com/kkdai/gomobile01 然後會產生一個gomobile01.framework 把他拉進xcode專案. 以下提供如何使用的方式: //載入該framework #import "gomobile01/Gomobile01.h" 這裡是使用的方式,切記要使用Constructor不要使用 [[xx alloc] init] GoGomobile01Goomobile *gb = GoGomobile01New(); //Default data is @"Default test" [gb setData:@"Data...."]; NSString * str = [gb GetData]; //str = @"Data..." 已知可以支援的部分 基礎的運算與簡單的資料格式當初參數 (int, string) 支援structure跟method 可以跑net/http但是記得別直接拿rpc.Client或是http.Client當作public 相關限制 目前試著編譯幾個有在使用的package發現有以下的問題,可能需要解決. []slice, map, interface{} 比較進階的資料格式不支援 (可能也不能轉換到iOS) 同理可證,一些package裡面的變數也不要放在parameter裡面.只支援基礎資料格式. 即便是簡單的string, int不支援public global variable. var TestVariable string 不被允許 但是var testVariable string 是可以允許的 const目前還不支援 (gomobile: not yet...
繼續閱讀
September
21st,
2015
####將所有m透過預設Object C++來編譯:
設定->LLVM 7.0 -> Compile Source As -> Object-C++
這裏的設定比起單獨點選每個.m再來改成ObjectC++更有優先權.
設定額外的Include Path
設定-> HEADER_SEARCH_PATHS (記得改HEADER_SEARCH_PATHS就好).
記得要使用 $(PROJECT_DIR)/../../../include,而不是單純的 ../../../include不然會找不到.
避免發生 Undefined symbols for architecture x86_64
這是因為你嘗試要跑模擬器的編譯而你編譯出來的static library並沒有x86_64的選項.這邊的修改方式有幾個:
增加x86_64 到”Build Setting”->”Artchitectures”跟”Valid Artchitectures”
或是修改”Build Setting”->”Build Active Architecture Only”改成No
Bitcode enableing
Bitcode是xcode7新的功能.但是如果使用xcode新的專案都會遇到warning,關閉的方法就是在App去關閉,當然如果要使用這個功能,就得每個library都要打開bitcode.
繼續閱讀
September
17th,
2015
前言 主要是因為有大師推薦,然後發現這堂課的教授就是所謂的Compiler恐龍課本的作者Jeffrey Ullman(Compiler Design的聖經). 加上自動機本身不僅僅實作牽扯到regular expression之外,更在分散式系統中的狀態機(state machine)扮有相當重要的部分. 所以需要來好好學習. 課程鏈結在這裡https://class.coursera.org/automata-004. 相關文章 [Coursera][Automata] 自動機理論-Automata筆記-第一週Finite Automata(本篇) [Coursera][Automata] 自動機理論-Automata筆記-第二週: Regular Expression [Coursera][Automata] 自動機理論-Automata筆記-第三週: Context-Free Grammars and Pushdown Automata [Coursera][Automata] 自動機理論-Automata筆記-第四週: Pushdown Automata and Properties of Context-Free Languages [Coursera][Automata] 自動機理論-Automata筆記-第五週: Turing Machines and Undecidability [Coursera][Automata] 自動機理論-Automata筆記-第六週(上): Intractable Problems and NP-completeness [Coursera][Automata] 自動機理論-Automata筆記-第六週(下): Intractable Problems and NP-completeness 第一週課程 DFA(Deterministic Finite Automata)基本定義 alphabet: 任何有限的符號集合. (可以是ASCII也可以是Unicode) ex: {0,1} (binary alphabet), {a,b} {s,p} 都是alphabet string: 透過alphabet產生的list,其中每一個元素都要是該alphabet其中一個元素. length代表的是該string有的個數. ex alphabet {0, 1} 其 string {01} length=2 ε 代表是empty string其中他的length=0 language: 為alphabedt產生出所有string的subset. DFA: Deterministic Finite Automata: A formalism for defining languages.由以下組成: 有限的狀態(states) 表示為 Q 固定的input alphabet 表示為 Σ 一個起始狀態 (start state) 表示為q0 至少一個結束狀態 (final state) (這裏指的final state也是指可接受的狀態) 表示為 F 一個transition function 表示為 δ(Q, A)其中 A 代表是一個輸入的 alphabet transition function代表的是,一個輸入所要進入的一個狀態. δ(Q, A) 代表是從狀態Q透過輸入A來計算下一個狀態會是哪裡. 範例: {0, 1} 是一個alphabet {0, 1}* = {ε, 0, 1, 00, 01, 10, 11, 010, …} 是alphabet {0,1}為可能出現的string組合,其中 {e} length=0 {0} length=1 {00} {01} {10} {11} length=2 如果要討論language,我們可以說 {ε,...
繼續閱讀