type
status
date
slug
summary
tags
category
icon
password
comment_flag
SLUGS
  • 为了体验更好的排版,建议浏览参考链接原文。
  • Toggle list下的内容只是原文的一个备份。
  • 持续更新。

1.安全使用EasyConnect

参考:https://soulike.tech/article?id=64
关于 EasyConnect,懂的都懂,不用多说。本文介绍如何相对安全的在 macOS 上使用 EasyConnect。
EasyConnect 主要有以下行为:
  1. 后台常驻进程 EasyMonitor 和 ECAgentProxy,且都以 root 权限运行;
  1. 自动安装根证书,包括系统根证书与 FireFox 的根证书,且在删除后会重新安装。
以 root 权限常驻进程,意味着这些进程可以读取和写入任何东西;安装根证书,意味着可以直接进行中间人攻击。因此我们需要解决这些问题。
步骤
  1. 使用 sudo su
  1. 删除 /Library/LaunchDaemons/com.sangfor.EasyMonitor.plist
  1. 删除 /Library/LaunchAgents/com.sangfor.ECAgentProxy.plist
  1. 重新启动 Mac
  1. 打开钥匙串,删除系统钥匙串-系统-证书下面的证书(关键词 sangfor)
注意一定要先重启 Mac 再删除证书,因为在后台的 EasyMonitor 进程会在证书被删除后自动导入。
这样就消除了 EasyConnect 的问题。但是,目前为止会导致 EasyConnect 不能连接,因此我们需要用安全的方式启动 EasyConnect。可以编写两个脚本实现启动和退出。
脚本
startEasyConnect
killEasyMonitor
将上述两个脚本放到 PATH 路径下,并给予可执行权限:
在需要使用 EasyConnect 时,使用普通用户身份执行 startEasyConnect 命令(如此,EasyMonitor 进程就没有权限导入根证书了)。在退出 EasyConnect 后,执行 killEasyMonitor 杀掉后台的 EasyMonitor 进程即可。
 

2.MBP不充电盒盖防止睡眠

参考:Use caffeinate to prevent sleep on lid close on battery
It's not ideal, but here's a solution. To prevent the laptop from sleeping when the lid is closed and you're running on battery, run the following commands:
To re-enable laptop sleeping when the lid is closed and you're running on battery, run the following commands:
The "5" in the second set of commands represents the number of minutes before sleeping when on battery; adjust as desired for your laptop.
This is a bit dangerous, since if you forget to re-enable your settings, the laptop will never sleep when on battery. Because of this, I've written a shell script to automatically re-enable the settings:
The shell script will disable sleeping until you hit the Enter key, at which point it will re-enable the sleep settings (alternately, you can hit Ctrl-C and achieve the same thing). It will also set a timeout (defaults to 300 seconds/5 minutes) after which the sleep settings will automatically be re-enabled, and the laptop will be forced to go to sleep. While this would be a pain if you're using your laptop in a meeting, it will be a lifesaver if you forgot and put your laptop in your bag to go home.
Astute readers will note that these commands require sudo; sadly, that's unavoidable AFAIK. What I've done on my system is to make it so that I don't have to enter my password to run pmset as root. To do that, edit the sudoers file (sudo visudo) and add this line:
replacing "joe" with your username. You could probably achieve the same result (i.e. running the script without having to enter your password) by running the shell script SETUID, but I don't like doing that; opening up this one command via sudoers seems less risky to me.
To run the script, stick it in a directory on your PATH and invoke it as such:
When you get to where you're going, simply hit Enter or Ctrl-C and you're good to go. And if you forget about it, it will automatically reset and sleep.
There's probably a way to achieve all of this via AppleScript, so that you can then assign it a hot key and what not; I'll try that if I ever get tired of running this from the command line.
 
 

3.使用VSCode远程调试Linux服务器的可视化输出

参考:Mac使用VSCode远程调试Linux服务器的可视化输出 - 简书 (jianshu.com)
好久不见~ 废话不多说,上教程。
在做 数据分析(数据挖掘 或 机器学习)的时候,我们经常需要绘制一些统计相关的图表,这些统计、绘图的程序常常是跑在服务器上的,可是服务器出于性能和效率的考虑,通常都是没有安装图形化界面的,于是这些统计、绘图的程序在服务器上压根儿就跑不起来,或者无法直接显示出来,这就很尴尬了! Linux 本身是没有图形化界面的,所谓的图形化界面系统只不过中 Linux 下的应用程序。这一点和 Windows 不一样。Windows 从 Windows 95 开始,图形界面就直接在系统内核中实现了,是操作系统不可或缺的一部分。Linux 的图形化界面,底层都是基于 X 协议。
假设我在使用VSCode的remote-ssh,并成功连接上了远程服务器,现在需要在调试代码的时候显示图形化界面。例如Python的opencv或者matplotlib的图形输出。
Mac 现在不提供X11 需要安装Xquartz,在https://www.xquartz.org/下载适合Mac的最新版安装包(其实不是很新了)。
首先,我们编辑服务器端的设置,使其能够X11转发: 编辑/etc/ssh/sshd_config文件中找到如下两个参数,设置为yes10
更改后需要重启服务, Linux运行如下命令重新启动ssh服务。
然后,我们编辑Mac上的配置,编辑/private/etc/ssh/ssh_config文件(可使用vi),设置如下参数为yes
最后,使用安装了remote-ssh插件的VSCode,登录远程服务器,记得要在命令后加-X选项。
notion image
跑一个带有图形输入的代码试试看~
notion image
不过,matplotlib输出的模块,上面的保存按钮,还是只能保存在了服务器中,可以使用ssh配合scp传输到本地。
当然,配好了X11的转发,其实我们可以做很多事情,例如在远程登录后终端里输入任意一个linux的GUI软件的命令:
notion image
参考:
 

4.使NTFS盘支持读写

(deprecated, 似乎在m1pro mbp ventura 13上不起作用)参考:打开Mac OSX原生的NTFS功能 (tianwaihome.com)
很多同学都会为如何在Mac下写入NTFS格式的磁盘而感到困惑,因为默认情况下,把一个NTFS格式的磁盘插入到Mac里,是只能读不能写的。用起来肯定很郁闷,很多同学也因此把移动硬盘分成了双分区,一个NTFS,一个HFS。其实在Mac下完全是可以写NTFS磁盘的
一种十分简单的方法是用第三方工具,Paragon NTFS for MAC。使用这种工具,虽然说是简单了,可是麻烦事也不少,一来是这个工具是要收费的,当然有破解版,不过破解版里有没有被植入什么,那就没有人知道了,二是这个工具本身就不怎么稳定,容易丢数据不说,每次OSX一更新,必须得等软件更新后才能用,总之,用起来不放心啊。
其实呢,大家并不需要困惑,OSX其实原生就支持NTFS,最早在OSX 10.5的时候,是可以直接写入NTFS的盘的,后来由于微软的限制,把这个功能给屏蔽了,我们可以通过命令行手动打开这个选项。
第一步,当然是插上磁盘啦。
可以从finder或者使用以下命令查看到磁盘的Volume Name:
可以看到,我的 Volume Name 是FreeAgent GoFlex Drive。
紧接着更新 /etc/fstab文件
把以下内容写入进去
下面来依次解释一下,其中的\040的意思是代替空格键,因为我的Volume Name是有空格的,所以必须把这个空格给转义了。
后面的Ntfs rw表示把这个分区挂载为可读写的ntfs格式,最后nobrowse非常重要,因为这个代表了在finder里不显示这个分区,这个选项非常重要,如果不打开的话挂载是不会成功的。
编辑好以后重新插入磁盘,就能识别到了,但是这个时候有了一个最大的问题,因为这个分区在finder里不显示了,那么我们要怎么找到它呢,总不能一直用命令行把。
解决办法其实很简单,因为这个分区是挂/Volumes下的,我们把这个目录在桌面做一个快捷方式就行了。
然后我们能在桌面找到
notion image
点开以后就能找到磁盘了
notion image
用这种方法打开的是系统原生的ntfs功能,稳定实用,比第三方工具要好用的多了。
macOS Ventura 写入 NTFS 格式移动硬盘的方法 - 知乎 (zhihu.com)
lezgomatt/ezntfs: An easy-to-use wrapper for NTFS-3G on macOS (github.com)

5.读取Linux ext4的硬盘

 
参考https://github.com/gerard/ext4fuse/issues/74#issuecomment-1374069541,只支持读(为了保证安全性,如果需要读写,可使用虚拟机创建linux,然后将磁盘挂载到Linux)

6.移除Dock栏

[论文简读][ICLR15]FitNets: Hints for Thin Deep NetsGit一些操作备忘
Loading...