Flutter

浏览模式: 标准 | 列表 | 图文
解决蓝牙鼠标飘的问题

轻置顶 解决蓝牙鼠标飘的问题

之前写过一篇Mac蓝牙鼠标卡顿、飘的临时解决方案,但当时这种方法其实现在感觉一般其实还有一个简单粗暴的办法,打开活动监视器,搜索bluetoothd(其实只要搜索blu三个字母就出来了)。然后直接杀掉这个进程。

因为这个是系统服务,你杀完后他会自动重启,这时候晃晃鼠标什么的,就又会自动连上了。

卡顿的问题基本上确实就是:2.4G的wifi冲突,当然还有可能是某些中断导致。但一般重启一下bluetoothd服务就能解决90%以上的问题。

再不济,重启吧

轻置顶 mac没有声音的处理

mac突然间就没有声音了。。。按照以往的办法,拿出耳机,插拔一下。。。结果 还是没有

最后没办法,从网上找了点资料,说是:
sudo killall coreaudiod
然后就好了,不过有人说,这样也不一定有效,果然在知乎上有很多大神就说了不少方法,手法不同,各有千秋,我挑个最简单的出来:
著作权归作者所有。
商业转载请联系作者获得授权,非商业转载请注明出处。
作者:周全
链接:http://www.zhihu.com/question/21975970/answer/20769174
来源:知乎

应该是系统问题 重启成本还是很高的 可以试着重载声音驱动

sudo kextunload /System/Library/Extensions/AppleHDA.kext
sudo kextload /System/Library/Extensions/AppleHDA.kext
其他更多请查看上述的链接,或者打开这个网页:http://www.zhihu.com/question/21975970
解决orbstack的 data.img 过大而导致无法备份的问题

解决orbstack的 data.img 过大而导致无法备份的问题

在Mac 用 orbstack 代替 docker 之后,确实方便不少,而且 orb 创建 debian/ubuntu 的虚拟机也很方便,几乎就是分分钟搞定。然后就可以通过 orb 进入默认的虚拟机,方便在 mac 上使用 linux 来进行操作很多事情。过多的 orbstack 的用法我就不讲了,网上有一堆堆的教程。

但随之带来的另一个问题就是,orbstack 几乎无法备份了。因为在他的目录下~/.orbstack/data/data.img,这个文件显示是8T,虽然说它是一个稀疏文件,然而却是很多软件不认,比如说 rsync。
你会发现你1T 的硬盘备着备着突然就磁盘满了。虽然`~/.orbstack/data/data.img`这个文件其实只有几 G 或者10几 G,但 rsync 认为他是8T,导致备份失败,所以在实际应用中,必须要加入 --exclude ".orbstack/data/data.img" ,否则备一次失败一次
看官方的 issue 中,也有不少人用苹果的time machine 备份也失败了。这真让人烦恼。官方也没有给出一个方法用来压缩成实际大小,这个 Parallels Desktop 和 virtual machine 好象都有。象 PD 默认创建的时候 可以指定大小,比如10G,实际使用中超过时,会随之增大,同时也可以压缩成实际大小(好象只支持 windows???记不太清)
如果 orb 也有这个功能就好了,就这样吧
梯子无法打开增强模式

梯子无法打开增强模式

ClashX 和 ClashX Pro 真的是两个不同的软件。在 CSDN 上有教你,如果打不开增强模式时候 的操作。鉴于这里不太方便贴这样的内容,我说一下思路

1、sudo launchctl unload -w /Library/......plst
2、删除这个 list。有时候 可能会有多个。你得看一下。估计是会有多个不同的存在
删除完后,重新运行。会提示你安装辅助插件,点取消。会重新让你以传统模式进行安装,至此完成
mac多屏幕下的程序坞问题以及打开系统设置的方法

mac多屏幕下的程序坞问题以及打开系统设置的方法

在mac 下面,如果你多屏幕 的。建议把 程序坞隐藏掉。这样有个好处,在任一屏幕 上,到指定位置都能打开程序坞。不然,你固定在 main 窗口,他不知道什么时候 就到另一个屏幕去了,而且连原因都不知道。。(适合屏幕左右排列,程序坞在最下方),程序坞放在左、右侧的都不起使用。

另一个就是快速打开屏幕 设置。按住 option+屏幕亮度,可以打开系统设置(+音量,可以打开音量设置),加 F3那个可以打开外观设置
如果你不想管理程序坞,建议安装 Raycast 这个软件,免费版的就行。可以自己调定快捷键来管理:窗口大小和位置,以及打开任意已经打开过的 APP(这个还是比较方便的,因为有些APP 因为屏幕空间小的关系,在使用的时候 会隐藏在副屏,或者第二、第三窗口,如果直接通过触摸板来切换,很麻烦。打开已存在的 APP,则可以直接激活窗口)。【cmd+tab 也可以,但 cmd+tab 有个很烦的地方1、他会激活在你不知道是哪个窗口,2你只能通过多次按 tab 来切换】而 raycast 的这个就比较方便了,支持快捷键、支持模糊搜索。
---EOF---

MAC下让 sudo 使用指纹而不是密码

MAC下让 sudo 使用指纹而不是密码

确实每次在终端下输入 sudo 运行命令的时候要输密码很麻烦,因为有不少时候会在中文模式下。比如 npm run dev ,在 mac 下,低于1024的端口要启动,都是要带 sudo 才 OK。虽然大多数情况下,项目都是会带上 port,但有极少数情况下是不带的。

这时候 会运行 sudo npm run dev 。然后因为一些其他原因,比如在其他地方 sudo n ( 或 sudo nvm) 切换了版本,当前的项目可能就要重启,有时候 sudo !!的时候 会让再输入密码,但是这种情况下,不少时候 都是在中文模式下。于是就想着是不是可以偷懒,直接用指纹,多方便~~~
网上找了些资料,大多数都是说修改一下 /etc/pam.d/sudo 文件,在 auth sufficint 前加一个 pam_tid.so 即可,于是直接 sudo vim 这个文件,加入了:auth sufficient pam_tid.so
保存的时候 会提示你这是一个 readyOnly 的文件,得 :wq! 强制保存。
然后再在终端运行 sudo ,就会弹出指纹确认框啦 。当然如果你这时候 点取消,则还是需要输入密码,其实只是按顺序一个个验证罢了。
参考:
1、https://zhuanlan.zhihu.com/p/31529925
2、https://www.imore.com/how-use-sudo-your-mac-touch-id
3、https://apple.stackexchange.com/questions/411497/pam-tid-so-asks-for-password-instead-of-requesting-for-fingerprint-when-docked
苹果M1笔记本如何安装 Python2

苹果M1笔记本如何安装 Python2

为什么需要 python2,还不是因为 node_sass 需要用到它。没有它,npm installF 得了无法执行而直接报错。但苹果从 M1开始就不再默认带上 Python2,而是默认3.x(好象是3.9)。

那怎么办呢?
先安装个 pyenv,再用 pyenv 安装2.7
1、brew install pyenv
2、arch -x86_64 pyenv install 2.7.18
3、把路径加入到配置文件:export PATH="$(pyenv root)/shims:${PATH}"
Over。如果是非 M1的话,直接 pyenv install 2.7.18即可
Tunnel error on MacOS when installed as service

Tunnel error on MacOS when installed as service

其实我一直在想,这个功能什么时候会被关掉。

开始:
用cloudflare tunnel的时候,从没想过会在macos上出问题,如果你直接cloudflared service install,不会运行,即使你sudo了也不会,因为这个运行的只是cloudflared,并不带任何参数。
需要在相应的plist下面加上<string>tunnel</string><string>run</string>才OK。
加之前需要先unload,然后再load。否则无效。
其他都与官方一致。
---
如果用sudo了。需要将~/.cloudflared/下的内容copy到/etc/cloudflared下面。如果不放心或者担心没权限,可以修改uuid.json,将路径改为/etc/cloudflared/。其他照旧
记得配合一下valet,因为valet tld之后,子域名的映射会比较方便。
而且valet也支持multi php version。
---EOF
git fetch --unshadow出现RPC failed

git fetch --unshadow出现RPC failed

远程操作家里的mac mini进行更新的时候,突然报错:

mini:Homebrew mini$ brew update
Warning: No available formula with the name "ca-certificates".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get its complete history, run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
Error:
homebrew-core is a shallow clone.
To `brew update`, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
于是执行 git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow ,然而执行下来还是:
error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out
fatal: the remote end hung up unexpectedly
然后我就用打开git trace进行查看:
GIT_TRACE=2 git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
10:29:28.798061 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/bin/git
10:29:28.798668 exec-cmd.c:236 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/bin
10:29:28.799328 git.c:418 trace: built-in: git fetch --unshallow
10:29:28.801482 run-command.c:643 trace: run_command: GIT_DIR=.git git-remote-https origin https://mirrors.ustc.edu.cn/homebrew-core.git
10:29:28.812513 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-remote-https
10:29:28.813122 exec-cmd.c:236 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
10:29:28.929816 run-command.c:643 trace: run_command: git fetch-pack --stateless-rpc --stdin --lock-pack --include-tag --thin --depth=2147483647 https://mirrors.ustc.edu.cn/homebrew-core.git/
10:29:28.935164 exec-cmd.c:139 trace: resolved executable path from Darwin stack: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git
10:29:28.935863 exec-cmd.c:236 trace: resolved executable dir: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
10:29:28.936585 git.c:418 trace: built-in: git fetch-pack --stateless-rpc --stdin --lock-pack --include-tag --thin --depth=2147483647 https://mirrors.ustc.edu.cn/homebrew-core.git/
error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out
fatal: the remote end hung up unexpectedly
这个。。--depth=2147483647,居然这么深?
查到了网上的方案,参考在这里:记录: homebrew-core is a shallow clone - 腾讯云开发者社区-腾讯云 (tencent.com),我按上面的操作,删除了homebrew-core,homebrew-cask,再进行upgrade,果然 正常了。
---
在非正常之前,做了不少操作,比如用官方的uninstall脚本清除了系统,然而也没有什么用。所幸,现在正常了。
mac下使用podman的代理大坑

mac下使用podman的代理大坑

关于这podman啊,一天天的,都在说要替换docker,然后也是大家各种说怎么弄怎么弄,教你安装podman之后,alias docker="podman" ,然后pip3 install podman-compose,再alias一条 alias docker-compose="podman-compose",说的这样好象就差不多了

确实,正常情况下,或者在linux\wsl的情况下,应该是差不多的,虽然部分命令不一样,但看一看参数,基本上也就过了。。。
mac下确实有一个大坑。因为mac其实是不支持container这玩意的。所以不管是docker也好,谁也好,都得装虚拟机。。。
早期podman的教程大多是让你安装一个ubuntu出的multipass,然后再各种连接,用podman连接远程(就是multipass出来的ubuntu虚拟机中安装一个podman)。。。手续也烦,教程也复杂。所以官方升级后出了一个简化版本:podman machine init/podman machine start。然后就可以各种操作了,确实方便很多。
然而问题也正是发生在这里。
> 且看我一步步操作
* brew update && brew install podman
* 正常更新,但由于有部分文件在raw.githubusercontent.com上,遇到这个,代表你只能用代理 了。于是ctrl+c
* export http_proxy=127.0.0.1:1087;export https_proxy=127.0.0.1:1087;export all_proxy=127.0.0.1:1080
* 再次执行:brew update&& brew install podman
*顺利执行完
* podman machine init && podman machine start
* 没问题,但这里要吐槽一下,安装的是fedora。。。好吧,我忍了。我纠结的是,为什么不能选择宿主操作系统?
* podman pull mysql
* 问题就出来这里,拉包的时候,报错
```
podman create --name=pl-and-si-mysql-db --label io.podman.compose.config-hash=123 --label io.podman.compose.project=pipeline_combined_db --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=pipeline_combined_db --label com.docker.compose.project.working_dir=/Users/gouki/Desktop/SC-REDBACK-main/database/pipeline_combined_db --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=pl-and-si-db -e MYSQL_DATABASE=database -e MYSQL_ROOT_PASSWORD=password -v pipeline_combined_db_pl_and_si_database_folder:/var/lib/mysql -v /Users/gouki/Desktop/SC-REDBACK-main/database/pipeline_combined_db/allInOne.sql:/docker-entrypoint-initdb.d/1.sql --net pipeline_combined_db_default --network-alias pl-and-si-db -p 3306:3306 --restart always --cpus 0.4 -m 350m mysql:latest
Resolving "mysql" using unqualified-search registries (/etc/containers/registries.conf.d/999-podman-machine.conf)
Trying to pull docker.io/library/mysql:latest...
Error: initializing source docker://mysql:latest: pinging container registry registry-1.docker.io: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp 127.0.0.1:1087: connect: connection refused
```
咦,他走了代理 ,但被拒绝?不可能啊,我前面下载软件的时候不是还好好的么,难道是代理错误?于是我新开一个shell窗口,再次执行,仍然是同样的错误,这回就发现问题了,因为新的shell窗口我env|grep -i proxy的时候,返回为空,当前进程没有任何一个proxy参数
找了一堆podman的配置,打印了podman info也没有找到有代理 设置的地方,最后只能问google。搜索了半天,只搜到一个有效贴,还是在官方的[issue](failed to pull image when use system proxy · Issue #14087 · containers/podman (github.com))里
有人这样回复:
```

The proxy is set correctly: proxyconnect tcp: dial tcp 127.0.0.1:7890: connect: connection refused

The problem is that your proxy is listening on 127.0.0.1. Obviously 127.0.0.1 inside the VM is a different address and therefore it cannot connect to the proxy on you actual host.

If you set http_proxy=socks5://host.containers.internal:7890 before you run podman machine init it should work.
Maybe podman should just s/127.0.0.1/host.containers.internal and s/localhost/host.containers.internal automatically when it copies the proxy value from the host.

```
感情是你只要machine init的之前用了代理 ,init完后。针对vm的参数就变了。于是下面就有人说,你可以这样:
```

I just test it and I think you are right, but I don't know why http_proxy=socks5://host.containers.internal:7890 podman machine init this command still hit the same error but it works as expected when I add 127.0.0.1 host.containers.internal to my host file

however it works now

add item blow to host file

127.0.0.1 host.containers.internal

and change proxy to

http_proxy=socks5://host.containers.internal:7890

then everything works fine

much thanks @Luap99 for your help and I close this issues for the problem is solved, but I still stay concerned if some day podman can do this itself and no need to change proxy setting

```

呵呵,这么麻烦?我还是新建一个shell窗口:podman machine stop && podman machine init && podman machine start吧。

然后,podman pull mysql,一切正常~

至此搞定。

> 假装内容支持markdown,因为新模板在寻找中,现在的html所见所得,估计会全部改成markdown,先尝试一下。