Skip to content

Instantly share code, notes, and snippets.

@k1ic
k1ic / php
Created March 2, 2016 03:01
rety_func
function _retry($function, $params, $max = 3) {
$this->_retry++;
if ($this->_retry >= $max) {
$this->_retry = 0;
Hades_Tool_Log::logRun("p:{$this->_processNumber}|retry_max|function:" . json_encode($function) . "|params:" . json_encode($params), false, __FUNCTION__, $this->_className, Hades_Tool_Log::TYPE_EVE);
return false;
}
usleep(20000);
@k1ic
k1ic / php
Created November 3, 2016 06:36
sort
private function _sort($arr = array(), $sort_filed = '', $sort_direction = self::HOT_LIST_SORT_ASC) {
$sort = array(
'direction' => $sort_direction, //排序顺序标志,SORT_DESC:降序,SORT_ASC:升序
'field' => $sort_filed, //排序字段
);
$arr_sort = array();
foreach ($arr as $uniqid => $row) {
foreach ($row as $k => $v) {
$arr_sort[$k][$uniqid] = $v;
@k1ic
k1ic / php
Created November 3, 2016 09:42
log id generate
sprintf("%u%04u", substr(sprintf("%.0f", microtime(true) * 1000000), 5), rand(0, 9999))