新版本的Laravel没有必要使用Laravel Scaffold Generator作为代码生成器了

Laravel 5.3+ Scaffold Generator代码生成器能让你通过执行一条 Artisan 命令,完成注册路由、新建模型、新建表单验证类、新建资源控制器以及所需视图文件等任务,不仅约束了项目开发的风格,还能极大地提高我们的开发效率。

但是Laravel 10、11 等高版本,在使用 php artisan make:model 命令生成模型类的文件时,可以开启–all 或 -a 选项,来同时生成对应的迁移、工厂、填充器、策略、控制器和表单请求等文件:

php artisan make:model Flight –all
php artisan make:model Flight -a

所以,已经无需使用Laravel Scaffold Generator作为代码生成器了!

Dutch Auction: Applications and Use Cases

A Dutch auction, also known as a descending-price auction, is a widely used mechanism, particularly suited for scenarios requiring rapid transactions or the allocation of limited resources.

In a Dutch auction, the price of an item starts high and decreases over time. If multiple buyers are interested, the first buyer to stop the auction at an acceptable price secures the item. Buyers are incentivized to act quickly, as waiting too long risks losing the item to someone else. As a result, items rarely drop to zero or negative prices—unless no buyer values them.

Common Applications

  1. Flower Auctions
    The most iconic use of Dutch auctions is in the Netherlands’ flower markets. Flowers are perishable, so fast transactions are critical. In these auctions, the auctioneer starts with a high price and gradually lowers it until a buyer stops the process at their preferred price, ensuring a quick sale.
  2. Bond Issuance
    Governments and corporations sometimes use Dutch auctions to determine the price and allocation of bonds. Investors place purchase bids as prices drop, and all successful bidders pay a uniform price. This method prevents price inflation caused by competitive bidding.
  3. Electricity Markets
    Dutch auctions are used in electricity allocation markets, such as procuring backup power during high demand. Utility companies aim to secure sufficient electricity at the lowest possible cost.
  4. Agricultural Product Auctions
    Similar to flower auctions, Dutch auctions are used to sell perishable agricultural goods like fruits and vegetables. This ensures quick sales at market-accepted prices, minimizing waste.
  5. Online Advertising Bidding
    Real-Time Bidding (RTB) in online advertising platforms employs mechanisms akin to Dutch auctions. Ad slots start with high prices that decrease over time, allowing advertisers to claim slots when the price aligns with their budget.
  6. Inventory Clearance
    Retailers and second-hand markets use Dutch auctions to clear inventory or discounted goods. Prices begin high and drop progressively, encouraging buyers to act promptly to avoid losing out or delaying purchases.
  7. Financial Asset Liquidation
    In financial markets, Dutch auctions are employed to liquidate assets quickly, such as bankruptcy assets or secondary stock sales. The goal is to convert assets into cash at the highest feasible price.
  8. Art and Collectibles
    While rare in high-end art auctions, Dutch auctions are sometimes used for items with immediate demand, such as license plates or commemorative coins, to accelerate transactions.
  9. Spectrum Auctions
    Governments often use Dutch auction-like mechanisms to allocate wireless communication frequencies, balancing efficient allocation with market-driven pricing.
  10. Parking Allocation
    Some smart parking systems adopt Dutch auction principles during peak periods, lowering prices incrementally to attract drivers.

Key Advantage

The primary strength of Dutch auctions lies in their efficiency and speed. They are ideal for situations where rapid decision-making and flexible supply-demand dynamics are crucial. Whether for perishable goods, financial assets, or high-demand resources, Dutch auctions provide a streamlined solution for swift and fair transactions.

价格递减的拍卖(荷兰式拍卖)

价格递减的拍卖(又称荷兰式拍卖)在实际中有许多应用场景,尤其适用于快速完成交易或针对有限资源的分配。

价格递减拍卖某件物品,如果存在多个买家想要购买这件物品,那么当价格降低到一定程度时,一定会有其中一个最想要它的买家叫停买下它,因为这个买家如果不及时叫停拍下的话,就很有可能会被其他买家拍下。因此价格递减拍卖某件物品,很少会真正导致价格降到0甚至负数,除非大家都不想要这件物品。

以下是一些典型应用场景:

1. 花卉拍卖

荷兰式拍卖最著名的应用场景是在荷兰的花卉市场。花卉是易腐商品,必须快速交易,价格递减拍卖能够让买家迅速做出决策,避免延误。拍卖过程中,拍卖师会从高价开始逐步降低价格,买家在适合的价格点时喊停。

2. 债券发行

政府债券或公司债券有时使用荷兰式拍卖来确定价格和分配。投资者在降价过程中提交购买请求,最终成交价格是所有成功投标者的统一价格。这种方式避免了竞标者为争抢资源而提高价格的现象。

3. 电力市场

在一些国家的电力分配市场中,价格递减拍卖用于分配发电权或购买发电能力。例如,高需求时的备用电力采购,电力公司希望以最低价格购买足够的电量。

4. 农产品拍卖

对于易腐烂的农产品,如水果和蔬菜,荷兰式拍卖有助于快速确定价格并完成交易,避免浪费。和花卉市场类似,农民或供应商可以通过这种方式以市场接受的价格快速卖出产品。

5. 网络广告竞价

**实时竞价广告系统(RTB)**中的某些机制也有类似荷兰拍卖的特点。广告位起价较高,逐步降低,广告主在适合的价位抢占广告资源。

6. 库存清理

零售行业或二手市场常用于清理库存或折扣商品。起初价格高,逐步降价,鼓励买家尽快购买,避免拖延导致商品滞销。

7. 金融资产清算

在金融市场中,荷兰式拍卖可以用于快速清算某些资产,如破产企业的资产、二级市场的股票交易等。目标是以尽可能高的价格快速完成资产变现。

8. 艺术品与珍藏品拍卖

虽然较少见于高端艺术品拍卖,但对于一些具有即时需求的物品(如车牌号、特殊纪念币等),荷兰式拍卖有时会用来加速交易。

9. 频谱拍卖

政府拍卖无线通信频段时,有时采用类似荷兰式拍卖的机制。

10.停车位分配

某些智能停车系统会以价格递减方式吸引停车需求高峰期的车主。 荷兰式拍卖的核心优势在于效率高、决策迅速,适合处理需要快速成交且供需灵活的场景。

Avoid Using Resource Routes and Resource Controllers in Laravel

In the Laravel framework, resource routes and their corresponding resource controllers are notoriously limited in flexibility, so it’s best to avoid them. There’s no silver bullet here—you might think they save you time upfront, but customizing them can become a headache. It’s often better to skip them altogether from the start and implement routes and controllers tailored to your specific needs.

尽量不要使用资源路由和资源控制器

Laravel框架中,资源路由和对应的资源控制器扩展性太差,尽量别用。没有银弹,你以为你能偷到懒,但其实资源路由和资源控制器定制起来可麻烦了,不如一开始就不要使用它们。

On the Granularity of Git Commits

When using Git, it’s best practice to commit your code after completing a small logical step—such as implementing one or more functions that achieve a minor feature—or upon finishing a module. This approach makes code tracking and merging much easier.

Avoid committing only after writing a large amount of code. If one small logical step contains an error, rolling back your commit could mean losing significant portions of otherwise correct code.

Similarly, if you make changes to existing code or comments, like fixing a bug, you should commit those changes immediately. Don’t wait until you’ve finished writing a new feature to bundle everything into one large commit.

关于git commit代码的粒度

应该做完一个小的逻辑步骤(例如写完了一个或几个函数实现了一个小功能)就提交一次,完成一个模块就提交一次,这样方便代码回溯,也方便代码合并。不要写了大量代码后再提交一次,万一其中的一个小逻辑步骤的代码写错了,代码回滚后,大量其他正确的代码都白写了。

修改了之前的代码或注释,例如修复一个bug,也应该及时提交一次,而不是继续写完当前小功能的代码之后一起提交。

问题不在于“家族传承吾辈责”,问题在于“垄断”

“家族传承吾辈责”是可以的,也是应该的,这样才能造就百年企业。问题在于“垄断”,你通过权力手段搞垄断,只许自己家族或团队把持这个行业,在国内你们确实一直赢赢赢,但是长期垄断会导致傲慢、低质的服务和产品,在国际市场上,你们就会输输输……不能搞垄断,要给人民选择权,有竞争才会有进步。

Ubuntu操作系统桌面版使用V2RayA翻墙

V2RayA的安装和配置,见官方文档https://v2raya.org/docs/prologue/introduction/

我的操作系统是Ubuntu 22,安装的V2RayA的版本是2.2.6.2。

V2RayA翻墙节点启动后,我能使用火狐浏览器成功访问到goole.com。

V2RayA翻墙节点启动后,在操作系统后台运行,即使我们重启浏览器或重启操作系统,它依旧是在运行着的。

有时候我们在终端下载安装一些国外的软件包,由于GFW原因,网速非常慢,很久都下载不下来,那么Ubuntu的终端如何使用v2rayA翻墙?

停止V2RayA的翻墙节点后,在终端运行以下命令:

$ wget www.google.com
--2024-11-08 01:25:07--  http://www.google.com/
正在解析主机 www.google.com (www.google.com)... 31.13.94.36, 2001::1
正在连接 www.google.com (www.google.com)|31.13.94.36|:80...

发现连不上谷歌。 启动V2RayA的翻墙节点后,再次在终端运行以下命令:

$ wget www.google.com
--2024-11-08 01:27:41--  http://www.google.com/
正在解析主机 www.google.com (www.google.com)... 31.13.94.36, 2001::1
正在连接 www.google.com (www.google.com)|31.13.94.36|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 未指定 [text/html]
正在保存至: ‘index.html’

index.html                                              [ <=>                                                                                                                ]  21.11K  --.-KB/s    用时 0.002s

2024-11-08 01:27:41 (11.7 MB/s) - ‘index.html’ 已保存 [21612]

可见,成功连接到谷歌并下载了谷歌的主页到index.html文件!上述实验说明,只要我们成功启动了V2RayA的翻墙节点,Ubuntu的终端也能借助V2RayA进行翻墙!

如果你启动了V2RayA的翻墙节点后,火狐浏览器能成功访问到goole.com,但是在终端运行wget www.google.com命令连不上谷歌,也许你应该在Ubuntu操作系统的设置->网络->网络代理中手动配置代理,如下图所示:

其中20171是V2RayA默认使用的http代理端口,20170是V2RayA默认使用的socks5代理端口。

newgrp: Changing the Current User’s Group

Overview:
newgrp is a command used to change the group associated with the current user. It allows the user to switch to a different group, affecting file permissions and other operations. This command operates within the context of the currently logged-in user, meaning it cannot be used to change the group for other users.

Syntax:

newgrp [group_name]

Details:
newgrp works similarly to the login command. It allows the user to log in again under the same account but with a different group. The primary effect of running newgrp is that it switches the user’s effective group to the specified one, which will influence operations such as file access permissions.
If no group is specified, newgrp logs the user into the default group associated with the user’s username.
To use newgrp to switch groups, the user must be a member of the specified group. Otherwise, access to that group will be denied. Once a user has switched groups via newgrp, they can revert to their original group by using the exit command to close the current shell session.

Parameters:

  • group_name: The name of the group to switch to.

Example:
To add a user to the docker group:

$ sudo usermod -aG docker username

Replace username with the actual username. To add the current user to the docker group, run:

$ sudo usermod -aG docker $USER

After adding the user to the docker group, a re-login or system restart is required for the changes to take effect. Alternatively, use the following command to reload the user’s group memberships without logging out:

$ newgrp docker