gist僅為備份檔案,rendered題目請見hackmd
參考解答會在選項前以星號(*)標記,不過目前並不保證一定正確,各位高手可以自行編輯(需登入)提供各題詳解。
感謝提供題目的Anio俊傑和一同討論解題的各位: Sean, Moony Hsieh, johnson, 怡中, Jacky Chang
gist僅為備份檔案,rendered題目請見hackmd
參考解答會在選項前以星號(*)標記,不過目前並不保證一定正確,各位高手可以自行編輯(需登入)提供各題詳解。
感謝提供題目的Anio俊傑和一同討論解題的各位: Sean, Moony Hsieh, johnson, 怡中, Jacky Chang
gist僅為備份用檔案,完整rendered題目請見hackmd
參考解答會在選項前以星號(*)標記,不過目前並不保證一定正確,各位高手可以自行編輯(需登入)更正答案或提供各題詳解。 感謝一同討論解題的各位: Paul, 陳彥吉, 游聲峰Robert, Sean, Moony Hsieh, johnson, 怡中
| import os | |
| import asyncio | |
| import aiobotocore | |
| import io | |
| from PIL import Image | |
| AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID'] | |
| AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY'] | |
| // findOneOrCreate in Mongoose: | |
| // Return the original doc (no modification) if it can be found and create a new doc if cannot be found. | |
| // Without `$setOnInsert`, it will update the doc if it can be found. | |
| Model.findOneAndUpdate( | |
| {name: 'Matt'}, | |
| {$setOnInsert: {score: 60}}, | |
| {upsert: true, new: true} | |
| ) | |
| // Set `setDefaultsOnInsert` to true in option if need to insert with setting the default value. |
| import logging | |
| import json | |
| # modified from https://docs.python.org/3/howto/logging-cookbook.html#implementing-structured-logging | |
| class StructuredLogger: | |
| ''' The wrapper of logger that handles structurizing logs | |
| and passing logs to the root logger ''' |
| import logging | |
| from pymongo import MongoClient | |
| from sshtunnel import SSHTunnelForwarder | |
| # local | |
| SSH_PASSPHRASE = 'you ssh passphrase (if any)' | |
| LOCAL_BIND_PORT = 27017 | |
| SSH_KEYPATH = '/your/path/to/key/file' |
| """Visualize zh_TW translation progress of Python official docs | |
| Run the script under the project root of the repo. | |
| ref: https://github.com/python/python-docs-zh-tw | |
| """ | |
| import logging | |
| from pathlib import Path | |
| import pandas as pd | |
| import polib | |
| from git import Repo |