This file contains 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 | |
if(!function_exists('generate_random_str')) { | |
function generate_random_str($len = 9, $type=2) { | |
$letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
$numbers = '0123456789'; | |
$special_chars = '!@#$%^&*()-_ []{}<>~`+=,.;:/?|'; | |
$words = ''; | |
switch ($type) { | |
case 1: | |
$words = $letters.$numbers; |
This file contains 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 | |
/** | |
* 计算函数的执行时间,可以用于性能统计 | |
* @param $function | |
* @param array $params | |
* @param int $times | |
* @return mixed | |
*/ |
This file contains 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 | |
/** | |
* 快速获取数据的值 | |
* @param $soure | |
* @param $key | |
* @param string $separetor | |
* @return array|null | |
* @throws Exception | |
*/ | |
function _v($soure, $key, $separetor = '.') { |
This file contains 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
/** | |
* Get free shadowsocks from ishadowsocks. | |
* the server password will change every 6 hours. | |
* ------------------------------------ | |
* @author huzemin8 <[email protected]> | |
*/ | |
var cheerio = require('cheerio'); | |
var fs = require('fs'); | |
var path = require('path'); |
This file contains 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
/** | |
* @author huzemin8 <[email protected]> | |
*/ | |
/** | |
* @param in_size mixed file size | |
* @param type string output size | |
* @param precision int | |
* @return string |
This file contains 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
var net = require('net'); | |
var readline = require('readline'); | |
var HOST = process.env.IP, | |
PORT = process.env.PORT; | |
var me = readline.createInterface(process.stdin, process.stdout); | |
var client = new net.Socket(); | |
client.connect(PORT, HOST, function() { | |
console.log('CONNECTED TO: ' + HOST + ':' + PORT); |
This file contains 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
var os = require('os'); | |
// 获取网卡信息 | |
var networkInterfaces = os.networkInterfaces(); | |
function getHostIp() { | |
// 可能会用多个活动网卡的情况,这样也会出现多个IP | |
var ip = []; | |
for(var key in networkInterfaces) { |
This file contains 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
var http = require('http'); | |
var url = require('url'); | |
var debug = require('debug')('download'); | |
var fs = require('fs'); | |
var path = require('path'); | |
debug('booting %s', "download.js") | |
var url_parms = url.parse("http://img2.chouti.com/CHOUTI_8CEB537A0B9E46BDA7B744ABED8C3812_W163H163=C200x200.jpg"); | |
var options = { | |
protocol: url_parms.protocol, |
This file contains 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 getBoundary(req) { | |
if (req && req.headers) { | |
var content_type = req.headers['content-type'].split(';'); | |
if (content_type.length > 1) { | |
var raw_boundary = content_type.pop().split('='); | |
var boundary = raw_boundary[1]; | |
return boundary; | |
} | |
} | |
else { |
This file contains 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 | |
/** | |
* @author 胡泽民 <[email protected]> | |
*/ | |
// 获取数组中特定键的数据,并进行默认值设置 | |
function filter_array($params, $keys) { | |
if(!is_array($params)) { | |
return null; | |
} |
OlderNewer