This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Gmail { | |
| private $mail; | |
| private $email; | |
| private $pass; | |
| public function __construct($email, $pass){ | |
| $this->email = $email; | |
| $this->pass = $pass; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 计算两个坐标之间的距离(米) | |
| * @param float $fP1Lat 起点(纬度) | |
| * @param float $fP1Lon 起点(经度) | |
| * @param float $fP2Lat 终点(纬度) | |
| * @param float $fP2Lon 终点(经度) | |
| * @return int | |
| */ | |
| function distanceBetween($fP1Lat, $fP1Lon, $fP2Lat, $fP2Lon){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (var i = array.length - 1; i >= 0; i--) { | |
| if (array[i].status == 1) { | |
| array.splice(i, 1); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Geohash:将一个经纬度信息,转换成一个可以排序,可以比较的字符串编码 | |
| * ref http://blog.jobbole.com/80633/ | |
| * | |
| * 找一个点附近的所有人 步骤:先将当前经纬度编码,然后根据需要的精度选择编码长度(eg:长度为8位精度like '12345678%'在19米左右) | |
| * 找出附近的八个和当前格子前缀相同的记录,如果需要排序则需要计算每个点到当前点的距离然后排序 | |
| * | |
| * $hashcode = $hash->encode($lat, $long); | |
| * //十公里范围的hash长度为5位 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 读取文件前几个字节 判断文件类型 | |
| * | |
| * @return String | |
| */ | |
| function checkTitle($filename) { | |
| $file = fopen($filename, "rb"); | |
| $bin = fread($file, 2); //只读2字节 | |
| fclose($file); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function uuid() { | |
| var s = []; | |
| var hexDigits = "0123456789abcdef"; | |
| for (var i = 0; i < 36; i++) { | |
| s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); | |
| } | |
| s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 | |
| s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 | |
| s[8] = s[13] = s[18] = s[23] = "-"; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //生成唯一数字id | |
| base_convert(uniqid('', true), 16, 10); | |
| ?> |