散步是人生中的大事,而 Paseo 可以記錄與督促它。祝大家都有一個健康的體魄。
上個月,F-Droid 被 DNS 污染,這個月遭遇不同程度屏蔽。
這裏演示一下免費使用 AWS Lambda 創建一個查詢網頁大小的接口。之所以直接使用 Lambda 生成的鏈接而不是 API Gateway 的鏈接,是因爲 API Gateway 的免費額度是在註冊帳號的一年內有效。而且 API Gateway 最大超時只有 30 秒,而 Lambda 可以設置到 15 分鐘。
首先註冊一個帳號,我記得只要郵箱和手機號就行,不用綁定支付方式。然後在控制台搜索 Lambda 進入 Lambda 控制台。點擊 Funtction > Create function. 選擇 Author from scratch,輸入函數名字沒有特殊要求,Runtime 選 Python 3.10,Architecture 選 x86 和 arm64 都可以,各有免費額度。點開 Advanced settings,勾選 Enable function URL,勾選 None。CORS 看需要也可以勾上,然後點擊右下角 Create function 就可以了。
在函數頁面 Code 標籤頁貼上如下代碼:
import json import os import random import urllib.request UA = '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edge/19041.423 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 OPR/87.0.4390.99 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Vivaldi/6.1.3035.111 Mozilla/5.0 (Windows NT 10.0; WOW64; rv:85.0) Gecko/20100101 Firefox/85.0 Mozilla/5.0 (Windows NT 10.0; Win64; x64; Trident/7.0; rv:11.0) like Gecko Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.51 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36''' US_LIST=UA.split() def lambda_handler(event, context): event_body_str = event['body'] event_body = json.loads(event_body_str) # print(str(event_body)) if event_body['secret'] == os.environ.get('secret'): try: t_ua = random.choice(US_LIST) res = urllib.request.urlopen(urllib.request.Request( url=event_body['url'], headers={"User-Agent": t_ua,}, method='GET'), timeout=180) content = res.read() return { 'statusCode': 200, 'body': json.dumps(str(len(content))+' '+event_body['url']) } except: return { 'statusCode': 500, 'body': json.dumps('request failed.') } else: return { 'statusCode': 500, 'body': json.dumps('unauthorized.') }
secret 的環境在 Configuration > Environment variables 中添加。在 General configuration 中可以設置函數的超時時長 Timeout,默認是 3 秒。在 Function URL 裏可以看到我們需要的 URL 類似:https://4xyqiuexi7l3fcnuyuevjgclei0jhpuy.lambda-url.us-east-1.on.aws/ 。使用如下 curl 命令測試下:
curl -X POST -H "Content-Type: application/json" -d '{"secret":"Dn2Xk7d7RDkK_8bILy7lVe2NJlE4y7T_", "url":"http://ip-api.com/json"}' https://4xyqiuexi7l3fcnuyuevjgclei0jhpuy.lambda-url.us-east-1.on.aws/ #應該會得到如下結果 "296 http://ip-api.com/json"
免費額度使用情況可以在 Billing > Free Tier 頁面查看。Lambda 服務每月有 400000 seconds(GB-Second,如果的函數和我的一樣用的是 128 MB,那就可以乘以 8)和 1000000 次請求。
時間來到 2023 年,國內的二手機市場也迎來了新一代的索尼手機,其中 1、5、10 系列都各有所長。唯一需要注意的就是 AU 的手機對於中國移動用戶來說缺少的頻段過多,輕則導致上網不暢,重則漏接電話短信,除非你只是連 Wi-Fi。而 Docomo 雖然也缺一個移動頻段,但是日常使用中並不影響。關於二手索尼的版本,我推薦的順序是港版(雙卡雙待可刷機) > 歐版(可刷機) > Docomo日版 > Au日版。 當然市場價格應該也是這個順序。
失去支持後,dnf upgrade
會報錯 "Failed to download metadata for repo 'updates'" 。可以修改 /etc/yum.repos.d/
中如下四個文件:fedora.repo fedora-modular.repo fedora-updates.repo fedora-updates-modular.repo 中的兩行
baseurl=https://archives.fedoraproject.org/pub/archive/fedora/linux/updates/$releasever/Everything/$basearch/ #metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch
修改後便不再報錯,但是由於 35 已失去官方支持,所以不會再有更新。
!畢竟是更新系統,所以重要資料記得備份。!
可以通過 dnf system-upgrade
來方便的升級到 36 或 37(但是不能直接升級到38)。升級系統請參考官方的 DNF System Upgrade 以及 Upgrade to Fedora 37 from Fedora 36 using DNF。大約要下載 2G 大小的文件,下載後升級過程需要半個小時左右。主要命令如下:
#更新一下,如果有更新之後要重啓一下 sudo dnf upgrade --refresh #安裝系統升級 dnf 插件 sudo dnf install dnf-plugin-system-upgrade #下載要升級到的版本,如 37 sudo dnf system-upgrade download --releasever=37 #下載完畢,執行系統更新 sudo dnf system-upgrade reboot
執行 system-upgrade download 前需要把前面四個文件改回去,不然 archive 站點是沒有新系統的資料包的。
在 .vscode 文件夾中創建一個 lanch.json 文件, 內容如下:
{ "version": "0.2.0", "configurations": [ { "name": "Django Q", "type": "python", "request": "launch", "program": "${workspaceFolder}/manage.py", "args": [ "qcluster" ], "django": true, "env": { "DJANGO_SETTINGS_MODULE": "YOUR_PROJECT_NAME.settings" }, "gevent": true }, // Your other configurations go here ] }
只需修改兩個地方:program 裏的 ${workspaceFolder}
是變量,如果你項目的 manage.py 在 VS Code 項目根目錄下,那這行就不用修改。 DJANGO_SETTINGS_MODULE 這裏需要把 YOUR_PROJECT_NAME 替換成你項目的名字。然後按 Debug 按鈕就可以調試 Django Q task 了。
對於這個問題,ChatGPT 4 前前後後給出了五次錯誤配置,不得不記錄一下。
In the late 19th century at the height of the practice of Blackbirding, thousands of Ni-Vanuatu were forced to work on plantations in Australia and Fiji. With several languages being spoken in these plantations, a form of pidgin English was developed, combining English vocabulary with grammatical structures typical of languages in the region. This early plantation pidgin is the origin not only of Bislama, but also of Tok Pisin of Papua New Guinea and Pijin of the Solomon Islands.
This pidgin started spreading over the Vanuatu archipelago at the turn of the 20th century, as the survivors of Blackbirding began to come back to their native islands. Knowledge of this pidgin would facilitate communication not only with European traders and settlers, but also between native populations of remote islands within the archipelago.
Ni-Vanuatu began to add their own words and pronunciation (today 95% of Bislama is based on English, with a few dozen French words and ‘island language’ thrown in).
Over the past century or so, Bislama has evolved to what is currently spoken and written in Vanuatu.
In order to understand Bislama, common advice is to throw in the words "long" and "blong" a few times every sentence and you'll just about have It.
For example,
Stoa kolosap long haos: The store next to the house.
Mi bin stap long ples ia bifo: I have stayed at this place before. Breakdown of the sentence:
- "Mi" means "I"
- "bin" is a past tense marker, indicating that the action happened in the past.
- "stap" means "staying" or "living."
- "long" is a preposition that means "in" or "at."
- "ples" means "place."
- "ia" is a demonstrative marker that can mean "this" or "that" depending on the context.
- "bifo" means "before" or "previously."
Mi stap long stoa: I am at the store.
Jea long haos: The chair in the house.
Buk blong mi: The book that belongs to me, my book
Man Amerika: Man from America, American.
Hemi woman blong saiens: She is a woman of science, she is a scientist.
Here's a few other phrases to get you going on your journey to discovering this fascinating and fun new language.
本文更新於 2023/02/20。
Cloudflare Worker 可以方便的中轉 HTTP 請求,下面示例是我之前用過的,算是密碼保護的中轉特定請求。其中的 X_Custom_PSK 算是密碼,在 Settings > Variables 設置,這樣就只有我的程序可以請求。
addEventListener("fetch", event => { const psk = event.request.headers.get("X_Custom_PSK"); if (psk === X_Custom_PSK) { event.respondWith(handleRequest(event.request)); }else{ const failed_response = new Response('Sorry, you have supplied an invalid key.', { status: 403, }); event.respondWith(failed_response); } }) async function handleRequest(request) { const resp = await fetch('https://domain.ltd/checkpoint/list', { method: 'POST', headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.3 Safari/537.36', 'Accept': '*/*', 'Accept-Language': 'zh-CN;q=0.8,zh;q=0.6,en-US;q=0.4,en;q=0.2', 'Origin': 'https://domain.ltd', 'DNT': '1', 'Connection': 'keep-alive', 'Referer': 'https://domain.ltd/', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'cross-site' }, body: new URLSearchParams({ 'page': '1', 'pageSize': '10', 'latitude': '22.5', 'longitude': '114.0', 'queryType': '0' }) }); return resp; }
下面這個則是用一個 worker 代理多個網站。
addEventListener("fetch", event => { let url=new URL(event.request.url); if (event.request.url.indexOf('shaman')>-1){ url.hostname="ft.shaman.eu.org"; }else{ url.hostname="www.rfi.fr"; } let request=new Request(url,event.request); event.respondWith(fetch(request)); });