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语句,只有执行到这里的时候里面的函数才会被解析,

 

哈哈,一个不错得坑

原来png图片比jpg要大很多倍

今天准备把网站图片缩略图全部改成png的,本来以为png图片会小很多。结果转换完以后傻眼了。原来2.1GB的图片,转换后变2.5GB了,整整多了400MB。这次算是失败了,重新转回来吧

使用linux find命令:

find . -name original.jpg   |awk '{b= $1; sub(".jpg",".png") ;print "convert " b " -resize 3000x220 " $1}'  | bash

png图片格式的特点如下:

公认的最适合网页使用的图片格式,优点是能像gif一样透明还能像jpg一样保留更多的颜色,并且效果要比jpg好,而且它可以渐变透明,不像gif要透明就100%透了,这种格式的缺点是透明不兼容ie浏览器,不过有方法弥补,另外一点是体积稍微有点大。

所以,以后除非是涉及logo相关的图片,上传的图片还是jpg的比较省空间!

分屏后台运行神器tmux

使用screen命令有个问题就是当打开的窗口多的时候会出现screen进程占用cpu资源过多,分屏的环境没法保存的问题。当分屏之后再进入当前会话,分屏会分成几个窗口使用命令切换,无法在一个屏幕展示。

有了tmux就不会有这个问题了。tmux命令键和screen基本一致。screen是用ctrl+a前置键。tmux使用 ctrl+b前置命令键。

使用方法:

tmux #进入tmux环境
tmux ls #显示已经打开的tmux列表

ctrl+b: 命令前置键与下面命令配合
d : 离开当前会话,回到普通终端模式,还能再回来哟
n : 切换到下一个窗口,多窗口模式
c : 新建一个窗口
p : 切换到上一个窗口
" :垂直分屏这个很好玩
% :水平分屏
o : 小窗口间切换
方向键: 小窗口按方向键切换
x :关闭当前小窗口
!:关闭所有小窗口
w :选择当前打开的窗口列表可以通过上下键切换

最后我要说用了tmux,screen就弱爆了 。tmux占用的资源特别少。很稳定还,分屏效果更是爽歪歪

玩的开心;