willismax
    • 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
    • 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
    • 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 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
  • 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- author: Willis Chen image: https://hackmd.io/_uploads/B1-u_uJZs.png GA: G-CH7FZ71WRC --- # Day 23 : HackMD 嵌入 Colab with Gist [![hackmd-github-sync-badge](https://hackmd.io/_bj3HZLESs-TvhSqiIqyiA/badge)](https://hackmd.io/_bj3HZLESs-TvhSqiIqyiA) [![Yes](https://img.youtube.com/vi/ecVj5DnKCCY/0.jpg)](https://www.youtube.com/watch?v=ecVj5DnKCCY) ## 為什麼需要 [Colab](https://colab.research.google.com/) - Colab (Colaboratory) 為Google 推出的雲端執行 Python 程式碼的服務,依據 Jupyter Notebook 的筆記本(以下稱筆記本)發展而來,可在瀏覽器中編寫及執行 Python 程式碼,並且可以透過 Linux 指令操作虛擬機(Colab 的虛擬機是採用 Linux 系統的 Debain,Ubuntu 大多數常用指令共用)。 - 筆者也是Colab的愛用者,在第12屆[用Line聊天機器人串起多媒體系統 ](https://ithelp.ithome.com.tw/users/20121130/ironman/3131)系列文[Day 10 : 左手只是輔助 - 用 Google Colab 協助開發日常](https://ithelp.ithome.com.tw/articles/10234527)之後,只要是分享Python實作的程式碼全都提供Colab連結,如果您對先前筆者的鐵人賽的Colab 實作有興趣,清單都在最後一天,像是第12屆的[Dya 30 : 完結灑花](https://ithelp.ithome.com.tw/articles/10242827)、2021年的 [從 AI 落地談 MLOps ](https://ithelp.ithome.com.tw/users/20121130/ironman/4015)系列的[Day 30 : 綜合整理 MLOps 成熟度模型](https://ithelp.ithome.com.tw/articles/10274317)。 ## Colab的優點 - 不必進行任何設定 - 可以直接瀏覽頁面,直接建立好可以執行程式碼的筆記本環境,登入Google帳號即可互動。 - 免付費使用 - 目前免費服務提供12小時虛擬機執行時間、佛心的GPU資源,關閉視窗即停止虛擬機;付費版目前可運行至24小時、較優先的GPU資源、可重新訪問關閉視窗尚在執行的筆記本。 - 輕鬆共用 - 如同Google文件系列的檔案共享方式,可以限制使用者與個別邀請、提供分享連結供檢視或編輯。 ## 如何儲存您要的 Colab 檔案 您可以選擇以下方式 - 在 Google 雲端硬碟儲存 - 在 GitHub Gist 儲存 - 在 GitHub 儲存 - 在本機儲存為`.ipynb` - 在本機儲存為`.py` ![](https://hackmd.io/_uploads/H1S1oTtfo.png) ## 在 HackMD 結合 Colab 的方法 ### Colab 不能用`<iframe>` 嵌入 如果用HackMD的`<iframe>`嵌入或書本模式的外部連結,都不能直接嵌入,與 Google 的試算表、簡報與文件不同,是特別的存在。 ### Colab 以超連結分享 - 可以用分享連結供使用者點選,另開視窗即可。 - 人人都會的[分享超連結](https://colab.research.google.com/gist/willismax/171dccff8e7ade253ea6ddad3ae262d4/-qrcode.ipynb)。 ## Colab 以 Gist 用`{}`內嵌 - HackMD 針對嵌入 Gist 程式碼已有優化,所以要在 HackMD 嵌入 Colob ,不是存在 GitHub,而是存在 Gist 才行唷! - [存至Gist以`{}`內嵌Colab](https://gist.github.com/willismax/171dccff8e7ade253ea6ddad3ae262d4)範例 ![](https://hackmd.io/_uploads/H1pzywqGj.png) ``` {%gist 171dccff8e7ade253ea6ddad3ae262d4 %} ``` - 結合`:::spoiler`切換展示效果 - 收合 ![](https://hackmd.io/_uploads/H1GhJw5Mo.png) - 開啟 ![](https://hackmd.io/_uploads/B1sq1vczs.png) ``` :::spoiler {%gist 171dccff8e7ade253ea6ddad3ae262d4 %} ::: ``` - 附帶一提,如果 Colab 已經與 Gist 同步的話,您有修正 Colab 而儲存時,會自動更新 Gist 內容,非常方便唷! > 也分享[今日簡報](https://hackmd.io/@wiimax/intro-hackmd-23),以及至今已公開的[所有簡報](https://hackmd.io/@wiimax/intro-hackmd-slides),供您一次瀏覽!

    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