恶心的python2.7

莫名,某日突然发现python -V的版本变成2.7了,于是给python3做了个软连接,放到$PATH之前的路径下,相关命令如下:

  • 先查看当前python(2.7)的位置
1
whereis python

  • 找到python3的位置
1
2
find / -name python
/usr/local/Cellar/python (brew install 都在Cellar里)
  • 查看环境变量
1
echo $PATH
  • 找到比python2.7更靠前的路径,做软连接
1
ln -s /usr/local/Cellar/python/3.6.2/bin/python3.6 python
  • pip重复上面步骤

docker+flask+mysql

阮一峰docker

阮一峰docker-compose

  1. 每个container相当于一个虚拟机,有自己的ip地址

  2. Dockerfile

1
2
3
4
5
6
7
FROM python:3
EXPOSE 5001
WORKDIR /what
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . /what
CMD ["python", "main.py"]
  1. docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
version: '3'
services:
db:
image: mysql:5
container_name: mydb
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=mingtest
ports:
- "3307:3306"
volumes:
- ~/Data/mysql:/var/lib/mysql
web:
build: .
container_name: myweb
ports:
- "5001:5001"
links:
- db
  1. requirements.txt
1
2
3
Flask
pymysql
flask-restful
  1. main.py
1
2
3
4
5
6
7
8
9
10
11
from flask import Flask
from flask_restful import Api, Resource
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}

api.add_resource(HelloWorld, '/')
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5001, debug=True)
  1. docker-compose ps
1
2
3
Name        Command      State                Ports          
mydb docker-entrypoint.sh mysqld Up 0.0.0.0:3307->3306/tcp, 33060/tcp
myweb python main.py Up 0.0.0.0:5001->5001/tcp
  1. 连接msql
1
mysql -h127.0.0.1 -P3307 -uroot -proot
  1. shell进正在运行的docker
1
docker container exec -it 43a38e5c1965 bash

curl代理

1
2
3
4
5
6
curl ip.cn
# 当前 IP:xxx.xxx.xxx.xxx 来自:广东省深圳市
# 设置环境变量:
export ALL_PROXY=socks5://192.168.3.3:1080
curl ip.cn
# 当前 IP:xxx.xxx.xxx.xxx 来自:台湾省 Google

MarkDown语法学习

fuck what

fuck what

fuck what

fuck what

nini

  • 彪悍
  • 彪悍了
  • 要加空格
  1. wha
  2. nani
  3. google

1
2
3
4
5
6
7
8
9
private void initPlayer(LessonDetailModel lessonDetailModel) {
initPlayerView();
LogUtils.i(mPlayer.getPlayerState() + ", pos=" + mPlayer.getCurrentPosition());
if (mPlayer.isPlaying()) {
mPlayer.setDisplay(mSurfaceView.getHolder());
} else {
requestVideoInfo(lessonDetailModel.getAudioList().get(0).getId());
}
}