0%

原文:solifugus——国内能用的靠谱DNS整理

今天上网发现很多网站上不去,还以为网线有问题,但V2EX能上的去,上去看到有人提到114DNS的合作计划,回复有人说114没节操,劫持过一些网站,猛然想到自己用的就是114的DNS,于是就把自己的DNS改成了Google的,马上没问题了,但是Ping了一下,延迟虽然还可以,但有掉包,于是开始了找国内可用的高速的DNS的过程,把找到的能用的记录下,以备以后用,今天的问题就是114临时抽风,一直无法ping通。

0、OpenerDNS:42.120.21.30

14.2.8更新,由@L_Meteor推荐:该DNS是国内服务器,延迟在30ms左右,不掉包,速度非常好,该官方称使用该DNS能够无压力访问Facebook、Twitter、Google等服务,不过要使用https:// 加密链接,我试了一下,Google没有问题,Youtube也可以访问,而且速度很靠谱,Facebook和Twitter无法访问,但也非常值得使用了。经@CyconIn 提醒,使用这个只能对‘Google被过滤和用谷歌其他产品很慢’很有用,能够访问Youtube,但并不能播放Youtube的视频,因为Youtube的视频是使用http传输的。

Read more »

ghs 是 google hosted 的缩写,即谷歌主机托管。运行在 GAE 的网站通过 google apps (谷歌企业套件)绑定自己的域名后,谷歌会要求用户在 DNS 解析服务商处设置,将绑定的域名添加值为 ghs.google.com 或 ghs.googlehosted.com 的 CNAME 记录,这样自己的域名就指向了 google 的托管主机。

国内的 DNS 服务器解析这两个域名的 ip 多为 74.125.128.121,这样当该 ip 被墙后几乎所有在国内托管于谷歌的 GAE 网站就会无法访问。我们可以找到可用的 ghs ip,将域名添加这些值的 A 记录就可以恢复网站的访问。提供一个不完整的 ghs ip 列表,备查。

Read more »

在安装根证书的时候,有时会遇到安装上的种种问题,比如在点击完成的时候就无响应了。

根证书无响应

解决过程

打开“服务”,找到里面的 HDZB Comm Service For V2.0 这个服务,有的是V3.0。开启它,然后再安装根证书,重启浏览器就OK了。

这是建设银行网银客户端安装时添加的服务。

goagent 启动DNS proxy时,弹出错误

1
2
3
4
5
6
7
GoAgent Starting...ERROR - [May 21 17:44:25] GoAgent DNSServer requires dnslib and gevent 1.0  
Traceback (most recent call last):
File "/Applications/goagent/local/proxy.py", line 3073, in main
from dnsproxy import DNSServer
File "/Applications/goagent/local/dnsproxy.py", line 12, in <module>
import gevent
ImportError: No module named gevent
Read more »

CentOS自带gcc是v4.4.6,在编译TokuDB时要求gcc >= 4.7

  1. 下载源码包(v4.8的编译方法也是一样的步骤)

    1
    wget http://ftp.gnu.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.bz2
  2. 解压

    1
    tar -jxvf gcc-4.9.0.tar.bz2
Read more »

升级cmake时,提示“Error when bootstrapping CMake:Problem while running initial CMake”,第二次运行./bootstrap时,直接的给出了错误原因:

1
2
3
4
5
6
7
8
[root@localhost cmake-2.8.12.2]# ./bootstrap
---------------------------------------------
gmake: “cmake”是最新的。
/home/src/cmake-2.8.12.2/Bootstrap.cmk/cmake: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/src/cmake-2.8.12.2/Bootstrap.cmk/cmake)
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------

缺少GLIBCXX_3.4.15版本,或是更高的版本。

Read more »

一个python脚本执行报错,老版本python中MIMEText 写法不对

1
2
3
4
5
6
7
8
[root@localhost:~]# /usr/bin/python check_linux_resource.py
Traceback (most recent call last):
File "/usr/local/mysqlmtop/global_functions.py", line 11, in ?
from email.mime.text import MIMEText
ImportError: No module named mime.text

[root@localhost:~]# /usr/bin/python -V
Python 2.4.3
1
2
from email.mime.text import MIMEText
from email.header import Header

将以上写法修改为下面这样就ok

1
2
from email.MIMEText import MIMEText
from email.Header import Header

转自http://www.elias.cn/Python/GetPythonPath?from=Develop.GetPythonPath

##1. 以前的方法

如果是要获得程序运行的当前目录所在位置,那么可以使用os模块的os.getcwd()函数。

如果是要获得当前执行的脚本的所在目录位置,那么需要使用sys模块的sys.path[0]变量或者sys.argv[0]来获得。实际上sys.path是Python会去寻找模块的搜索路径列表,sys.path[0]和sys.argv[0]是一回事因为Python会自动把sys.argv[0]加入sys.path。

具体来说,如果你在C:\test目录下执行python getpath\getpath.py,那么os.getcwd()会输出”C:\test”,sys.path[0]会输出”C:\test\getpath”。

更特别地,如果你用py2exe模块把Python脚本编译为可执行文件,那么sys.path[0]的输出还会变化:

  1. 如果把依赖库用默认的方式打包为zip文件,那么sys.path[0]会输出”C:\test\getpath\libarary.zip”;
  2. 如果在setup.py里面指定zipfile=None参数,依赖库就会被打包到exe文件里面,那么sys.path[0]会输出”C:\test\getpath\getpath.exe”。
Read more »

一般情况而言需要做字符串到十进制数字的转换可以用 crc32() 函数 …

这个函数的优点是快 … 在我的知识范围内这应该是 php 内置最快的哈希函数 …

缺点是操作系统依赖 … 不同操作系统的 crc32() 函数会产生不一样的值 …

至于把 md5() 的结果转化成十进制 … 用 hexdec() 显然是不靠谱的 … 因为hexdec最大只能转0x7fffffff,再大就变成float了。

这里我们用到另外一个更加灵活的进制转换函数 base_convert()

这个函数的好处是返回 string … 也就不存在溢出的问题了 …

Read more »

先来看看怎样取得单个汉字的拼音首字母,请看下面这个函数,它支持GBK和UTF8编码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function getfirstchar($s0){   
$fchar = ord($s0{0});
if($fchar >= ord("A") and $fchar <= ord("z") )return strtoupper($s0{0});
$s1 = iconv("UTF-8","gb2312", $s0);
$s2 = iconv("gb2312","UTF-8", $s1);
if($s2 == $s0){$s = $s1;}else{$s = $s0;}
$asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
if($asc >= -20319 and $asc <= -20284) return "A";
if($asc >= -20283 and $asc <= -19776) return "B";
if($asc >= -19775 and $asc <= -19219) return "C";
if($asc >= -19218 and $asc <= -18711) return "D";
if($asc >= -18710 and $asc <= -18527) return "E";
if($asc >= -18526 and $asc <= -18240) return "F";
if($asc >= -18239 and $asc <= -17923) return "G";
if($asc >= -17922 and $asc <= -17418) return "H";
if($asc >= -17417 and $asc <= -16475) return "J";
if($asc >= -16474 and $asc <= -16213) return "K";
if($asc >= -16212 and $asc <= -15641) return "L";
if($asc >= -15640 and $asc <= -15166) return "M";
if($asc >= -15165 and $asc <= -14923) return "N";
if($asc >= -14922 and $asc <= -14915) return "O";
if($asc >= -14914 and $asc <= -14631) return "P";
if($asc >= -14630 and $asc <= -14150) return "Q";
if($asc >= -14149 and $asc <= -14091) return "R";
if($asc >= -14090 and $asc <= -13319) return "S";
if($asc >= -13318 and $asc <= -12839) return "T";
if($asc >= -12838 and $asc <= -12557) return "W";
if($asc >= -12556 and $asc <= -11848) return "X";
if($asc >= -11847 and $asc <= -11056) return "Y";
if($asc >= -11055 and $asc <= -10247) return "Z";
return null;
}

以上函数返回单个汉字的拼音首字母。

Read more »