## 兩個 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 unsigned integers without overflow (microsoft.com)」也可以翻翻。

```unsigned average(unsigned a, unsigned b)
{
return (a + b) / 2;
}
```

```unsigned average(unsigned low, unsigned high)
{
return low + (high - low) / 2;
}
```

```unsigned average(unsigned a, unsigned b)
{
return (a / 2) + (b / 2) + (a & b & 1);
}
```

```unsigned average(unsigned a, unsigned b)
{
return (a & b) + (a ^ b) / 2;
}
```

```unsigned average(unsigned a, unsigned b)
{
// Suppose "unsigned" is a 32-bit type and
// "unsigned long long" is a 64-bit type.
return ((unsigned long long)a + b) / 2;
}
```

## Laravel 9 (LTS) 出了

For LTS releases, such as Laravel 9, bug fixes are provided for 2 years and security fixes are provided for 3 years. These releases provide the longest window of support and maintenance. For general releases, bug fixes are provided for 18 months and security fixes are provided for 2 years.

## PostgreSQL 15 將可以對透過 UNIQUE 限制 NULL 的唯一性了

```The SQL standard has been ambiguous about whether null values in unique constraints should be considered equal or not.  Different implementations have different behaviors.  In the SQL:202x draft, this has been formalized by making this implementation-defined and adding an option on unique constraint definitions UNIQUE [ NULLS [NOT] DISTINCT ] to choose a behavior explicitly.

This patch adds this option to PostgreSQL.  The default behavior remains UNIQUE NULLS DISTINCT.  Making this happen in the btree code is pretty easy; most of the patch is just to carry the flag around to all the places that need it.

The CREATE UNIQUE INDEX syntax extension is not from the standard, it's my own invention.

I named all the internal flags, catalog columns, etc. in the negative ("nulls not distinct") so that the default PostgreSQL behavior is the default if the flag is false.

Reviewed-by: Maxim Orlov
Reviewed-by: Pavel Borisov
Discussion: https://www.postgresql.org/message-id/flat/84e5ee1b-387e-9a54-c326-9082674bde78@enterprisedb.com
```

## Raspberry Pi OS 64-bit 與 32-bit 的效能差異

Using a Raspberry Pi 400 keyboard computer with 4GB of RAM, I ran some fresh benchmarks of Raspberry Pi OS in its default 32-bit build and then again with the new 64-bit build.

Across the few dozen different workloads tested, switching Raspberry Pi OS 11 for the 64-bit version improved the performance on average by about 48%. See all the 32-bit vs. 64-bit Raspberry Pi benchmarks over on OpenBenchmarking.org.

## PHP: The Right Way

Hacker News 上面意外看到「PHP – The Right Way (phptherightway.com)」，官網在「PHP: The Right Way」這邊，另外我在 2012 年的時候也有提過這個站台：「PHP 康莊大道」。

## Raspberry Pi OS 64-bit 版本正式推出

Twitter 上看到前同事貼了 Raspberry Pi 官方放出 Raspberry Pi OS 64-bit 版本的公告：「Raspberry Pi OS (64-bit)」。

The 64-bit version of Chromium, installed by default, has no version of the WidevineCDM library and therefore, it is not possible to play streaming media such as Netflix or Disney+.

## 一些不太容易注意到的 Python 安全性問題

In Python < 3.6, the folders A, B and C are each created with permission 700. However, in Python > 3.6, only the last folder C has permission 700 and the other folders A and B are created with the default permission 755.

```>>> os.path.join('var', 'lib', 'tmp', 'abc.png')
'var/lib/tmp/abc.png'
```

In Python < 3.7 the function urllib.parse.parse_qsl allows the use of the ; and & characters as separators for URL query variables.

Changed in version 3.10: Added separator parameter with the default value of &. Python versions earlier than Python 3.10 allowed using both ; and & as query parameter separator. This has been changed to allow only a single separator key, with & as the default separator.

## Backblaze 的 2021 年硬碟死亡報告

Backblaze 放出 2021 年的硬碟統計數據了：「Backblaze Drive Stats for 2021」。

## MariaDB Corporation Ab 透過 SPAC 上市

Upon closing of the transaction, the combined company will be named MariaDB plc and led by MariaDB’s CEO Michael Howard.

## 紐約時報買 Wordle...

Hacker News 上看到「The New York Times Buys Wordle」這篇，紐約時報買下 WordleHacker News 上的討論「The New York Times buys Wordle (nytimes.com)」裡面有在討論商業模式之類的事情，另外因為紐約時報的報導放在 paywall 裡面，所以另外提供 Internet Archive 的版本可以看：「The New York Times Buys Wordle」。

Wordle was purchased from its creator, Josh Wardle, a software engineer in Brooklyn, for a price “in the low seven figures,” The Times said. The company said the game would initially remain free to new and existing players.