分类 技术 下的文章

我有一台2013的iMac,因为不能升级最新macos,而且用macos也慢所以就只安装了windows 11
今天想安装wsl的时候提示没有开启虚拟化,但查了一个这个cpu是支持虚拟化的
但是imac没有bios,设置不了,只能用第三方refind的引导程序来修改配置。
可是使用refind引导后发现win11启动不了,提示:
Stop code:KMODE_EXCEPTION_NOT_HANDLED(0x1E) What failed: AppleMNT.sys

查了一个AppleMNT.sys作用是让Windows支持访问macos的文件系统,对我来说没用
解决办法是把 system32/drivers/AppleMNT.sys 文件改名后就可以正常启动系统,而且也支持虚拟化。

缺点是Windows中的bootcamp不能打开控制面板,不过无所谓,我只有windows,所以bootcamp没用。

还有安装refind有个简单的办法 ,通过geniusdisk访问efi分区复制文件,再通过它的“设置UEFI BIOS启动项” 修改启动文件
\EFI\refind\refind_x64.efi

这里注意,如果想还原的话改回 \EFI\Microsoft\Boot\bootmgfw.efi 既可。

还有如果是在命令行操作的话有个注意的点:
下面这个必须在cmd下运行命令,不要在powershell, 这两个有区别
bcdedit /set {bootmgr} path \EFI\refind\refind_x64.efi

最近使用 Antigravity 自动生成Commit Message 会出错
Yup definitely broken… Error generating commit message: [unknown] error grabbing LLM response: stream error

很多人也有同样的问题,但官方都没修复。不知道是网络问题还是bug导致的。毕竟在国内都是魔法上网用的!
https://discuss.ai.google.dev/t/error-in-antigravity-not-generating-commit-message/114550/178

但这两天特别频繁,最后完全用不了了!
手写Commit Message太麻烦,后来想到可以用 Workflows 解决,也是挻方便的!

Description
Git Commit

Content

---
description: Automatically stage all changes and commit with a generated message
---
1. Stage all current changes in the repository.
   Run `git add .`
2. Generate a commit message following the Conventional Commits specification,written in Simplified Chinese.
   Ask: "Write a concise commit message summarizing the changes."
3. Create the commit using the generated message.
   Run `git commit -m "[generated commit message]"`

使用方法:在聊天窗口输入/后选择这个workflows既可!

最近练听力,找到 englishpod 的 mp3,非常不错,但是缺少同步字幕,所以用openai的whisper来转换
但是官方的 whisper 每次只处理30s,需要分片处理,所以找到了 Whisper Jax 声称速度更快,而且不需要自己处理分片的问题。

import jax
import jax.numpy as jnp
import os
import time
import json
import magic
from whisper_jax import FlaxWhisperPipline

def get_mp3_files(directory):
    total_files = 0
    print(f"scanning files...")
    for root, dirs, files in os.walk(directory):
        for file in files:
            mime = magic.Magic(mime=True)
            if mime.from_file(os.path.join(root, file)) == 'audio/mpeg':
                total_files += 1
                yield os.path.join(root, file)
    print(f"Total files: {total_files}")

def mp3_to_text(directory):
    pipeline = FlaxWhisperPipline("openai/whisper-large-v2", dtype=jnp.bfloat16)
    for mp3_file in get_mp3_files(directory):
        print(f"Processing file: {mp3_file}")

        txt_file = os.path.splitext(mp3_file)[0] + '.txt'
        if os.path.isfile(txt_file):
            print(f"Skipping file: {mp3_file}")
            continue

        start_time = time.time()
        text = pipeline(mp3_file, task="translate", language="chinese",return_timestamps=True)
        text_length = len(text['text'])  # 获取转录文本的长度
        print(f"Text length: {text_length} characters")
        end_time = time.time()
        print(f"Processed in {end_time - start_time} seconds")

        with open(txt_file, 'w') as f:
            f.write(json.dumps(text))


start_time = time.time()
mp3_to_text('/data/englishpod')
end_time = time.time()
print(f"Total time: {end_time - start_time} seconds")

使用这个工具
https://github.com/vzhd1701/evernote-backup

备份步骤1
如果是印象笔记要注意的是需要加入 --backend china 参数

./evernote-backup.exe init-db --backend china
Logging in to Evernote...
Username or Email: king@gmail.com
Password:
Enter one-time code (+XX XXX XXXX 2010): 638303
Authorizing auth token, china backend...
Successfully authenticated as king!
Current login will expire at 2024-07-09 07:31:21.
Initializing database en_backup.db...
Reading database en_backup.db...
Successfully initialized database for king!

备份步骤2

./evernote-backup.exe sync
Reading database en_backup.db...
Authorizing auth token, china backend...
Successfully authenticated as king!
Current login will expire at 2024-07-09 07:31:21.
Syncing user notebooks...
  [####################################]  60931/60931
2267 note(s) to download...
Downloading 2267 note(s)...
  [####################################]  2267/2267
Updated or added notebooks: 96
Updated or added notes: 2267
Expunged notebooks: 38
Expunged linked notebooks: 0
Expunged notes: 660
Synchronization completed!

备份步骤3

./evernote-backup.exe export ./
Reading database en_backup.db...
Exporting notes...
  [####################################]  96/96
All notes have been exported!

Swoole4.5.7 + hyperf

用阿里云上传文件的时候莫名奇妙的异常
Oss\Core\OssException: : RequestId:

找了好久才定位到是SWOOLE_HOOK_CURL导致的问题,于是
检查 bin/hyperf.php
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL);
配置是对的,根据Swoole官方文档 SWOOLE_HOOK_ALL:打开所有类型但不包括CURL
https://wiki.swoole.com/wiki/diff/?id=993&version=0&compare=current

然后发现一个好心人做了一个兼容组件
https://github.com/Reasno/swoole-aliyunoss-addon

安装后再把SWOOLE_HOOK_CURL打开
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL)

错误却变成了
string(106) "MissingContentLength: You must provide the Content-Length HTTP header. RequestId: 5FC048380D92D938376A214A"
这种情况不用定位了,还是换个Swoole版本看看效果,先删除swoole-aliyunoss-addon

composer remove swoole-aliyunoss-addon

然后把Swoole升级到4.5.8问题依旧
最后把Swoole降级到4.5.2问题解决

看了官方文档
https://wiki.swoole.com/#/runtime?id=swoole_hook_all
从 v4.5.4 版本起,SWOOLE_HOOK_ALL 包括 SWOOLE_HOOK_CURL
原来是这样....

如果版本高于4.5.4使用下面这个就可以解决问题了
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_CURL)

还有一个解决方案就是使用支持hook curl的php oss sdk
https://packagist.org/packages/starfalling/aliyun-oss-php-sdk