代码改变世界

[转] PHP计算两个坐标之间的距离, Calculate the Distance Between Two Points in PHP

2015-01-12 14:34 by 斌哥tobin, 359 阅读, 0 推荐, 收藏, 编辑
摘要:Calculate the Distance Between Two Points in PHPThere are a lot of applications where it is useful to know the distance between two coordinates. Here,... 阅读全文

file_get_contents抓取远程URL内容

2014-09-09 10:27 by 斌哥tobin, 791 阅读, 0 推荐, 收藏, 编辑
摘要:/** * POST URL * @param $url * @param null $post * @return false / string */ public static function UrlPost($url, $post = null,... 阅读全文

Xshell下VI打开文件中文乱码解决

2014-08-21 01:35 by 斌哥tobin, 1177 阅读, 0 推荐, 收藏, 编辑
摘要:修改 /etc/sysconfig/i18n 成如下值:LANG="zh_CN.utf8"LANGUAGE="zh_CN.utf8"SUPPORTED="zh_CN.utf8:zh_CN.GB18030:zh_CN:zh:en_US.UTF8:en_US:en"SYSFONT="lat0-sun16... 阅读全文

YII实现Memcache故障转移的配置办法

2014-07-22 17:28 by 斌哥tobin, 607 阅读, 0 推荐, 收藏, 编辑
摘要:YII在默认配置下连接Memcache失败时会报错,要想实现故障转移就要改一下配置和代码1、首先修改一下YII的 caching/CMemCache.php,我的版本是 1.1.7找到$cache->addServer($server->host,$server->port,$server->per... 阅读全文

Nginx实现多重IF判断的办法

2014-07-22 11:25 by 斌哥tobin, 475 阅读, 0 推荐, 收藏, 编辑
摘要:在YII框架中如果访问的图片不存在,会记录大量的错误,于是我想了个办法,凡是访问不存在的图片,直接返回404,不经过YII框架location / { set $if_img N; if ($request_filename ~ (.*)\.(png|gif|jpg)){ set $if_img ... 阅读全文

CentOS安装NodeJS v0.10.25 + Express

2014-02-15 16:07 by 斌哥tobin, 1517 阅读, 0 推荐, 收藏, 编辑
摘要:安装必需组件yum -y install gcc make gcc-c++ openssl-devel wgetcd ~wget http://nodejs.org/dist/v0.10.25/node-v0.10.25.tar.gztar zxvf ./node-v0.10.25.tar.gzcd node-v0.10.25./configure --prefix=/usr/local/node/v0.10.25报错: fpu = 'vfpv3' if armv7 else 'vfpv2' (如果你的安装环境没有报错,可以略过升级python部分)原因是需要升 阅读全文

一个小玩意 PHP实现微信红包金额拆分试玩

2014-01-29 17:56 by 斌哥tobin, 2248 阅读, 0 推荐, 收藏, 编辑
摘要:bonus_num = 10; $this->bonus_money = 200; $this->money_single_max = 60; } private function randomFloat($min = 0, $max = 1) { $mt_rand = mt_rand(); $mt_getrandmax = mt_getrandmax(); echo 'mt_rand=' . $mt_rand . ', mt_getrandmax=' . $mt_getrandmax . ''; ... 阅读全文

Web Service测试利器 Postman

2014-01-24 18:01 by 斌哥tobin, 758 阅读, 0 推荐, 收藏, 编辑
摘要:利器推荐,下载地址https://github.com/a85/POSTMan-Chrome-Extension在chrome的扩展商店中安装失败所以下载zip文件下来再导入到chrome扩展 阅读全文

CentOS安装Git

2014-01-02 18:12 by 斌哥tobin, 567 阅读, 0 推荐, 收藏, 编辑
摘要:准备安装Gityum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel#下载git-1.8.5.2.tar.gz 到 /usr/local/src 下载网址 http://code.google.com/p/git-corecd /root/downloadtar -zvxf git-1.8.5.2.tar.gzcd git-1.8.5.2./configure --prefix=/usr/local/gitmake && make install报错了吧?libgi 阅读全文

PHP导出CSV UTF-8转GBK不乱码的解决办法

2013-12-27 11:45 by 斌哥tobin, 1181 阅读, 0 推荐, 收藏, 编辑
摘要:折腾了几次 搜索了好久 终于找到办法/*** http://yige.org/php/* @ string 需要转换的文字* @ encoding 目标编码**/ function convert_encoding($string, $encoding = 'gbk'){ $is_utf8 = preg_match('%^(?:[\x09\x0A\x0D\x20-\x7E]| [\xC2-\xDF][\x80-\xBF]| \xE0[\xA0-\xBF][\x80-\xBF] | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} | \xED[\x80 阅读全文