Skip to content

Instantly share code, notes, and snippets.

@uranusjr
uranusjr / migrator.py
Last active May 11, 2026 09:54
Manual Cadwyn migrator
"""
Socket-compatible migration runner.
How it bypasses FastAPI/HTTP coupling
--------------------------------------
Cadwyn's VersionChange decorators store transformer callables on instruction
objects. When an instruction is called it simply does:
def __call__(self, info):
return self.transformer(info)
@uranusjr
uranusjr / print_primes.md
Last active August 16, 2024 11:59
輸入一數字 n,印出 2 到 n 之間的質數。

知道一個數字是不是質數的方法是:

如果 n 不是質數,那麼 n 一定有一個小於等於 n 的因數。

所以我們可以用下面的程式判斷輸入的 n 是否為質數:

def is_prime(n):
    for i in range(2, n):
        if n % i == 0:  # 整除,i 是 n 的因數,所以 n 不是質數。
@uranusjr
uranusjr / better-python-env.md
Last active June 8, 2023 14:11
Toward a better Python installation

Toward a better Python installation

Meta

想要的特質

  • 不會太污染 PATH
  • 盡可能避免要求 root/admin 權限
  • 可以同時安裝多個版本(只需要到 minor,不須 patch)
  • 可以輕鬆啟動任意一個版本的 Python,不須多餘設定,版本之間也不會互相衝突
{
"ambient": { // Ambient sensor.
"ambient": [{x: timestamp, y: temperature}, /* more... */]
},
"1-1": { // Silo 1, cable 1.
"1": [{x: timestamp, y: temperature}, /* more... */], // Node 1.
"2": [{x: timestamp, y: temperature}, /* more... */] // Node 2.
}
}
@uranusjr
uranusjr / installation.rst
Last active August 1, 2021 19:16
在各作業系統上安裝 Python 3.4。

設定 Python 環境

開始使用 Pyhton 之前,首先要確定電腦上能不能執行 Pyhton 程式。本教學將需要 Python 3.4 或更高的版本,因此請確認電腦上是否有對應版本。若不確定電腦上是否已經安裝 Python,建議直接按照以下步驟設定,以保證教學中的程式皆能夠正常執行。由於各作業系統安裝流程不同,以下請按照作業系統,選擇自己需要的部份閱讀。

Windows

(deb_system)
siddhpant Kali Linux https://github.com/pypa/pip/issues/10151#issuecomment-888165609
Molkree Google Colab https://github.com/pypa/pip/issues/10151#issuecomment-886957554
pdxjohnny https://github.com/pypa/pip/issues/10151#issuecomment-889358122
KanTakahiro https://github.com/pypa/pip/issues/10151#issuecomment-889189881
(Cygwin)
allenatdecisiv https://github.com/pypa/pip/issues/10151#issuecomment-886309065
(MSYS2)
Collecting pip
Using cached pip-21.1.2-py3-none-any.whl (1.5 MB)
Collecting wheel
Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Collecting setuptools
Using cached setuptools-57.0.0-py3-none-any.whl (821 kB)
Installing collected packages: pip, wheel, setuptools
Attempting uninstall: pip
Found existing installation: pip 20.2.1
Uninstalling pip-20.2.1:

依賴解析器 Alpha 版本:相關資訊與測試指引

摘譯 The alpha dependency resolver: context and how to test,最後更新於 2020-04-21 03:14 UTC+8。

pip 20.1 中包含了一個 alpha 版本的依賴解析器全新實作。這個功能尚不穩定,不適合日常使用。本文將根據我們已知的測試需求滾動更新;若有任何回饋,請使用這個表單。

如之前公告,pip 開發團隊正在實作一個新的依賴解析器。我們在即日起釋出的新版本 pip 中包含了一個初步版本(alpha),讓使用者進行測試。

由於該功能預設關閉,要進行測試,需要在使用 pip 時加上 --unstable-feature=resolver。正常的 pip 使用情境不會受到新的解析器影響。

@uranusjr
uranusjr / pip-new-resolver-timeline.md
Last active April 13, 2020 10:41
pip 即將更新依賴解析器(PSF 公告)
@uranusjr
uranusjr / macdown-master-79c2a15.log
Created February 21, 2020 07:12
Build failure log for MacDown site
3:02:25 PM: Build ready to start
3:02:35 PM: build-image version: 8e315e54bc4032a32e73290be556cde4f8348c12
3:02:35 PM: build-image tag: v2.8.2
3:02:35 PM: buildbot version: 45cd00068410d70db72c9672cdd014995488e12a
3:02:35 PM: Fetching cached dependencies
3:02:35 PM: Starting to download cache of 216.5MB
3:02:51 PM: Finished downloading cache in 16.500911211s
3:02:51 PM: Starting to extract cache
3:02:57 PM: Finished extracting cache in 5.844598317s
3:02:57 PM: Finished fetching cache in 22.530673613s