楊進雄
    • 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
    • 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 Note Insights 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- title: WSL Install tags: Note_Linux, Docker, Linux description: Docker, Linux, Program, Online --- # [WSL Install](https://hackmd.io/@billsun/BJByCIUHf) > Windows Subsystem for Linux (WSL) ## 事前須知 作業系統 * Windows 10 家用版,版本 1903 或更高版本,含 組建 18362 或更高組建。 (x64 的處理器) * Windows 10,版本 2004 或更高版本,含 組建 19041 或更高組建。 (ARM64 的處理器) ![](https://i.imgur.com/L30eOYc.png) ## 方法 > 到「控制台 > 程式與功能」,點擊「開啟或關閉 Windows 功能」。 ![](https://i.imgur.com/OvIL7zD.png) > 要重開機才能繼續安裝,學校教室有防寫, 如果沒有一開始沒有開這二個選項, 就不用試。 ## [使用 WSL 在 Windows 上安裝 Linux](https://learn.microsoft.com/zh-tw/windows/wsl/install) [WSL 的基本命令](https://learn.microsoft.com/zh-tw/windows/wsl/basic-commands?source=recommendations) PowerShell上執行 執行 wsl --list --online 以查看可用的版本清單 > wsl -l -o ```shell= wsl -l -o wsl --update wsl -l -o ``` wsl --install -d <DistroName> 以安裝散發版本。 > wsl --install -d Ubuntu > wsl --install -d Ubuntu-20.04 ```shell= wsl --install -d Ubuntu-20.04 ``` 下載和安裝, 第一次啟動, 新增使用者 user ![](https://i.imgur.com/fH9R5U0.png) In Windows 10 PowerShell 列出已安裝的 Linux 發行版本,此命令也可以輸入為:wsl -l -v ```shell= wsl --list --verbose ``` WSL 忘記密碼 ```shell= wsl -d Ubuntu-22.04 --user root ``` [Install GCC on Ubuntu 22.04](https://www.cherryservers.com/blog/how-to-install-gcc-on-ubuntu) Windows 終端機可以從 [Windows 商店](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=zh-tw&gl=tw) 取得 在終端機可選擇進入那個作業系列 ![](https://i.imgur.com/e7uv1m2.png) >目前Ubuntu STATE 為Stopped會發生上課遇到的錯誤, >[處理結束,代碼為 4294967295 (0xffffffff)] >可用 wsl --install -d Ubuntu ,即可進入Ubuntu, >再用 wsl --list --verbose, Ubuntu STATE 為 Running 或用下列方法 ``` C:\Windows\system32\wsl.exe -d Ubuntu-20.04 改成 "C:\Windows\system32\wsl.exe" ~ -d Ubuntu-20.04 ``` ![](https://i.imgur.com/khCzPQ6.png) ## [How to Fix WSL: Error code: WSL/Service/0x80040326](https://localusr.com/posts/2023/03/01-fix-wsl-0x80040326-error/) > When you use Windows 10/11 with the WSL service, you can encounter the following error ``` Error: 0x80040326 Error code: Wsl/Service/0x80040326 ``` 1. Open Windows Powershell in administrator mode 2. Update WSL and shut it down completely ```shell= PS C:\Users\mossad> wsl --update Checking for updates. Updating Windows Subsystem for Linux... PS C:\Users\martinmusale> wsl --shutdown ``` 3. Test that the error is fixed ```shell= PS C:\Users\martinmusale> wsl -d Ubuntu-20.04 ``` ```shell= sudo apt install python3 sudo apt install python-is-python3 python --version sudo apt update sudo apt upgrade -y sudo apt install python3-pip ``` ![](https://i.imgur.com/AfIwuAa.png) > 2023/02/21回家作業 ```shell= df cd /mnt/d ls -l curl ifconfig.me python --version ``` >![](https://i.imgur.com/HK4at7H.png) * df:df 是一個查看硬碟空間使用情況的指令。它會列出硬碟分區的大小、已用空間和可用空間等資訊。 * cd /mnt/d:cd 是目錄切換的。在這裡,這個指令將當前工作目錄更改為 /mnt/d。 * ls -l:ls 是列出目錄內容,而 -l 則是將內容以長格式(即列出每個檔案或目錄的詳細資訊,例如擁有者、權限、檔案大小等)列出。 * curl ifconfig.me:curl 是一個用於從命令列中下載或上傳資料的指令。ifconfig.me 是一個用於獲取您的公用 IP 地址的網站。這個命令將使用 curl 訪問該網站,並將使用者的對外連線 IP 地址輸出到命令列中。 * python --version:python 是一程式語言,而 --version 用於顯示系統中安裝的 Python 版本。 ## [How to install Nginx + php + MySQL on WSL Ubuntu 20.04- Windows 10] (https://www.how2shout.com/how-to/install-nginx-php-mysql-on-wsl-ubuntu-20-04-windows-10.html) 需要一些時間 ```shell= sudo apt update ``` sudo apt upgrade先不做,太花時間了 > sudo apt upgrade ```shell= sudo apt-get install php7.4-cli php7.4-fpm php7.4-curl php7.4-gd php7.4-mysql php7.4-mbstring zip unzip ``` ```shell= sudo apt install nginx ``` Start Nginx services ```shell= sudo service nginx start ``` Access Nginx through the browser > http://127.0.0.1 or http://localhost or http://your-system-ipaddress ## [HxD is a hex editor](https://mh-nexus.de/en/downloads.php?product=HxD20) 四則運算 ### Input 輸入一個字串,其中包含運算元及運算子,為了方便讀取,所有的運算子及運算元均以空格區隔。 運算元為 0 ~$2^{31}-1$ 的整數 運算子則包含 + - * / % 及 ( ) 運算時請注意先乘除後加減及() 優先運算的計算規則 ```= 3+2*2 (1+(4+5+2)-3)+(6+8) 3+5 / 2 ``` ### Output 輸出結果。為了避免小數點誤差,所有的運算過程都不會產生小數點,可以放心使用整數進行運算 ```= 7 23 5 ``` #### Answer ```python= import sys for s in sys.stdin: print(eval(s.replace("/", "//"))) ``` # 以1970-01-01開始的總天數, Python 在Windows 的雷 :::info 以1970-01-01開始的總天數為0,對應到的日期為 '1970-01-01' 以1970-01-01開始的總天數為1,對應到的日期為 '1970-01-02' 以1970-01-01開始的總天數為18039,對應到的日期為 '2019-05-23' 以1970-01-01開始的總天數為18405,對應到的日期為 '2020-05-23' ::: :::danger 在Linux和Mac正常,在Windows無法跑,會出現OverflowError錯誤訊息 ```shell Traceback (most recent call last): File "time.py", line 6, in <module> end_sec2 = time.mktime(time.strptime(end_date,'%Y-%m-%d')) + date_time * (24*60*60) OverflowError: mktime argument out of range ``` ::: #### Answer ```python= import time import datetime date_time = 0 end_date = '1970-01-01' end_sec2 = time.mktime(time.strptime(end_date,'%Y-%m-%d')) + date_time * (24*60*60) print(time.strftime("%Y-%m-%d", time.localtime(end_sec2)) ) ``` --- ![](https://i.imgur.com/6doiDnF.png) ZeroJudge d074 ``` 5 42 39 41 43 30 ``` ```python= input() print(max(list(map(int,input().split())))) ``` ```python= t=input();print(max([int(x) for x in input().split()])) ``` 基礎使用 --- - [repl.it] repl.it WSL Ubuntu 20.04 Node v18.17.1 Install == ```shell= sudo apt install python3 sudo apt install python-is-python3 python --version ``` 安裝 Node v18.17.1 ```shell= sudo apt-get install -y curl sudo curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - ``` 出現的提示: ``` ## Run `sudo apt-get install -y nodejs` to install Node.js 18.x and npm ## You may also need development tools to build native addons: sudo apt-get install gcc g++ make ## To install the Yarn package manager, run: curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn ``` 依提示安裝下列程式: ```shell= sudo apt-get install -y nodejs sudo apt-get install -y gcc g++ make curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install -y yarn ``` 很重要的檢查方式, 要 node --version 和 sudo node --version 都能看到 v18.17.1 的版本 ```shell= user@402-PC09:~$ node --version v18.17.1 user@402-PC09:~$ sudo node --version v18.17.1 ``` 確認之後, 才能安裝 DOLOS ```shell= user@402-PC09:~$ sudo npm install -g npm@10.1.0 user@402-PC09:~$ sudo npm install -g @dodona/dolos ``` ``` added 232 packages in 31s 31 packages are looking for funding run `npm fund` for details ``` 很重要的檢查方式, 要能看到以下三列的顯示結果 ```shell= $ dolos --version ``` 能看到以下三列 ``` Dolos v2.3.0 Node v18.17.1 Tree-sitter v0.20.5 ``` WSL Ubuntu 20.04可共用 Windows 的資料匣, 但要用 cd /mnt/e/ 來切資料匣 ```shell= #cd /mnt/e/Python/ cd /mnt/d/linux/ wget http://ms.ntub.edu.tw/~shyong/ssl/Dolos.zip sudo apt install unzip unzip Dolos.zip cd Dolos/student_P dolos run -f web -l python *.py ``` 是否需要 --host 0.0.0.0 , 不同環境作法不一樣 http://localhost:3000/#/ ```shell= dolos run -f web -l python *.py ``` http://172.30.100.116:3000/#/ ```shell= dolos run -f web -l python *.py --host 0.0.0.0 ``` ![](https://hackmd.io/_uploads/Syg8x1Oea.png) ``` find problem_A1 -type f -path "*/team*/correct*.py" -exec cp {} Dolos/problem_A1/ \; ```

    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