自定义首页图片为bing每日美图

将workpress 自定义为bing搜索的背景图片的方法,我这里改的是twentyseventeen theme。 将站点下的wp-content/themes/twentyseventeen/inc/custom-header.php中 twentyseventeen_custom_header_setup函数修改为如下函数: function twentyseventeen_custom_header_setup() { //bing api $url = ‘http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=’; $resolution = ‘1920×1080’; // language options $locale = array( “zh-CN”, “en-US”, “ja-JP”, “en-AU”, “en-UK”, “de-DE”, “en-NZ” ); // parameters foreach ($locale as $lang) { $URL = $url.$lang; //print_r($URL); $data = file_get_contents($URL); if( $data === FALSE){ continue; } $json = json_decode(trim($data), true); if… Continue reading 自定义首页图片为bing每日美图

Published
Categorized as web

工具使用shadowsocks代理接口

一般使用代理的时候,一个是为了资料,另一个是为了下载。 用的系统是osx,经常会使用brew安装软件。但是很多软件的源或者它们的依赖库是被墙了。配置代理后,就方便了,不用到处去找替代源 brew 下载软件是基于curl,vim的管理软件Vim Bundle下载是基于wget的。 curl cat ~/.curlrc socks5=127.0.0.1:1080 polipo #Via ~/.polipoc file: logSyslog = true logFile = ~/log/polipo/polipo.log socksParentProxy = “127.0.0.1:1080” socksProxyType = socks5 proxyAddress = “127.0.0.1” proxyPort = 8123 shadowsocks使用的是socket代理,可以使用polipo转化为http代理,方便一些没有办法直接配置socket代理的工具:wget wget Via ~/.wgetrc file: use_proxy=yes http_proxy=127.0.0.1:8123 https_proxy=127.0.0.1:8123 git #git use http proxy git config –global https.proxy http://127.0.0.1:1080 #git use https proxy git config… Continue reading 工具使用shadowsocks代理接口

Published
Categorized as tool, vps

如何搭梯子

这里介绍一下搭梯子用到的网站 centos7一监安装脚本:来自老高博客 这个脚本配置了自动启动和自动重启。 yum update -y yum install -y python-setuptools net-tools easy_install pip pip install –upgrade pip shadowsocks cat>/etc/systemd/system/shadowsocks-server.service<<EOF [Unit] Description=Shadowsocks Server After=network.target [Service] ExecStart=/usr/bin/ssserver -c /etc/ss-config.json Restart=always [Install] WantedBy=multi-user.target EOF num=$((30000 + RANDOM)) pass=`date +%s | sha256sum | base64 | head -c 12` cat>/etc/ss-config.json<<EOF { “server_port”:$num, “password”:”$pass”, “timeout”:60, “method”:”rc4-md5″ } EOF systemctl daemon-reload systemctl… Continue reading 如何搭梯子

Published
Categorized as tool, vps

vps测试

最方便,便宜是搬瓦工(bandwagonhost),就是速度不快,有时候连不上稳定性不够。平常查资料,用谷歌也还可以的。 采用的方案是:搬瓦工 洛杉矶机房 openvz  年付费19.9vps ,Shadowsocks server +kcptun 最近推出了kvm cn2的线路,买了一个测试了一下:Shadowsocks server +bbr 测试了一下感觉。也是和上面的速度差不多(同样是洛杉矶机房)。没有感觉到网上别人测试得到的成倍提升。可能分配vps的时候运气比较差。   宇宙最快:Google云平台建的虚拟机。 开启了bbr+shadowsocks速度是搬瓦工的十倍。机房选择的是asia-east1-a,网上说这是台湾机房。 客户端测试延迟是25ms,上YouTube: 就是Google收费太贵了,费用由vm和流量两部分构成: vm采用的按时收费,我选的最低配置:1共享vcpu +0.6GB内存+标准永久10GB磁盘:有效的每小时费率为 $0.007(每月 730 小时) 网络流量计费:有效的每小时费率为 $0.023。(google 产品流量不计费,例如:上youtube的流量不计费) 还好Google提供开户绑定信用卡免费试用一年,现在我就在用。

Published
Categorized as vps

go函数返回数组

Defining a function that returns a slice of variable size in golang First of all, slices are already of “variable size”: [100]int and […]int are array type definitions. []int is the correct syntax for a slice, and you could implement the function as: func BuildSlice(size int) []int { return make([]int, size) } The built-in function… Continue reading go函数返回数组