python pip使用国内源

国内使用python的时候安装很多组件直接使用是无法下载的,只能翻墙,需要的条件比较高;如果不能翻墙怎么办呢?

仿照以前linux下载映像的思路,python pip也有国内的源;

首先我们看下pip怎么配置使用国内的源:

文档地址:https://pip.pypa.io/en/stable/user_guide/#config-file

windows配置位置在:

%APPDATA%\pip\pip.ini

unix的配置位置在:

$HOME/.config/pip/pip.conf

macOS的在:

$HOME/Library/Application Support/pip/pip.conf

nodejs的npm源用的阿里的源,pip的我们也用阿里的源

配置如下:

[global]
timeout = 60
trusted-host = mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple

配置完后安装组件就很顺畅

pip install scrapy
pip install six
pip install django
pip install requests

树莓派2Raspberry Pi2显示器分辨率设置

刚开始玩树莓派,开始搞了半天没有显示内容,后俩知道了修改 config.txt 配置,将 hdmi_safe=1加上了,有显示了,结果只有640x480的分辨率。

经过苦苦搜索发现了一个配置: hdmi_ignore_edid=0xa5000080 将edid检测干掉就ok了。分辨率终于可以设置。

现在公布下哥的config文件:

# For more options and information see 
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
hdmi_safe=0

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
overscan_left=10
overscan_right=10
overscan_top=10
overscan_bottom=10

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=1024

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=35
hdmi_ignore_edid=0xa5000080 

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

start_x=1

希望能帮到大家。

nodejs npm 加速

国内使用npm安装nodejs 组件会无比的卡顿,经常会失败。还好万能的taobao给我们提供了一个国内能快速访问的镜像。http://npm.taobao.org/

同步组件比较全。速度有保障,再也不用死卡死卡了。

使用方法:

1,使用cnpm组件安装组件

npm install -g cnpm --registry=https://registry.npm.taobao.org

2,修改npm源获取地址

最方便的就是使用第一个方法。

mac svn1.8.10客户端 提交svn代码报错

由于公司的svn服务器版本不兼容最新的svn 1.8.10导致 提交代码报错

svn: E120105: Commit failed (details follow):
svn: E120105: Error running context: The server sent an improper HTTP response

只能降级svn客户端版本到1.7。然后重新checkout代码

 

 

php5.5.17编译报 can't open file: ext/opcache/.libs/opcache.a错误

崩溃了,一天编译了4此,发现到 can't open file: ext/opcache/.libs/opcache.a 这里就挂了,为什么呢?

应该是homebrew的php5.5编译有bug,最后试了下用--disable-opcache去掉opcache模块。安装完成,使用pecl install ZendOpcache-7.0.3

单独安装opcache模块。

成功搞定mac下brew安装php5.5.17

enjoy it!

linux curl命令超时设置

curl post提交数据如果遇到超时未响应的请求会导致cpu一直飙升,最好设置一个超时时间

curl --connect-timeout 10 -m 20

 

connection-timetou :连接时间超时这是10s,

-m/max-time 请求总时间 超时20ms将报错

 

php function_exists函数未定义问题

前几天踩了一个php的坑,在写函数的时候添加了一个function_exists判断函数是否已经定义,

结果爆出了函数未定义的错误,经过分析发现函数定义我放到文件最后面了,将这块代码提到最前面就没问题,

function_exists判断是一个php语句,只有执行到这里的时候里面的函数才会被解析,

 

哈哈,一个不错得坑