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
/** | |
* test some performance between this and parent | |
*/ | |
function microtime_float() | |
{ | |
list($usec, $sec) = explode(" ", microtime()); | |
return ((float)$usec + (float)$sec); | |
} | |
/* | |
$time_start = microtime_float(); |
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
*/ | |
/** | |
* test memory comsuming | |
*/ | |
class base1{ | |
public $a; | |
public $b; | |
public $c; | |
public $d; |
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
#Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等) | |
#去空格及特殊符号 | |
s.strip() .lstrip() .rstrip(',') | |
#复制字符串 | |
#strcpy(sStr1,sStr) | |
sStr= 'strcpy' | |
sStr = sStr |
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 | |
function getOnlineIp() { | |
$strOnlineIp = ""; | |
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) { | |
$onlineip = getenv('HTTP_CLIENT_IP'); | |
} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) { | |
$onlineip = getenv('HTTP_X_FORWARDED_FOR'); | |
} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) { | |
$onlineip = getenv('REMOTE_ADDR'); | |
} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) { |
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 | |
function getStrTruncate($string, $length = 80, $etc = ''){ | |
if ($length == 0) return ''; | |
mb_internal_encoding("UTF-8"); | |
$string = str_replace("\n","",$string); | |
$strlen = mb_strwidth($string); | |
if ($strlen > $length) { | |
$etclen = mb_strwidth($etc); | |
$length = $length - $etclen; |
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
close all | |
clear all | |
% for n=1:10:10000 | |
fsample=1424424; | |
f=fsample/1020.32; | |
A=1; | |
lens=2^20; | |
N=15; |
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 [ theta ] = direction( p1,p2 ) | |
% direction of nodes p1 and p2. Support 2D and 3D, return the angle from p2 to p1 | |
% In 2D case, theta will be a scaler indicates the angle from p2 to p1, which ranges from -pi~pi; | |
% In 3D case theta will be a vector, theta(1) is azimuthal angle (-pi~ pi) and theta(2) is altitude angle(-pi/2~pi/2) | |
if(length(p1)==2) | |
v = p1-p2; | |
theta = atan(v(2)/v(1)); | |
if(v(1)<0) | |
if(v(2)<0) | |
theta = theta- pi; |
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 [X,Y,Z] = polarToCartesian(R,logi,lanti) | |
% convert polar coordinate to Cartesian | |
% R, logi(-pi~pi), lanti (-1/2*pi~1/2*pi) are Radius,longitude, lantitude | |
Z = R* sin(lanti); | |
Y = R* cos(lanti) *sin(logi); | |
X = R*cos(lanti) *cos(logi); |
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 [ indx ] = resampleSystematic(w,N) | |
Q = cumsum(w); | |
T = linspace(0,1-1/N,N) + rand(1)/N; | |
T(N+1) = 1; | |
i=1; | |
j=1; | |
indx = zeros(N,1); |
OlderNewer