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
"获取插件加载时间 | |
vim filename --startuptime 'time.txt' | |
"统计加载插件总用时 | |
awk '{print $2}' time.txt | sed 's/\([0-9].*\):/\1/g' | awk '{sum+=$1} END {print sum}' |
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 URL parameter | |
function get_param(name) | |
{ | |
if (location.href.indexOf("?") >= 0) { | |
var query=location.href.split("?")[1]; | |
var params=query.split("&"); | |
for (var i = 0; i < params.length; i ++) { | |
value_pair=params[i].split("="); | |
if (value_pair[0] == name) | |
return unescape(value_pair[1]); |
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
/** | |
* 解析类似URI query字符串,返回数组对象 | |
* @param uri 类似location.search | |
* @param key 数组的key name | |
* @returns {*} | |
*/ | |
function parse_param(uri, key) | |
{ | |
var regex = /[?&]([^=#]+)=([^&#]*)/g, | |
url = uri, |
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
/** | |
* @return array of type | |
*/ | |
public static function itemsAilas($type){ | |
$items = [ | |
'occupation'=> [ | |
self::OCCUPATION_DOCTOR => 'แพทย์', | |
self::OCCUPATION_NURSE => 'พยาบาล', | |
self::OCCUPATION_PHARMACY => 'เภสัชกร', | |
self::OCCUPATION_DENTIST => 'ทันตแพทย์', |
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
$phoneset = ''; | |
$content = ''; | |
$type = 'uid'; | |
$types = [ | |
'uid' =>'使用uid', | |
'phone'=>'电话号码', | |
]; | |
$model = DynamicModel::validateData(compact('phoneset', 'content', 'type', 'types'), [ | |
['phoneset', 'string', 'min' => 11], | |
['content', 'string', 'max' => 340, 'min' => 2], |
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 | |
// http://www.phpwtf.org/ | |
$a = array(); | |
$a[''] = 'string index'; | |
$a[NULL] = 'NULL index'; | |
$a[] = 'add index'; | |
var_dump($a); | |
// NULL is equal '' |
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 | |
/** | |
* Created by PhpStorm. | |
* User: yantze.yang | |
* Date: 2015/11/7 | |
* Time: 18:05 | |
*/ | |
namespace app\helpers\db; | |
// user:password@host:port\database |
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 addScript( src,callback) { | |
var s = document.createElement( 'script' ); | |
s.setAttribute( 'src', src ); | |
s.onload=callback; | |
document.body.appendChild( s ); | |
} |
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
#!/bin/sh | |
# get pure ip from url | |
function ipurl() { | |
echo $1 | | |
sed -e 's/^.*:\/\/\(.*\)/\1/g' | # remove http(s):// | |
awk -F/ '{print $1}' | # remove /query/abc?a=b | |
xargs ping -c 1 -t 1 | # -c only send one package, -t timeout 1s | |
sed -n '1p' | # result: get first line | |
sed -e 's/^.*(\([0-9\.]\{7,\}\)).*/\1/g' # get ip in the first line |
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: yantze | |
// date: 2016-07-31 | |
// desc: php 自增和运算符执行顺序分析 | |
// #1 | |
function test1(){ | |
echo PHP_EOL.__function__ .":"; | |
$a=1; | |
echo (++$a)+(++$a); |
OlderNewer