Last active
May 8, 2021 01:59
-
-
Save crossmaya/5319554 to your computer and use it in GitHub Desktop.
Revisions
-
crossmaya revised this gist
May 8, 2021 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function updateAppVersion($appVersion1, $appVersion2) { $len = count($releaseVersion); } for($i = 0;$i<$len;$i++){ echo "[i=".$i."][r=".$releaseVersion[$i]."][d=".$deviceVersion[$i]."]"; if(!isset($releaseVersion[$i])){ @@ -28,9 +28,7 @@ function updateAppVersion($appVersion1, $appVersion2) else if($releaseVersion[$i]<$deviceVersion[$i]){ return false; } } return false; } -
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function updateAppVersion($appVersion1, $appVersion2) { $len = count($releaseVersion); } for($i = 0;$i<$len;$i++){ echo "[i=".$i."][r=".$releaseVersion[$i]."][d=".$deviceVersion[$i]."]"; if(!isset($releaseVersion[$i])){ -
crossmaya revised this gist
May 8, 2021 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,10 @@ function updateAppVersion($appVersion1, $appVersion2) { $releaseVersion = explode(".",$appVersion1); $deviceVersion = explode(".",$appVersion2); $len = count($deviceVersion); if(count($releaseVersion)>count($deviceVersion)) { $len = count($releaseVersion); } -
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ function updateAppVersion($appVersion1, $appVersion2) { $releaseVersion = explode(".",$appVersion1); $deviceVersion = explode(".",$appVersion2); $len = count($deviceVersion); if(count($releaseVersion)>count($deviceVersion)){ $len = count($releaseVersion); -
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,35 @@ /** common libs **/ //应用版本比较 function updateAppVersion($appVersion1, $appVersion2) { $releaseVersion = explode(".",$appVersion1); $deviceVersion = explode(".",$appVersion2); $len = count($deviceVersion); if(count($releaseVersion)>count($deviceVersion)){ $len = count($releaseVersion); } for($i = 0;$i<$len;$i++){ echo "[i=".$i."][r=".$releaseVersion[$i]."][d=".$deviceVersion[$i]."]"; if(!isset($releaseVersion[$i])){ return false; } else if(!isset($deviceVersion[$i])){ return true; } else if($releaseVersion[$i]>$deviceVersion[$i]){ return true; } else if($releaseVersion[$i]<$deviceVersion[$i]){ return false; } } return false; } /** Array helper **/ -
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,9 @@ /** common libs **/ //应用版本比较 /** Array helper **/ -
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . No changes.There are no files selected for viewing
-
crossmaya revised this gist
May 8, 2021 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ <?php /** common libs **/ /** Array helper **/ function array_except($array, $key) -
crossmaya revised this gist
Jan 8, 2021 . 1 changed file with 156 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,156 @@ <?php declare(strict_types=1); use GuzzleHttp\Client; use Swoft\Stdlib\Helper\ArrayHelper; use GuzzleHttp\Exception\RequestException; /** * 数据格式化 * * @access public * @param mixed $args 待处理数据 * @return mixed */ if ( ! function_exists('formatData')) { function formatData($args) { $data = []; foreach ($args as $key => $val) { $key = lineToHump((string)$key); if (is_array($val) || is_object($val)) { $val = formatData($val); } $data[$key] = $val; } return $data; } } /** * 驼峰转下划线 * * @access public * @param string $str 字符串 * @return string */ if ( ! function_exists('lineToHump')) { function humpToLine(string $str) { return preg_replace_callback('/([A-Z])/', function ($match) { return '_'.lcfirst($match[0]); }, $str); } } /** * 下划线转驼峰 * * @access public * @param string $str 字符串 * @return string */ if ( ! function_exists('lineToHump')) { function lineToHump(string $str) { return preg_replace_callback('/(_[a-z])/', function ($match) { return ucfirst(trim($match[0], '_')); }, $str); } } /** * 随机字符串 * * @access public * @param integer $len 字符长度 * @param boolean $int 纯数字 * @return string */ if ( ! function_exists('random')) { function random($len = 10, $int = false) { $str = ''; $len = (is_numeric($len)) ? $len : 10; $seed = base_convert(md5(microtime(true).uniqid((string)mt_rand(), true)), 16, ( ! empty($int)) ? 10 : 35); $seed = ( ! empty($int)) ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); if ( ! empty($int)) { $str = ''; } else { $str = chr(mt_rand(1, 26) + mt_rand(0, 1) * 32 + 64); --$len; } $max = strlen($seed) - 1; for ($i = 0; $i < $len; ++$i) { $str .= $seed{mt_rand(0, $max)}; } return $str; } } /** * 发送请求 * * @access public * @param string $url URL * @param array $args 提交参数 * @param array $headers HEAD信息 * @param string $method 提交方法 * @return array * @throws */ if ( ! function_exists('send')) { function send(string $url, array $args = [], array $headers = [], string $method = 'POST') { $status = ['code' => 0, 'data' => [], 'message' => '']; try { $options = ( ! empty($args)) ? ['form_params' => $args] : []; if ( ! empty($headers)) { $options['headers'] = $headers; } $response = (new Client())->request($method, $url, $options); $content = $response->getBody()->getContents(); if (empty($content)) { throw new \Exception('没有返回相关数据!'); } $status = ['code' => 200, 'data' => $content, 'message' => '']; } catch (RequestException $e) { $status['message'] = $e->getMessage(); } return $status; } } /** * 格式化JSON * * @access public * @param mixed $data 待处理数据 * @return mixed */ if ( ! function_exists('withJson')) { function withJson(array $data) { if (isset($data['data'])) { if (empty($data['data']) && is_array($data['data'])) { $data['data'] = new \stdClass(); } } return $data; } } -
crossmaya revised this gist
Dec 14, 2017 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,24 @@ function array_except($array, $key) return array_diff_key($array, array_flip((array) $key)); } if (! function_exists('objectToArray') ) { function objectToArray($d) { if( is_object($d) ) { $d = get_object_vars($d); } if( is_array($d) ) { return array_map(__FUNCTION__, $d); } else { return $d; } } } /* String Helper */ -
crossmaya revised this gist
Jun 27, 2013 . 1 changed file with 18 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,14 @@ <?php /** Array helper **/ function array_except($array, $key) { return array_diff_key($array, array_flip((array) $key)); } /* String Helper */ function start_with($haystack, $needle) { return strpos($haystack, $needle) === 0; @@ -10,9 +20,14 @@ function ends_with($haystack, $needle) } /* Common Helper */ function with($object) { return $object; } function value($value) { return $object instanceof Closure ? $value() : $value; } -
crossmaya revised this gist
Jun 27, 2013 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,13 @@ <?php function start_with($haystack, $needle) { return strpos($haystack, $needle) === 0; } function ends_with($haystack, $needle) { return $needle == substr($haystack, strlen($haystack) - strlen($needle)); } /** Array helper **/ -
crossmaya revised this gist
Jun 27, 2013 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,12 @@ function start_with($haystack, $needle) { function ends_with($haystack, $needle){ return $needle == substr($haystack, strlen($haystack) - strlen($needle)); } /** Array helper **/ function array_except($array, $key) { return array_diff_key($array, array_flip((array) $key)); } -
crossmaya revised this gist
Apr 5, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,4 +3,6 @@ function start_with($haystack, $needle) { return strpos($haystack, $needle) === 0; } function ends_with($haystack, $needle){ return $needle == substr($haystack, strlen($haystack) - strlen($needle)); } -
crossmaya renamed this gist
Apr 5, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
crossmaya revised this gist
Apr 5, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ <?php function start_with($haystack, $needle) { return strpos($haystack, $needle) === 0; }
-
crossmaya created this gist
Apr 5, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ <?php function start_with($haystack, $needle) { return strpos($haystack, $needle) === 0; }