petersonzhao / my_blog Goto Github PK
View Code? Open in Web Editor NEWa blog create by Github Issues
License: GNU General Public License v3.0
a blog create by Github Issues
License: GNU General Public License v3.0
在python中datetime对象通常会直接从系统中获取时区。当系统默认时区不是UTC时区时,通常会造成时区混乱,进而造成时间错误,解决办法有两种,一是修改系统时区(docker),二是在代码层面上保证时区的准确性:
docker中默认时区是UTC时间
import datetime
datetime.datetime.utcnow()
from datetime import datetime
import pytz
datetime.utcfromtimestamp(int(timestamp_begin)).replace(tzinfo=pytz.utc)
import pytz
<datetime obj>.replace(tzinfo=pytz.utc).timestamp()
这个转换并不会修改时间数值,只是修改时区
du -h -d1 /data/blockchain
nload
nmon
入手Oculus quest 2
后发现现有的gfwlist不完整,具体表现在oculus商店无法连接,系统无法更新,应用无法加载,需要将下列域名加入
oculus.com
oculuscdn.com
akamaihd.net
fbthirdpartypixel.com
facebook.com
facebook.net
facebook-hardware.com
fbcdn.net
fbcdn.com
fbsbx.com
fb.me
fb.com
crashlytics.com
source:
Oculus Quest - Starter Guide / Safety Guide / FAQ / Megathread
有很多应用下载之后,每次都是用.sh脚本运行的,并没有快捷图标,无法放到ubuntu系统的收藏夹
首先运行应用,之后在终端中运行
xprop WM_CLASS
此时鼠标变成'+'的形状, 点击应用程序窗口栏。
此时在终端中输出:
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "jetbrains-pycharm"
这两个字符串,随便选一个,之后会用上
sudo vi /usr/share/applications/<你的应用名字>.desktop
文件内容:
[Desktop Entry]
Version=1.0
Type=Application
Name=<你的应用名字>
Icon=/opt/pycharm-2018.3/bin/pycharm.png //注意替换图标的路径
Exec=/opt/pycharm-2018.3/bin/pycharm.sh //替换脚本的路径
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm //这里替换成之前获取的WM_CLASS字符串
pyenv 是 Python 版本管理工具。 pyenv 可以改变全局的 Python 版本,安装多个版本的 Python, 设置目录级别的 Python 版本,还能创建和管理 virtual python environments 。所有的设置都是用户级别的操作,不需要 sudo 命令。
pyenv 主要用来管理 Python 的版本,比如一个项目需要 Python 2.x ,一个项目需要 Python 3.x 。 而 virtualenv 主要用来管理 Python 包的依赖,不同项目需要依赖的包版本不同,则需要使用虚拟环境。
pyenv 通过系统修改环境变量来实现 Python 不同版本的切换。而 virtualenv 通过将 Python 包安装到一个目录来作为Python 包虚拟环境,通过切换目录来实现不同包环境间的切换。
pyenv 的美好之处在于,它并没有使用将不同的 PATH植入不同的shell这种高耦合的工作方式,而是简单地在PATH 的最前面插入了一个垫片路径(shims):~/.pyenv/shims:/usr/local/bin:/usr/bin:/bin。所有对 Python 可执行文件的查找都会首先被这个 shims 路径截获,从而使后方的系统路径失效。
pyenv的安装方式包括多种,重点推荐采用pyenv-installer的方式,原因主要有两点:
通过如下命令安装pyenv全家桶。
$ curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
内容除了包含pyenv以外,还包含如下插件:
安装完成后,pyenv命令还没有加进系统的环境变量,需要将如下内容加到~/.zshrc
中
export PATH=$HOME/.pyenv/bin:$PATH
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
然后执行
source ~/.zshrc
完成以上操作后,pyenv就安装完成了。
$ pyenv -v
pyenv 1.0.8
如果不确定pyenv的环境是否安装正常,可以通过pyenv doctor
命令对环境进行检测。
$ pyenv doctor
Cloning /Users/Leo/.pyenv/plugins/pyenv-doctor/bin/.....
Installing python-pyenv-doctor...
BUILD FAILED (OS X 10.12.3 using python-build 20160602)
Last 10 log lines:
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
configure: error: OpenSSL development header is not installed.
make: *** No targets specified and no makefile found. Stop.
Problem(s) detected while checking system.
通过检测,可以发现本地环境可能存在的问题,例如,从以上输出可以看出,本地的OpenSSL development header还没有安装。根据提示的问题,逐一进行修复,直到检测不再出现问题为止。
安装OpenSSL的方法如下:
如果使用
brew link openssl --force
出现如下错误:Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
首先尝试
$ brew doctor (now fix anything that it tells you to fix)
$ brew update
$ brew upgrade
安装 ```bash $ brew install openssl
And now we'll link it into our public area so you don't have to figure out the magic environment variable to set while building your favorite OpenSSL-backed library:
$ cd /usr/local/include
$ ln -s ../opt/openssl/include/openssl .
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev
通过pyenv update
命令,可以更新pyenv全家桶的所有内容。
pyenv的主要功能如下:
$ pyenv -h
Usage: pyenv <command> [<args>]
Some useful pyenv commands are:
commands List all available pyenv commands
local Set or show the local application-specific Python version
global Set or show the global Python version
shell Set or show the shell-specific Python version
install Install a Python version using python-build
uninstall Uninstall a specific Python version
rehash Rehash pyenv shims (run this after installing executables)
version Show the current Python version and its origin
versions List all Python versions available to pyenv
which Display the full path to an executable
whence List all Python versions that contain the given executable
See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/yyuu/pyenv#readme
$ pyenv install --list
需要注意的是,如果是采用brew命令安装的pyenv,可能会发现Python版本库中没有最新的Python版本。所以建议还是通过GitHub源码方式安装pyenv。
$ pyenv install 3.6.0
Downloading Python-3.6.0.tar.xz...
-> https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
Installing Python-3.6.0...
Installed Python-3.6.0 to /Users/Leo/.pyenv/versions/3.6.0
经过以上操作,我们在本地计算机中就可以安装多个版本的Python运行环境,并可以按照实际需求进行灵活地切换。然而,很多时候在同一个Python版本下,我们仍然希望能根据项目进行环境分离,就跟之前我们使用virtualenv一样。
在pyenv中,也包含这么一个插件,pyenv-virtualenv,可以实现同样的功能。
$ pyenv virtualenv PYTHON_VERSION PROJECT_NAME
PYTHON_VERSION 是具体的Python版本号,例如,3.6.0
PROJECT_NAME 是我们自定义的项目名称。
比较好的实践方式是,在PROJECT_NAME也带上Python的版本号,以便于识别。
现假设我们有XDiff这么一个项目,想针对Python 2.7.13和Python 3.6.0分别创建一个虚拟环境,那就可以依次执行如下命令。
$ pyenv virtualenv 3.6.0 py36_XDiff
$ pyenv virtualenv 2.7.13 py27_XDiff
创建完成后,通过执行pyenv virtualenvs
命令,就可以看到本地所有的项目环境。
通过这种方式,在同一个Python版本下我们也可以创建多个虚拟环境,然后在各个虚拟环境中分别维护依赖库环境。
例如,py36_XDiff虚拟环境位于/Users/Leo/.pyenv/versions/3.6.0/envs目录下,而其依赖库位于/Users/Leo/.pyenv/versions/3.6.0/lib/python3.6/site-packages中。
$ pyenv uninstall PROJECT_NAME
pyenv可以从三个维度来管理Python环境,简称为:
这三个维度的优先级从上到下依次升高,即当前系统的优先级最低、当前shell的优先级最高。
可以采用pyenv global PYTHON_VERSION
命令。
该命令执行后会在$(pyenv root)目录(默认为~/.pyenv)中创建一个名为version的文件(如果该文件已存在,则修改该文件的内容),里面记录着系统全局的Python版本号。
通过pyenv local PYTHON_VERSION
命令来修改当前目录的Python环境。
命令执行后,会在当前目录中生成一个.python-version文件(如果该文件已存在,则修改该文件的内容),里面记录着当前目录使用的Python版本号。
可以看出,当前目录中的.python-version配置优先于系统全局的~/.pyenv/version配置。
通过执行pyenv shell PYTHON_VERSION
命令,可以修改当前shell的Python环境。
执行该命令后,会在当前shell session(Terminal窗口)中创建一个名为PYENV_VERSION的环境变量,然后在当前shell的任意目录中都会采用该环境变量设定的Python版本。此时,当前系统和当前目录中设定的Python版本均会被忽略。
顾名思义,当前shell的Python环境仅在当前shell中生效,重新打开一个新的shell后,该环境也就失效了。如果想在当前shell中取消shell级别的Python环境,采用unset
命令重置PYENV_VERSION环境变量即可。
$ pyenv versions
MySQL 8.0采用了与5.7完全不同的验证方式,老版的Navicat无法通过用户验证
create user 'peter'@'%' IDENTIFIED WITH mysql_native_password BY 'peter';
'%'可以替换为'localhost',以限定用户只能在本地登录
GRANT ALL PRIVILEGES ON *.* TO 'peter'@'%' WITH GRANT OPTION;
Important
WITH GRANT OPTION
创建的用户权限与root相同,他可以管理其他用户的权限,因此通常只限在内网使用
bitmex.com
pythonhosted.org
ubuntu.com
huobipro.com
okex.com
readthedocs.io
docker.com
gitbooks.io
slack.com
instagram.com
cdninstagram.com
gitlab.com
mobi.me
btcc.com
bitcoin.org
pixiv.net
eosmonitor.io
jpn.com
hyperapp.fun
slack-edge.com
facebook.net
spiceworks.com
quantserve.com
bizographics.com
cloudfront.net
0daydown.com
slack-msgs.com
hbg.com
gstatic.com
googleusercontent.com
macbook$ sudo killall -HUP mDNSResponder && sudo killall mDNSResponderHelper && sudo dscacheutil -flushcache
macbook$ sudo killall -HUP mDNSResponder
macbook$ sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
macbook$ sudo discoveryutil udnsflushcaches
macbook$ dscacheutil -flushcache && sudo killall -HUP mDNSResponder
macbook$ sudo killall -HUP mDNSResponder
macbook$ dscacheutil -flushcache
macbook$ lookupd -flushcache
[local]$ sudo service nscd restart
[local]$ /etc/rc.d/init.d/nscd stop
[local]$ /etc/rc.d/init.d/nscd start
cd ./.git/config
源文件
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = ssh://[email protected]:20022/Ceres/blockchain-proxy.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
修改后
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = ssh://[email protected]:20022/Ceres/blockchain-proxy.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = [email protected]:ceres-mirror/blockchain-proxy.git
pushurl = ssh://[email protected]:20022/Ceres/blockchain-proxy.git
[branch "master"]
remote = origin
merge = refs/heads/master
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.