Mac 配置工具
Table of Contents
1. 工具
- 鼠标配置工具: Scroll Reverser
2. 快捷键配置
App Settings => Keyboard
- Move focus to the next window: command + tab
App Settings => Keyboard => Shortcuts => App Shortcuts => Click “+”
Terminal:
- Show Previous Tab: command + ↑
- Show Next Tab: commabd + ↓
Google Chrome:
- Select Previous Tab: command + ↑
- Select Next Tab: command + ↓
3. Terminal
- Theme: Pro
- Font: Courier
- Text color: #00FDFF
3. 其它
查看 Python 包安装路径,替换 speech_recognition 为实际包
python -c "import speech_recognition as sr, os.path as p; print(p.dirname(sr.__file__))"
Python 查看
class A(object):
print("A")
class B(A):
print("B")
class C(object):
print("C")
class D(B, C):
def __init__(self, age):
self.age = age
CITY = "bj"
def func(self):
pass
print("D")
# 可以查看类 D 及其父类的方法解析顺序
print(D.__mro__, "\n")
# (<class '__main__.D'>, <class '__main__.B'>, <class '__main__.A'>, <class '__main__.C'>, <class 'object'>)
# 类的所有属性
print("All class attr")
print(D.__dict__, "\n")
# {'__module__': '__main__', '__init__': <function D.__init__ at 0x7f06409a10e0>, 'CITY': 'bj', 'func': <function D.func at 0x7f06409a1170>, '__doc__': None}
obj = D(1)
# 查看对象属性
print("All obj attr:")
print(obj.__dict__)
# {'age': 1}
临时更换 brew 源
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
临时更换 Python 源
pip install -i package_name https://pypi.tuna.tsinghua.edu.cn/simple
设置 terminal 使用代理
$ export http_proxy=http://127.0.0.1:8080
$ export https_proxy=http://127.0.0.1:8081
$ curl cip.cc
查看进程号 (和 Linux 一样)
$ ps -ef|grep 进程名
使用进程号查看进程监听的端口
sudo lsof -nP -p PORT|grep LISTEN
有端口号查看被哪个进程监听 (和 Linux 一样)
lsof -i :Port