原创 Mac zsh及oh my zsh安裝與配置

1. 切換爲zsh環境 切換至zshchsh -s /bin/zsh,並重啓終端 2. 安裝oh my zsh 執行下列命令之一: sh -c "$(curl -fsSL https://raw.github.com/ohmyz

原创 開啓Mac的root賬戶

執行一下命令 sudo passwd root 設置好密碼後就可以使用root賬戶了

原创 werkzeug.Local 對象

在Python中,除了線程還有一些其他的併發方法如協程。所以在一個WSGI服務中,我們不能保證所有的請求都是以線程的形式存在。另外一種情況是當前請求複用了之前請求的線程,所以上一個請求的數據留在了當前請求的Thread Local

原创 Docker ps 指定顯示列

docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Status}}" 參考: https://www.jianshu.com/p/fd962293e128

原创 Flask 性能分析與SQL慢查詢發現機制

Flask 性能分析 使用werkzeug.middleware.profiler.ProfilerMiddleware中間件對Flask的每個請求進行性能分析。其使用python默認的cProfile或profile對請求入口函

原创 Navicat Failed to save password Error code: -25293 不能保存密碼

錯誤還原:mac環境,更換Navicat版本後,忘記初始Navicat的密碼,導致Navicat不能保存密碼 解決方案: 刪除Keychains的所有文件(可用如下命令)。 cd ~/Library/Keychains rm

原创 Github上查找最多star和最多fork的項目

Github使用的是GraphQL,所以可以使用語義化查找,並按Most stars排序 查找對多的start項目: stars:>10000 查找最多的fork項目:forks:>10000

原创 Kubernetes kubectl 指定不同 config 文件訪問不同集羣

kubectl 使用--kubeconfig指定 config 文件地址來訪問不同的集羣,如: kubectl --kubeconfig ~/.kube/config.dev get pods

原创 Istio 報錯503,upstream connect error or disconnect/reset before headers. reset reason: connect

錯誤描述: 每一次在升級微服務時(更新微服務版本),會有一段時間訪問報 503 。並在 istio-proxy 日誌中有記錄:”upstream connect error or disconnect/reset before h

原创 Python 多線程

一. 創建並執行線程 1. threading.Thead直接創建 用Thread(target=函數名)創建線程對象,用start根據線程對象創建線程並執行。 import threading from threading im

原创 Python raise 單獨一行的含義

在Python3中,單獨的raise會重新觸發前一個異常, 如果之前沒有觸發異常, 觸發RuntimeError。 In [1]: try: ...: 1/0 ...: except ZeroDivisionE

原创 Python cProfile或profile報錯 AttributeError: module 'profile' has no attribute 'run'

報錯:AttributeError: module ‘profile’ has no attribute ‘run’ 解決方案:查看是否有名稱爲profile的包或文件,刪除它就可以解決了。

原创 在centos7 下安裝Python3

安裝依賴環境 sudo yum -y groupinstall "Development tools" sudo yum -y install zlib-devel bzip2-devel openssl-devel ncur

原创 Django 常用Meta選項

verbose_name,別名(用於admin) verbose_name_plural,複數別名(用戶admin) abstract,True時類爲抽象基類 proxy,True時爲代理模型(proxy model) orde

原创 Django contenttype

每一個ContentType實例都擁有app_label和model這兩個字段。同時也用着兩個字段唯一描述一個模型 從ContentType實例操作模型 >>> from django.contrib.contenttypes.m