校验为正数则返回该数字，否则抛出异常.
547516
public static Integer positive(@Nullable String role, Integer x) {
		if (x.intValue() <= 0) {
			throw new IllegalArgumentException(role + " (" + x + ") must be > 0");
		}
		return x;
	}
908515
function config(needColor){
    let colorsTool = {};//这里为一个局部变量，为了方便多次初始化，每次执行都返回一个新的对象
    let isProdEnv = process.env.NODE_ENV==="production";
    //参数缺省时，非production环境变量，都需要带上颜色
    needColor = needColor===undefined ? !isProdEnv : !!needColor;

    let f,b,s;
    let len1 = arrF.length;
    let len2 = arrB.length;
    let len3 = arrS.length;
    // colors.red
    for(f=0;f<len1;f++){
        colorsTool[arrF[f]] = needColor ? genFn(arrF[f],null,null) : noop;
        // colors.red.bgYellow
        let i1;
        for(i1=0;i1<len2;i1++){
            let bName = arrB[i1].split("bg")[1];
            bName = bName.substring(0,1).toLowerCase() + bName.substr(1);// 仅首字母转成小写
            colorsTool[arrF[f]][arrB[i1]] = needColor ? genFn(arrF[f],bName,null) : noop;
            // colors.red.bgYellow.bold
            let j1;
            for(j1=0;j1<len3;j1++){
                colorsTool[arrF[f]][arrB[i1]][arrS[j1]] = needColor ? genFn(arrF[f],bName,arrS[j1]) : noop;
            }
        }
        // colors.red.bold
        let k1;
        for(k1=0;k1<len3;k1++){
            colorsTool[arrF[f]][arrS[k1]] = needColor ? genFn(arrF[f],null,arrS[k1]) : noop;
        }
    }
    // colors.bgYellow
    for(b=0;b<len2;b++){
        let bName2 = arrB[b].split("bg")[1].toLowerCase();
        colorsTool[arrB[b]] = needColor ? genFn(null,bName2,null) : noop;
        // colors.bgYellow.bold
        let i2;
        for(i2=0;i2<len3;i2++){
            colorsTool[arrB[b]][arrS[i2]] = needColor ? genFn(null,bName2,arrS[i2]) : noop;
        }
    }
    // colors.bold
    for(s=0;s<len3;s++){
        colorsTool[arrS[s]] = needColor ? genFn(null,null,arrS[s]) : noop;
    }

    // 常规组合：warn error success fail
    colorsTool.warn = function(str){
        if(typeof str !=="string"){ return str; }
        str = str.replace("\r","");
        return colorsTool.red.bgYellow("[warning]") + " " + colorsTool.yellow(str.split("\n").join("\n          "));
    };
    colorsTool.error = function(str){
        if(typeof str !=="string"){ return str; }
        str = str.replace("\r","");
        return colorsTool.red.bgBrightYellow.bold("[error]") + " " + colorsTool.red.bold(str.split("\n").join("\n        "));
    };
    colorsTool.success = function(str){
        if(typeof str !=="string"){ return str; }
        str = str.replace("\r","");
        return colorsTool.green.bold(str);
    };
    colorsTool.fail = function(str){
        if(typeof str !=="string"){ return str; }
        str = str.replace("\r","");
        return colorsTool.gray.bold(str);
    };

    return colorsTool;
}
553346
public void norm_setTotal() {
        String rule;
        Pattern pattern;
        Matcher match;
        String[] tmp_parser;
        String tmp_target;

        /*
         * 修改了函数中所有的匹配规则使之更为严格
         * modified by 曹零
         */
        rule = "(?<!(周|星期))([0-2]?[0-9]):[0-5]?[0-9]:[0-5]?[0-9]";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split(":");
            _tp.tunit[3] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[4] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[5] = Integer.parseInt(tmp_parser[2]);
        } /*
         * 添加了省略秒的:固定形式的时间规则匹配
         * add by 曹零
         */ else {
            rule = "(?<!(周|星期))([0-2]?[0-9]):[0-5]?[0-9]";
            pattern = Pattern.compile(rule);
            match = pattern.matcher(Time_Expression);
            if (match.find()) {
                tmp_parser = new String[2];
                tmp_target = match.group();
                tmp_parser = tmp_target.split(":");
                _tp.tunit[3] = Integer.parseInt(tmp_parser[0]);
                _tp.tunit[4] = Integer.parseInt(tmp_parser[1]);
            }
        }
        /*
         * 增加了:固定形式时间表达式的
         * 中午,午间,下午,午后,晚上,傍晚,晚间,晚,pm,PM
         * 的正确时间计算，规约同上
         * add by 曹零
         */
        rule = "(中午)|(午间)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            if (_tp.tunit[3] >= 0 && _tp.tunit[3] <= 10) {
                _tp.tunit[3] += 12;
            }
        }

        rule = "(下午)|(午后)|(pm)|(PM)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            if (_tp.tunit[3] >= 0 && _tp.tunit[3] <= 11) {
                _tp.tunit[3] += 12;
            }
        }

        rule = "晚";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            if (_tp.tunit[3] >= 1 && _tp.tunit[3] <= 11) {
                _tp.tunit[3] += 12;
            } else if (_tp.tunit[3] == 12) {
                _tp.tunit[3] = 0;
            }
        }


        rule = "[0-9]?[0-9]?[0-9]{2}-((10)|(11)|(12)|([1-9]))-((?<!\\d))([0-3][0-9]|[1-9])";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split("-");
            _tp.tunit[0] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[1] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[2] = Integer.parseInt(tmp_parser[2]);
        }

        rule = "((10)|(11)|(12)|([1-9]))/((?<!\\d))([0-3][0-9]|[1-9])/[0-9]?[0-9]?[0-9]{2}";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split("/");
            _tp.tunit[1] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[2] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[0] = Integer.parseInt(tmp_parser[2]);
        }

        /*
         * 增加了:固定形式时间表达式 年.月.日 的正确识别
         * add by 曹零
         */
        rule = "[0-9]?[0-9]?[0-9]{2}\\.((10)|(11)|(12)|([1-9]))\\.((?<!\\d))([0-3][0-9]|[1-9])";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            tmp_parser = new String[3];
            tmp_target = match.group();
            tmp_parser = tmp_target.split("\\.");
            _tp.tunit[0] = Integer.parseInt(tmp_parser[0]);
            _tp.tunit[1] = Integer.parseInt(tmp_parser[1]);
            _tp.tunit[2] = Integer.parseInt(tmp_parser[2]);
        }
    }
1092223
def cancel(self):
        

        self.cancel_amount = self.amount - self.trade_amount
        if self.trade_amount == 0:
            # 未交易  直接订单全撤
            self._status = ORDER_STATUS.CANCEL_ALL
        else:
            # 部分交易 剩余订单全撤
            self._status = ORDER_STATUS.CANCEL_PART
589896
private function writeCurve() {
        $fontSize = rand(10, 15);
        $py = 0;
        // 曲线前部分
        $A = mt_rand(1, $this->h / 2); // 振幅
        $b = mt_rand(-$this->h / 4, $this->h / 4); // Y轴方向偏移量
        $f = mt_rand(-$this->h / 4, $this->h / 4); // X轴方向偏移量
        $T = mt_rand($this->h, $this->w * 2); // 周期
        $w = (2 * M_PI) / $T;
        $px1 = 0; // 曲线横坐标起始位置
        $px2 = mt_rand($this->w / 2, $this->w * 0.8); // 曲线横坐标结束位置
        for ($px = $px1; $px <= $px2; $px = $px + 1) {
            if (0 != $w) {
                $py = $A * sin($w * $px + $f) + $b + $this->h / 2; // y = Asin(ωx+φ) + b
                $i = (int)($fontSize / 5);
                while ($i > 0) {
                    imagesetpixel($this->im, $px + $i, $py + $i, $this->color); // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出（不用这while循环）性能要好很多
                    $i--;
                }
            }
        }
        // 曲线后部分
        $A = mt_rand(1, $this->h / 2); // 振幅
        $f = mt_rand(-$this->h / 4, $this->h / 4); // X轴方向偏移量
        $T = mt_rand($this->h, $this->w * 2); // 周期
        $w = (2 * M_PI) / $T;
        $b = $py - $A * sin($w * $px + $f) - $this->h / 2;
        $px1 = $px2;
        $px2 = $this->w;
        for ($px = $px1; $px <= $px2; $px = $px + 1) {
            if (0 != $w) {
                $py = $A * sin($w * $px + $f) + $b + $this->h / 2; // y = Asin(ωx+φ) + b
                $i = (int)($fontSize / 5);
                while ($i > 0) {
                    imagesetpixel($this->im, $px + $i, $py + $i, $this->color);
                    $i--;
                }
            }
        }
    }
751627
public function verifyReturn(){
        if(empty($_GET)) {//判断POST来的数组是否为空
            return false;
        }
        else {
            //生成签名结果
            $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
            //获取支付宝远程服务器ATN结果（验证是否是支付宝发来的消息）
            $responseTxt = 'true';
            if (! empty($_GET["notify_id"])) {$responseTxt = $this->getResponse($_GET["notify_id"]);}

            //写日志记录
            //if ($isSign) {
            //	$isSignStr = 'true';
            //}
            //else {
            //	$isSignStr = 'false';
            //}
            //$log_text = "responseTxt=".$responseTxt."\n return_url_log:isSign=".$isSignStr.",";
            //$log_text = $log_text.createLinkString($_GET);
            //logResult($log_text);

            //验证
            //$responsetTxt的结果不是true，与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
            //isSign的结果不是true，与安全校验码、请求时的参数格式（如：带自定义参数等）、编码格式有关
            if (preg_match("/true$/i",$responseTxt) && $isSign) {
                return true;
            } else {
                return false;
            }
        }
    }
617526
function fixOldLinearGradient (args) {
	let angle;
	// 从args[0]中获取起始点信息
	const start = normalizePos(args[0]);
	// 从args[1]中获取终止点信息
	const end = normalizePos(args[1]);

	// 根据起始点和终止点计算角度
	angle = 180 - Math.atan2(end.x - start.x, end.y - start.y) * (180 / Math.PI);
	// 将角度进行坐标系变换
	angle = require("normalize-range").wrap(0, 360, angle);
	// 如果角度不等于180°，将其转换为字符串后返回
	if (angle !== 180) {
		angle = angle2String({
			deg: angle,
		});
		return angle;
	}
}
957834
protected void send(OutputStream out, Charset charset) throws IOException {
        // 报文分为三个部分
        // 报文头
        byte[] head = request.getHeadByte(charset);
        // 交易参数
        byte[] param = request.encodeParam(charset);
        // 交易文件流
        InputStream inputFile = request.getInputFile();
        long fileSize = request.getFileSize();
        LOGGER.debug("发出交易请求..报文头为{}", request.getHead());
        LOGGER.debug("交易参数为{}", param);
        // 输出报文头
        out.write(head);
        // 输出交易参数
        if (null != param) {
            out.write(param);
        }
        // 输出文件流
        if (null != inputFile) {
            sendFileContent(inputFile, fileSize, out);
        }
    }
568632
public function info()
    {
        $html = '<meta charset="UTF-8"/><h2 align="center" style="margin-top: 30px;margin-bottom: 0;">iBrand Laravel Sms</h2>';
        $html .= '<p style="margin-bottom: 30px;font-size: 13px;color: #888;" align="center">' . 1.0 . '</p>';
        $html .= '<p><a href="https://github.com/ibrandcc/laravel-sms" target="_blank">ibrand laravel-sms源码</a>托管在GitHub，欢迎你的使用。如有问题和建议，欢迎提供issue。</p>';
        $html .= '<hr>';
        $html .= '<p>你可以在调试模式(设置config/app.php中的debug为true)下查看到存储在存储器中的验证码短信/语音相关数据:</p>';
        echo $html;
        if (config('app.debug')) {

            $key = md5('ibrand.sms.' . request('mobile'));

            dump(Sms::getStorage()->get($key, ''));
        } else {
            echo '<p align="center" style="color: red;">现在是非调试模式，无法查看调试数据</p>';
        }
    }
1099222
function replace(value) {

  // 漢数字、漢字、全角文字を半角数字に変換
  value = suji(value);

  // 和暦時西暦に変換
  value = value.replace(REG_ERA, (x, g, n, af) => {
    var era = ERA_MAP[g];
    return '' + (era.y + (n === '元' ?  1 : +n) - 1) + af;
  });

  // 午前午後を24時間表記に変換
  value = value.replace(REG_AMPM, (x, ampm, n) => {
    var pm = ampm === '午後' || ampm.toLowerCase() === 'pm';
    return pm ? +n + 12 : n;
  });

  return value;
}
904017
private Writer doWrite(Writer writer, int indentFactor, int indent) throws IOException {
		writer.write(CharUtil.DELIM_START);
		boolean isFirst = true;
		final boolean isIgnoreNullValue = this.config.isIgnoreNullValue();
		final int newIndent = indent + indentFactor;
		for (Entry<String, Object> entry : this.entrySet()) {
			if (ObjectUtil.isNull(entry.getKey()) || (ObjectUtil.isNull(entry.getValue()) && isIgnoreNullValue)) {
				continue;
			}

			if (isFirst) {
				isFirst = false;
			} else {
				// 键值对分隔
				writer.write(CharUtil.COMMA);
			}
			// 换行缩进
			if (indentFactor > 0) {
				writer.write(CharUtil.LF);
			}

			InternalJSONUtil.indent(writer, newIndent);
			writer.write(JSONUtil.quote(entry.getKey().toString()));
			writer.write(CharUtil.COLON);
			if (indentFactor > 0) {
				// 冒号后的空格
				writer.write(CharUtil.SPACE);
			}
			InternalJSONUtil.writeValue(writer, entry.getValue(), indentFactor, newIndent, this.config);
		}

		// 结尾符
		if (indentFactor > 0) {
			writer.write(CharUtil.LF);
		}
		InternalJSONUtil.indent(writer, indent);
		writer.write(CharUtil.DELIM_END);
		return writer;
	}
24365
public function notify()
    {
        $notice['facId'] = isset($_REQUEST['facId']) ? $_REQUEST['facId'] : '';
        $notice['facMemId'] = isset($_REQUEST['facMemId']) ? $_REQUEST['facMemId'] : '';
        $notice['facTradeSeq'] = isset($_REQUEST['facTradeSeq']) ? $_REQUEST['facTradeSeq'] : '';
        $notice['tradeSeq'] = isset($_REQUEST['tradeSeq']) ? $_REQUEST['tradeSeq'] : '';
        $notice['CardId'] = isset($_REQUEST['CardId']) ? $_REQUEST['CardId'] : '';
        $notice['oProjNo'] = isset($_REQUEST['oProjNo']) ? $_REQUEST['oProjNo'] : '';
        $notice['CardKind'] = isset($_REQUEST['CardKind']) ? $_REQUEST['CardKind'] : '';
        $notice['CardPoint'] = isset($_REQUEST['CardPoint']) ? $_REQUEST['CardPoint'] : '';
        $notice['ReturnMsgNo'] = isset($_REQUEST['ReturnMsgNo']) ? $_REQUEST['ReturnMsgNo'] : '';
        $notice['ErrorMsgNo'] = isset($_REQUEST['ErrorMsgNo']) ? $_REQUEST['ErrorMsgNo'] : '';
        $notice['ErrorMsg'] = isset($_REQUEST['ErrorMsg']) ? $_REQUEST['ErrorMsg'] : '';
        $hash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : '';

        // 签名验证
        $str = '';
        $str .= $this->config['app_key1'];
        $str .= $notice['facId'];
        $str .= $notice['facMemId'];
        $str .= $notice['facTradeSeq'];
        $str .= $notice['tradeSeq'];
        $str .= $notice['CardId'];
        $str .= $notice['oProjNo'];
        $str .= $notice['CardKind'];
        $str .= $notice['CardPoint'];
        $str .= $notice['ReturnMsgNo'];
        $str .= $notice['ErrorMsgNo'];
        $str .= $notice['ErrorMsg'];
        $str .= $this->config['app_key2'];

        $transactionId = $notice['facTradeSeq'];

        if (hash('sha256', $str) != $hash) {
            throw new DefaultException('sign error');
        }

        $result = [
            'isSuccessful'         => true,
            'message'              => 'success',
            'transactionId'        => $transactionId,
            'transactionReference' => $notice['tradeSeq'],
            'amount'               => $notice['CardPoint'],
            'currency'             => 'TWD',
            'raw'                  => $notice,
        ];
        return $result;
    }
1049989
function(param) {
      var step, start, res;
      //如果无参数 当成是获取第一个元素
      if (!param || !(param = param.replace(/\s+/g, ""))) {
        return {
          start: 1,
          step: 0
        };
      }
      if (res = nthCache.get(param)) return res;
      // 对even odd等转化为标准的a，b组合(即step与start)
      if (param == "even") {
        start = 2;
        step = 2;
      } else if (param == "odd") {
        step = 2;
        start = 1;
      } else {
        res = param.match(nthValueReg);
        // 对错误的nth参数抛出错误
        if (!res) step = null; // 无论其他参数，如果step为null，则永远为false
        else {
          if (res[1]) {
            step = 0;
            start = parseInt(res[1]);
          } else {
            if (res[2] == "-") res[2] = "-1";
            step = res[2] ? parseInt(res[2]) : 1;
            start = res[3] ? parseInt(res[3]) : 0;
          }
        }
      }
      if (start < 1) {
        if (step < 1) {
          step = null; //标志false
        } else {
          start = -(-start) % step + step;
        }
      }
      return nthCache.set(param, {
        start: start,
        step: step
      });
    }
965693
private function getMessage()
    {
        if ($this->echostr === false && $this->checkSignature()) {

            // 获取微信原始消息体
            if (@file_get_contents('php://input') !== false) {
                $xml_input = file_get_contents('php://input');
            } else {
                $xml_input = $GLOBALS['HTTP_RAW_POST_DATA'];
            }
            if (!empty($xml_input)) {

                // XML解析微信消息体
                libxml_disable_entity_loader(true);
                $xml_obj = simplexml_load_string($xml_input, 'SimpleXMLElement', LIBXML_NOCDATA);
                        
                // 微信 兼容模式/安全模式 信息解密
                if ($this->encrypt_type == 'aes') {
                    // 异常处理: 未配置encodingAESKey
                    if ($this->encodingAESKey===false) {
                        @error_log('EncodingAESKey Not Defined.', 0);
                        exit();
                    }
                    // 验证用户消息的安全签名
                    $msg_signature = SHA1::getSHA1($this->token, $this->timestamp, $this->nonce, $xml_obj->Encrypt);
                    if ($msg_signature === false) {
                        @error_log('getSHA1 Error.', 0);
                        exit();
                    }
                    if ($msg_signature != $this->msg_signature){
                        @error_log('MsgSignature Not Match.', 0);
                        exit();
                    }
                    // 解密用户消息
                    $pc = new Prpcrypt($this->encodingAESKey);
                    $xml_input1 = $pc->decrypt($xml_obj->Encrypt, $this->appId);
                    if ($xml_input1 === false) {
                        @error_log('Decode Message Error.', 0);
                        exit();
                    }
                    $xml_obj = simplexml_load_string($xml_input1, 'SimpleXMLElement', LIBXML_NOCDATA);
                }    
                $this->message = $xml_obj;
                return $xml_obj;
            }
        }
        exit();
    }
144363
def success(text):
    ''''''
    print(' '.join((green('✔'), white(text))))
    sys.stdout.flush()
361531
function () {
            if (opt.globalTask.state === 'cancel') return;
            for (; that._uploadingThreadCount < that.uploadMaxThread && task.currentIndex < task.chunkCount; task.currentIndex++) {
                var chunk = task.chunks[task.currentIndex];
                if (chunk.state !== 'waiting') continue;
                (function (chunk) {
                    chunk.state = 'uploading';
                    task.uploadingCount++;
                    that._uploadingThreadCount++;
                    uploadSingleChunk.call(that, task, chunk, function (error, data) {
                        task.uploadingCount--;
                        that._uploadingThreadCount--;
                        if (error) { // 错误马上结束
                            chunk.state = 'error';
                            uploadError(error, data);
                        } else {
                            chunk.state = 'success';
                            if (task.uploadingCount <= 0 && task.currentIndex >= task.chunkCount) { // 全部完成
                                uploadSuccess();
                            } else { // 未完成，处理执行下一个分片
                                uploadNextChunk();
                            }
                        }
                    });
                })(chunk);
            }
            if (task.uploadingCount === 0 && task.currentIndex === task.chunks.length) { // 全部不需要上传
                uploadSuccess();
            }
        }
412415
public void norm_sethour()
	{
		/*
		 * 清除只能识别11-99时的bug
		 * modified by 曹零
		 */
		String rule="(?<!(周|星期))([0-2]?[0-9])(?=(点|时))";
		
		Pattern pattern=Pattern.compile(rule);
		Matcher match=pattern.matcher(Time_Expression);
		if(match.find())
		{
			_tp.tunit[3]=Integer.parseInt(match.group());
		}	
		/*
		 * 对关键字：中午,午间,下午,午后,晚上,傍晚,晚间,晚,pm,PM的正确时间计算
		 * 规约：
		 * 1.中午/午间0-10点视为12-22点
		 * 2.下午/午后0-11点视为12-23点
		 * 3.晚上/傍晚/晚间/晚1-11点视为13-23点，12点视为0点
		 * 4.0-11点pm/PM视为12-23点
		 * 
		 * add by 曹零
		 */
		rule = "(中午)|(午间)";
		pattern = Pattern.compile(rule);
		match = pattern.matcher(Time_Expression);
		if(match.find()){
			if(_tp.tunit[3] >= 0 && _tp.tunit[3] <= 10)
				_tp.tunit[3] += 12;
		}
		
		rule = "(下午)|(午后)|(pm)|(PM)";
		pattern = Pattern.compile(rule);
		match = pattern.matcher(Time_Expression);
		if(match.find()){
			if(_tp.tunit[3] >= 0 && _tp.tunit[3] <= 11)
				_tp.tunit[3] += 12;
		}
		
		rule = "晚";
		pattern = Pattern.compile(rule);
		match = pattern.matcher(Time_Expression);
		if(match.find()){
			if(_tp.tunit[3] >= 1 && _tp.tunit[3] <= 11)
				_tp.tunit[3] += 12;
			else if(_tp.tunit[3] == 12)
				_tp.tunit[3] = 0;
		}
	}