Liang-Bo Wang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # PyCon TW 2016 Collaborative Talk Notes <br> Day 1 - R0 > ### Quick Links > - [Portal for Collobration Notes 共筆統整入口](https://hackfoldr.org/pycontw2016) (hosted by [hackfoldr](https://hackfoldr.org/about) and [HackMD](https://hackmd.io/)) > - [Program Schedule 議程時間表](https://tw.pycon.org/2016/events/talks/) > - [PyCon TW 2016 Official Site 官網](https://tw.pycon.org/2016/) > > ### How to update this note? > - Everyone can *freely* update this note. 任何人都能自由地更新內容。 > - Please respect all the participants and follow our [code of conduct](https://tw.pycon.org/2016/about/code-of-conduct/) during discussion. 討論、記錄時,請遵守大會的[行為準則](https://tw.pycon.org/2016/about/code-of-conduct/)。 ## Talk: Essential TDD (Test-Driven Development) for Pythoners - Info: https://tw.pycon.org/2016/events/talk/70169571679535177/ - Speaker: 曾君宇 [均一教育徵才中](http://www.junyiacademy.org/) - Slides: http://www.slideshare.net/excusemejoe/essential-tdd-pycontw2016 - TDD (Test-Driven Development) - Red, green, refactor cycle - 預想好使用情境 - 一次只會專注一個目標,一次解決一個問題 - 避免過度設計 - 其他 *DD - ATDD(驗收測試驅動開發): - 聚焦在客戶的需求 - 按照spec做開發 - BDD - TDD的八卦?! - 2014就掛惹! by Rails創作者 - [懶人包:TDD is Dead 戰文總整理 ](http://joe-dev.blogspot.tw/2014/06/tdd-is-dead.html) - PyCon結束再看 ^.< (不然PyCon就結束了) - 結論? Mindset:設計決策一次只聚焦在一個地方 好好評估環境適不適合TDD(連需求都不確定時,不建議使用TDD) 推薦書籍:[Test-Driven Development with Python](http://chimera.labs.oreilly.com/books/1234000000754) (O'RELLY) ## Talk: 那些年,我用 Django Admin 接的案子 - Info: https://tw.pycon.org/2016/events/talk/69827266518974528/ - Speaker: Michelle Leu - 從美容床開始的故事... - 實作範例:店家網站,有眾多分店,Account 和 branch之間有多對多的情形 - [Django Packages](https://www.djangopackages.com/):推薦許多好用的Packages -- [Django Suit](http://djangosuit.com/) ## Talk: Reactive Programming in Python - Info: https://tw.pycon.org/2016/events/talk/67738180727603248/ - Slides: http://keitheis.github.io/reactive-programming-in-python/ - PDF: https://speakerdeck.com/keitheis/reactive-programming-in-python - Speaker: Keith Yang #### What is reactive programming >game is reactive. - Programming PARADIGMS - Declarative - Imperative #### Stream > Everything can be a stream ##### Stream in `for in if` * list comprehension * generator expression > 眼睛會痛XD #### Why reactive programming - Abstraction - Focus on Business logic - Concise code - Performance - asynchronous programming #### PyFunctional - `from functional import seq` > core spirit: Stream [most.js](https://github.com/cujojs/most): Monadic reactive streams [Python reactive extension](https://github.com/ReactiveX/RxPY) Handle for you: - Thread-safty - Syncronization - etc ... Implementation: - RxPy - RxJava - RxCpp - etc ... > Asynchronous programming is HARD. ### RxPy #### Observable #### flat_map 複雜的 list 的扁平化(我要的值在 list 的每個event中) ```python str_ls = [['6', '7'], ['42']] ``` ### books * Python Reactive Programming * Reactive Programming with Scala and Akka * Reactive Programing with ## Talk: 大型互動展覽的 Python 應用 - Info: https://tw.pycon.org/2016/events/talk/68743273514008626/ - Speaker: 陳炯廷 互動業 (?) 常用工具:OpenFramework / PureData / Kinect ...etc #### 互動科技案例: - 簽名自動雷雕成名牌 HTML canvas => Django server => jpg file => 工讀生 - 解密科技寶藏 - 3D掃描 #### ID機 用Raspberry Pi 3 - Autoupdate要寫好 - Django (因為有admin所以非熟悉程式的人也可以用) - zeroconf + avahi 自己找主機 - 使用 QRCode 設定機器 (ex. reboot 逼一下就重開) - 全區開機、全區關機卡(實用! pip install wakeonlan) - 運用redis指令,可以摹擬很多人一起使用系統 - socket.io emitter 可以和場內server聯絡 #### 文件 因為不同公司有不同權限,Django和nginx串接來解決 去一個展場,需要安裝一個 App ,然後可能還沒看完,就離開了, App 又需要送審,相對於網頁,網頁打開就可以 work。 ## Talk: Boost Maintainability - Info: https://tw.pycon.org/2016/events/talk/58446570282024986/ - Speaker: Mosky Liu - 投影片: https://speakerdeck.com/mosky/boost-maintainbility 我們在開發程式的時候,都是 "read lines randomly" 的,不像電腦會逐行讀取。 > [Making wrong code look wrong](http://www.joelonsoftware.com/articles/Wrong.html) - Joel on software #### Maintainability 用人讀 code 的方式來定義 Maintainability > To understand a random line, the lines you need to read back. 相對於programmer的時間,運算資源比較不值錢。 把時間專注於想要做的事情,而不是 debug 上面。 #### Boost Maintainability - Define our "Maintainability" - Making it zero - progressive from zero ##### Maintainability Be exact & consistent (命名要精準且有一致性) ##### 舉個例子 ```python result = ... result = ... ``` 以這種方式來命名不夠準確所以很容易混亂 ##### 命名的好方法 常常用 dictionary,對一個領域不熟悉的話可以多查字典來找到更好的名字哦! #### Ops Hint 命名具有提示的作用,提示有怎樣的operation可以用 ```python page_no = ... page_html = ... ``` 這樣就可以知道 `page_no` 是一個數字,而 `page_html` 是一個字串 ```python allowed_field_set = set(requested_field) ``` 這樣能清楚知道他是一個集合(set) ##### consistent問題 用d來標示dictionary ```python user = User(...) user_d = {} ``` >Hint: func 的命名如果沒有取名好,那發現問題還需要查 document,這個更耗時 建議:func都用動詞開頭,就會記得加上() 不要把 `is_secure = True` 與 `req.is_secure()` 混用 以 `形容詞`、`介係詞` 來當 boolean 會比較好 或者用簡單的句子來表示 boolean: `req_is_secure = True` #### Ops Hint (Mosky 使用的習慣) - Hint which ops you should use - _no: numeric - <plural>: sequence, usually is mutable sequence(list). - _<type>: if no intuitive way - (這邊好像有缺漏,求有筆記到的幫補充) - <verb>_: imperative sentence - <yes-no question>: return boolean - to_<thing>: thing - boolean: <adj>, <prep>, <simple sentence> ##### return value - get_page_no -> numeric >= 1 - query_user -> user object - parse_to_tree -> tree object ##### avoid `None` Consider: ```python= user = query_user(uid) user.is_valid() ``` 如果查不到 user 就 ret None 的話,就會噴 Error 囉! Accept an exception ? - N: user dummy object like an empty string. - Y: just raise when you wanna assign to None. #### 如果沒有檢查好做好處理 ```python= tmpl = '<p>{}</p>'.format(name) name = '<script> ... </script>' #XSS ``` ```python= tmpl_html = ... .format( escape_to_html(name) ) ``` 這種不是 python 的東西,對 Python 而言就只是 str,所以要去處理 #### Structure Hint ```python= uid_email_map = { 'mosky': 'mosky@email' } ``` 這樣子的命名方式能夠更直覺 ##### for dict & tuple - <key>_<value>_map - tuple - _pair: 2-tuple - _pairs: 3-tuple #### Private Hint - _<name> - Dont use out of class, function #### Performance Hint - get: memory op (記憶體的操作) - parse_ / cale_: CPU-bound op - query_ : IO-bound op - query_or_get_: IO-bound op with cache #### Progressive from zero - 不要自己自創縮寫,可以去[網站](http://www.abbreviations.com/)上查 - 如果只是要在一個 func 裡面用而已,可以用註解來解釋縮寫定義 (目前著重於讓人能夠更快讀懂 code,所以才這樣說) - 把程式分段跟分節 - 把做一系列事情的分段及分節 - 用 `空行` 來把不同的事情分隔開 - 用 `section` 的方式來切開(Title comment 來區隔開不同的區塊) #### Line Function up(把程式連線起來) > Func A call Func U, Func B call Func U 可以從連線的方式來慢慢切開變成函式的模組化 >Hint: 最好把箭頭指向的方向全統一到同個方向 #### Face Bad Smell(察覺程式碼中的壞東西) >不要為了克服心理上的潔癖而造成開發上時間的損失 >就是不要因為覺得 code 很醜就浪費一下午改好又不能動 XD - 用 comment 來解決痛點而不是改寫 - 放很多 TODO,不是不改是時候未到 XD - Seal it:把他封起來就對了,或是用更好的名稱把他包起來 - def good_name(): bad_name() - Stay focused:認真寫 code,舊的東西先放著! #### Summary > Use hints to boost maintainability ! #### QA 1、如何影響同事在 co-working 上使用較好的命名? 絕對不要有 guild line,可是可以用 `I will prefer` 這種方式來慢慢改變同事的風格,當他們發現這麼做的好處就會漸漸跟著改變。 但是真的碰到沒有按照規則走的同事也不要太生氣,可以 comment 他(幫他補一堆 comment),幫他 wrapper,然後讓自己的工作更順利。 2、你會參考 google 的 programming guildline 嗎? 會參考唷!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully