看到「SQL Style Guide」這個網站,把 SQL 常見的行為都列出來,寫了一份規範... 每個團隊未必都要照這個規範走,可以透過他條列的項目思考,再改成自己團隊的規範。
附註一下,最底下有繁體中文的翻譯版本,如果懶的看英文的版本可以看這份:「SQL樣式指南 · SQL Style Guide」。
幹壞事是進步最大的原動力
看到「SQL Style Guide」這個網站,把 SQL 常見的行為都列出來,寫了一份規範... 每個團隊未必都要照這個規範走,可以透過他條列的項目思考,再改成自己團隊的規範。
附註一下,最底下有繁體中文的翻譯版本,如果懶的看英文的版本可以看這份:「SQL樣式指南 · SQL Style Guide」。
這之後應該會變成 Python community 的神器之一...
剛剛看到分析 Python 程式效率的工具,只要有 pid 或是直接包著跑就可以分析:「Py-Spy: A sampling profiler for Python programs.」,執行起來長這樣:
而且還可以直接產生火焰圖讓開發者直接確認,超友善:
在 FAQ 的地方也有提到作者開發這套軟體的原因。有些在開發環境根本看不出問題的,可以很快的透過這個工具在 production 上看:
This project aims to let you profile and debug any running Python program, even if the program is serving production traffic.
另外一個重點在於其他常見的 profiling 工具通常都要改程式引用進來使用,這通常會使得程式效率慢下來,而 Pyflame 支援的平台比較少:
While there are many other python profiling projects, almost all of them require modifying the profiled program in some way. Usually, the profiling code runs inside of the target python process, which will slow down and change how the program operates. This means it's not generally safe to use these profilers for debugging issues in production services since they will usually have a noticeable impact on performance. The only other Python profiler that runs totally in a separate process is pyflame, which profiles remote python processes by using the ptrace system call. While pyflame is a great project, it doesn't support Python 3.7 yet and doesn't work on OSX or Windows.
Amazon S3 的 S3 Select 宣佈支援 Parquet 格式:「Amazon S3 Announces New Features for S3 Select」。
本來 S3 Select 就已經支援 CSV 與 JSON 格式,大多數的引擎也都可以直接吃,這次宣佈支援 JSON Arrays,以及 Parquet 格式:
Today, Amazon S3 Select works on objects stored in CSV and JSON format. Based on customer feedback, we’re happy to announce S3 Select support for Apache Parquet format, JSON Arrays, and BZIP2 compression for CSV and JSON objects. We are also adding support for CloudWatch Metrics for S3 Select, which lets you monitor S3 Select usage for your applications.
另外一個上面也有提到的是宣佈支援 bzip2 格式,不知道有沒有打算支援壓縮率更好的其他格式...
curl 的維護者 Daniel Stenberg 在他的 blog 上宣佈 curl 將會支援 DNS over HTTPS:「DoH in curl」。
從給的範例可以看出來就是多一個 CURLOPT_DOH_URL
可以設,對於要用的人很簡單:
curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, "https://curl.haxx.se/"); curl_easy_setopt(curl, CURLOPT_DOH_URL, "https://doh.example.com/"); res = curl_easy_perform(curl);
Twitter 上看到 Python 3 內建的 lru_cache()
:
One of my favorite Python 3 builtins is functools.lru_cache(): with a simple decorator, repeated function calls become O(1) table lookups. https://t.co/ORphGWvkCz pic.twitter.com/NmYVIxO9mE
— Jake VanderPlas (@jakevdp) August 8, 2018
從文件上可以看到預設值是 128 個:
@functools.lru_cache(maxsize=128, typed=False)
tweet 裡面有討論到 memory leak 的問題可以看一下,不過如果是拿來寫工具的話,應該不會有什麼問題...
AWS 推出了 Amazon DynamoDB 的相容 Docker Image,讓開發者可以在本地端測試 DynamoDB 的 API:「Use Amazon DynamoDB Local More Easily with the New Docker Image」,在 amazon/dynamodb-local 這邊可以拉到,裡面其實是包 Java:
DynamoDB local is now available to download as a self-contained Docker image or a .jar file that can run on Microsoft Windows, Linux, macOS, and other platforms that support Java.
這樣在 Continuous Integration (CI) 的過程裡面也可以拉起 service 測試...
這兩天又遇到一次,這應該是 Laravel 裡設計比較奇怪的地方,既然是跑 PHPUnit 的環境,為什麼不預設在錯誤發生時把完整的 stack 拋到 console...
這邊的解法是參考「Laravel: How to enable stacktrace error on PhpUnit」這篇的解答。
舊版需要自己丟 handler 進去 (5.4 以及之前的版本),在 5.5+ (寫這篇時最新的穩定版本已經是 5.6) 有內建 withoutExceptionHandling()
可以用,所以在 tests/TestCase.php
內搞定 setUp()
:
protected function setUp() { parent::setUp(); $this->withoutExceptionHandling(); }
不知道有沒有機會直接進 Laravel 的 package 設定裡面...
在 Twitter 上看到 GitHub 把網站上的 jQuery 都拔乾淨了。因為現代瀏覽器大多都可以直接來,或是有其他方案可以用:
We’re finally finished removing jQuery from https://t.co/r2QL2aHBfa frontend. What did we replace it with? No framework whatsoever:
• querySelectorAll,
• fetch for ajax,
• delegated-events for event handling,
• polyfills for standard DOM stuff,
• CustomElements on the rise.— Mislav Marohnić (@mislav) July 25, 2018
querySelectorAll
是 IE9+ 我可以理解,不過 Fetch
查了資料發現是 Edge 才支援的 (而且還要新一點的 Edge),找 GitHub 文件看到「Supported browsers」這篇,看起來 GitHub 網站直接放掉 IE 啊,另外 Firefox ESR 也是 best effort 而已,能這樣規劃跟網站性質有關係,一般網站還是得考慮 IE11 (因為 Windows 7)...
在 Twitter 上看到 Jeff Barr 提到 Amazon Translate 支援繁體中文與日文的消息:
Amazon Translate Adds Support for Japanese, Russian, Italian, Traditional Chinese, Turkish, and Czech - https://t.co/J8lCdJ7ygJ #AWS pic.twitter.com/GYyygw46Jt
— Jeff Barr ☁️ (@jeffbarr) July 17, 2018
console 上也可以測試:
翻了一下價錢:
Amazon Translate is priced at $15 per million characters ($0.000015 per character).
定價與其他服務相比算是中間... 隔壁微軟的 Translator Text API 的 PAY AS YOU GO 方案是 $10 (Per million characters),如果有量的話會降更多。而 Google 的 Cloud Translate 則是 $20 per 1,000,000 characters。