C++ 與組語的速度...
在 Hacker News Daily 上看到「Why is this C++ code faster than my hand-written assembly for testing the Collatz conjecture?」覺得很有趣... 作者寫了一段 assembly,但跑起來比用 C++ 同義的版本慢多了。目前最高分的答案給了很清楚的解釋... even: mov rbx, 2...
View ArticleGitHub 上有大量重複的程式碼...
扣除掉 fork 的程式碼後,研究人員在 GitHub 上還是發現有大量重複的程式碼:「DéjàVu: a map of code duplicates on GitHub」。 This paper analyzes a corpus of 4.5 million non-fork projects hosted on GitHub representing over 482 million...
View ArticleTwitter 放出來的 Vireo,一套 Open Source 授權的 Video Processing Library
Twitter 放出 Vireo,一套以 MIT License 釋出的 Video Processing Library:「Introducing Vireo: A Lightweight and Versatile Video Processing Library」。專案庫在 GitHub 的 twitter/vireo 可以取得。 用 C++ 寫的,另外也已經提供 Scala...
View ArticleWindows 上的 Chrome 改用 Clang 編譯
這應該是上個禮拜蠻熱鬧的一件事情 (i.e. 很多人看熱鬧 XD),就是 Google Chrome 從 Visual C++ 改成用 Clang 編譯:「Clang is now used to build Chrome for Windows」。 文章裡推敲效能應該不是主要的因素,因為在不同項目測試下各有千秋,而且差距都不大: We conducted extensive A/B...
View ArticleYubico 宣佈推出 Lightning 的 U2F 界面...
Yubico 在 CES 2019 上宣佈推出兩用版的 YubiKey,同時支援 USB-C 與 Lightning 接頭:「Yubico Launches the Security Key NFC and a Private Preview of the YubiKey for Lightning at CES 2019」。 從照片可以看出來是直接做成兩側各一個頭: 目前是 Private...
View ArticleRaspberry Pi 4 的 Type C 無法使用 Macbook Charger 供電的問題
Raspberry Pi 4 出來後有些災情 (畢竟又加了不少東西近去),在 Hacker News 上看到的 Type C 介面的充電問題:「Raspberry Pi 4 not working with some chargers (scorpia.co.uk)」,引用的原文可以在「Pi4 not working with some chargers (or why you need two...
View ArticleCanonical 推出的 Dqlite (High-Availability SQLite)
第一眼看到的時候直接有種不知道 Canonical 在幹什麼的感覺,翻完說明後大概知道可以用的地方,但還是覺得範圍有點小:「Dqlite - High-Availability SQLite」。 一種使用情境是,在 embedded system 上面同步資料的一種方案... 吧?例如網路連線的頻寬或是品質受限,無法順利傳到 Internet...
View Article老闆走近時自動切換視窗的玩具...
看到「Daytripper: Hide-My-Windows Laser Tripwire」這個東西,可以偵測有人走過 (然後你就可以設定後續的行為): 由兩個裝置組成: 用電池供電,充滿可以供應 40 小時,然後再用 Type-C 充電...
View Article一個超小的 HTTP Server Library
httpserver.h 這個專案是用 C 寫的,就一個 .h 檔,從範例可以看到用法不算太複雜: #define HTTPSERVER_IMPL #include "httpserver.h" #define RESPONSE "Hello, World!" void handle_request(struct http_request_s* request) { struct...
View Article用 C 與 Makefile 開發的 Android 專案
上個禮拜在 Hacker News Daily 上看到「cnlohr/rawdrawandroid」這個專案: Build android apps without any java, entirely in C and Make 看起來包括了 cross-compile 的支援,只要在 Makefile 裡面設定對應的平台就可以了: You may want to support multiple...
View ArticleRaspberry Pi 推出 MCU 產品 Pico
Raspberry Pi 推出了新的產品線 Raspberry Pi Pico,基於 ARM 架構的 MCU (microcontroller unit),Hacker News 上也有不少討論:「Raspberry Pi Pico and RP2040 Microcontroller (raspberrypi.org)」。 與 Raspberry Pi 的 Zero 系列比起來,Zero 上面有...
View ArticleGoogle Groups 把 comp.lang.c 給禁了...
Hacker News Daily 上看到的,Google Groups 把 comp.lang.c 給禁了,連到 https://groups.google.com/g/comp.lang.c 可以看到無法使用的訊息: 警告:內容已遭禁止 comp.lang.c 已被認定為包含垃圾內容、惡意軟體或其他惡意內容。 如要進一步瞭解 Google...
View ArticleUSB Type-C 要增加 240W 的規格...
在「USB Type-C Specification 2.1 allows up to 240W Extended Power Range (EPR)」這邊看到這個規格: Extended Power Range cables have additional requirements to assure that these cables can deliver the full defined...
View ArticleStackOverflow 開賣 Ctrl、C、V 的鍵盤
StackOverflow 今年愚人節的鍵盤真的開賣了:「No joke—you can buy our copy/paste keyboard right now」。 愚人節的文章在「Introducing The Key」,這次開賣的網站是跟 Drop 合作:「Stack Overflow The Key Macropad | Mechanical Keyboards | Mini...
View ArticleQOI 圖片無損壓縮演算法
在 Hacker News Daily 上看到「Lossless Image Compression in O(n) Time」這篇,作者丟出了一個圖片的無損壓縮演算法,壓縮與解壓縮的速度超快,但壓縮率又不輸 PNG 太多,在 Hacker News 上的討論也可以看一下:「QOI: Lossless Image Compression in O(n) Time (phoboslab.org)」。...
View Article電子紙的螢幕 BOOX Mira Series
看到「BOOX Mira Series」這個,主要是因為現在公司的老闆是電子墨水的發明人之一 (也是 E Ink 的 cofounder),所以看到一些電子墨水的新聞也會覺得有趣... 比較小的 BOOX Mira 是 13.3" 的 4:3 螢幕,但 resolution 也已經拉到 2200x1650 了,207 ppi,走 Mini HDMI 或是 Type C 輸入,賣...
View Article兩個 unsigned int 取平均值的方法
在 Hacker News Daily 上看到 Raymond Chen 在講怎麼對兩個 unsigned int 取平均值的方法:「On finding the average of two unsigned integers without overflow」,這篇裡面提到了不少有趣的歷史,另外 Hacker News 上的討論「Finding the average of two...
View Article拿 pytest 測 C 的程式
在 Hacker News 上看到「Running C unit tests with Pytest (p403n1x87.github.io)」這串討論,就如同標題所寫的,拿 pytest 測 C 的程式:「Running C unit tests with pytest」。 拿既有還蠻成熟的 testing framework 來用,而且看他的範例裡,C 的部份只要 symbol 有...
View ArticleC 語言的兩個笑話 (以及他的惡搞原理)
Twitter 上看到兩則 C 語言的笑話: a lot of people don't know this - C actually lets you do arithmetic with mixed types, much like JavaScript: pic.twitter.com/6XF4qm41xv — luna 💙 (@lunasorcery) March 18, 2022 This...
View Article從三角函數 cosine 的實做問題學一些週邊知識...
前幾天在 Hacker News 上看到「Implementing Cosine in C from Scratch (2020) (austinhenley.com)」這篇 2020 的文章,原文是「Implementing cosine in C from scratch」,裡面內在講自己刻三角函數的 cosine 所遇到的一些嘗試。 cosine...
View Article