0%

Access Right

1
2
3
4
5
6
7
8
9
$ touch tree
$ stat tree
File: `tree'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd18h/64792d Inode: 38100480 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 501/ xxx) Gid: ( 501/ xxx)
Access: 2018-11-08 23:35:55.749317495 +0800
Modify: 2018-11-08 23:35:55.749317495 +0800
Change: 2018-11-08 23:35:55.749317495 +0800
阅读全文 »

什么是“惊群现象”(thundering herd)

引用自wiki

In computer science, the thundering herd problem occurs when a large number of processes waiting for an event are awoken when that event occurs, but only one process is able to proceed at a time. After the processes wake up, they all demand the resource and a decision must be made as to which process can continue. After the decision is made, the remaining processes are put back to sleep, only to all wake up again to request access to the resource.
This occurs repeatedly, until there are no more processes to be woken up. Because all the processes use system resources upon waking, it is more efficient if only one process is woken up at a time.
This may render the computer unusable, but it can also be used as a technique if there is no other way to decide which process should continue (for example when programming with semaphores).

阅读全文 »

正则表达式关于 Metacharacter [ ]

引用自 wiki

A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches “a”, “b”, or “c”. [a-z] specifies a range which matches any lowercase letter from “a” to “z”. These forms can be mixed: [abcx-z] matches “a”, “b”, “c”, “x”, “y”, or “z”, as does [a-cx-z].
The - character is treated as a literal character if it is the last or the first (after the ^, if present) character within the brackets: [abc-], [-abc]. Note that backslash escapes are not allowed. The ] character can be included in a bracket expression if it is the first (after the ^) character: []abc].

说的很明白了不翻译了,重点:

  • ‘-‘ 的用法需特殊注意
  • ‘]’ 的用法需要特殊注意
阅读全文 »

定义

引用自wiki

“Endianness refers to the sequential order in which bytes are arranged into larger numerical values when stored in memory or when transmitted over digital links”

字节序是系统存储一个整数时,字节的排列顺序。分为:Big Endian(大端),Little Endian(小端)

阅读全文 »

在Google搜索“php 抽奖”, 通篇最为常见的算法如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
// “经典抽奖算法”
function rand2($arr)
{
$sum = array_sum($arr);

foreach($arr as $key => $value)
{
$ret = rand(0, $sum * MAX - 1);

if ($ret < $value * MAX)
return $key;
else
$sum -= $value;
}
}
?>

阅读全文 »

  • 云主机:阿里云主机
  • 操作系统:CentOS release 6.9 (Final)
    (本文档只记录大概步骤,可能有不详细的地方,暂且看看)

    1. 创建普通用户

    1
    2
    useradd xxx
    passwd xxx
阅读全文 »

直接连接 PHP-FPM

步骤

  • 工具安装
    1
    2
    3
    4
    5
    # centos
    yum --enablerepo=epel install fcgi

    # ubuntu
    apt-get install libfcgi0ldbl
阅读全文 »

location 匹配规则

1
2
3
4
Syntax: location [ = | ~ | ~* | ^~ ] uri { ... }
location @name { ... }
Default: —
Context: server, location

location 分类

  • 前缀字符串匹配

    1
    location [=|^~] uri {...}
    • =
      完全匹配/精确匹配
    • ^~
      前缀匹配
    • “无任何特殊字符”
      从前往后,普通匹配
  • 正则匹配

    1
    location [~*|~] uri {...}
    • ~
      匹配区分大小写
    • ~*
      匹配不区分大小写
  • 其他

    1
    location @ uri {...}

只用于内部重定向

阅读全文 »