文章分类 » bookmark

获取两组数据的固定乱序组合

修改自一个矩阵z形遍历代码,改成从中间开始遍历,乱序效果更好

function matrix_mess_order($rows, $cols) {
    $cuts = $rows + $cols - 1;
    $mid  = (int)($cuts/2);
    $result = array();
    for ($i = 0; $i < $cuts; $i++) {
        if ($i % 2 == 0) {
            $j = $mid - (int)($i % $mid);
        } else {
            $j = $mid + (int)($i % $mid);
        }
        $row_extra = ($j + 1) > $rows ? ($j + 1 - $rows) : 0; 
        $col_extra = ($j + 1) > $cols ? ($j + 1 - $cols) : 0; 
        $len = ($j + 1) - $row_extra - $col_extra;
        $topright_row = $col_extra;
        $topright_col = $j - $col_extra;
        $leftbotm_row = $j - $row_extra;
        $leftbotm_col = $row_extra;
        if ($j % 2 == 0) {
            while ($len -- > 0) {
                $result[] = array($leftbotm_row - $len, $leftbotm_col + $len);
            }
        } else {
            while ($len -- > 0) {
                $result[] = array($topright_row + $len, $topright_col - $len);
            }
        }
    }
    return $result;
}

[bookmark]统计最常使用的命令

v2ex看到一条统计最常用命令的脚本,收藏一下~

$ history | awk '{CMD[$2]++;count++;} END { for (a in CMD )print CMD[ a ]" " CMD[ a ]/count*100 "% " a }' | grep -v "./" | column -c3 -s " " -t |sort -nr | nl | head -n10
1 167 33.4% vim
2 104 20.8% ls
3 75 15% make
4 25 5% cd
5 13 2.6% sshgo
6 11 2.2% telnet
7 11 2.2% sudo
8 10 2% find
9 5 1% mv
10 4 0.8% ps

from:http://v2ex.com/t/98373

[bookmark]cron,anacron,atd

There’s a clear difference between these three applications, and merging
them would be a fairly significant amount of development effort.

cron – executes recurring commands that should occur at a specific time
anacron – executes recurring commands that should take place with a
given frequency.

(The difference between them is that if a task is scheduled in cron and
the machine is switched off, it won’t be executed until the next time
it’s due to run. anacron will attempt to catch up when the machine comes
back up)

atd – executes a non-recurring command at a specific time

The fact that all three exist is something of a holdover from legacy
Unix, but it’s not possible to just remove one of them.

http://ubuntu.5.x6.nabble.com/cron-atd-anacron-other-wtf-td686145.html

key code table

Key Mac Windows Linux Notes
rbKeyUp 126 26 103
rbKeyDown 125 28 108
rbKeyLeft 123 25 105
rbKeyRight 124 27 106
rbKeyBackspace 117 8 14
rbKeyEnter 76 * 28
rbKeyHome 115 36 102
rbKeyEnd 119 35 107
rbKeyPageDown 121 34 109
rbKeyPageUp 116 33 104
rbKeyReturn 36 13 *
rbKeyDelete 51 46 111
rbKeyTab 48 9 15
rbKeySpacebar 49 20 57
rbKeyShift 56 10 *
rbKeyControl 59 11 *
rbKeyMenu 58 18 139 The Alt key
rbKeyPrintScreen * 42 210
rbKeyEscape 53 27 1
rbKeyCapsLock 57 20 58
rbKeyHelp 114 47 138
rbKeyF1 122 112 59
rbKeyF2 120 113 60
rbKeyF3 99 114 61
rbKeyF4 118 115 62
rbKeyF5 96 116 63
rbKeyF6 97 117 64
rbKeyF7 98 118 65
rbKeyF8 100 119 66
rbKeyF9 101 120 67
rbKeyF10 109 121 68
rbKeyF11 103 122 87
rbKeyF12 111 123 88
rbKeyMacFn 63 * *
rbKeyMacOption 58 * *
rbKeyMacCommand 55 * *
rbKeyWinLeftWindow * 91 * On “Natural” keyboards
rbKeyWinRightWindow * 92 * On “Natural” keyboards
rbKeyWinApplication 110 93 * On “Natural” keyboards
rbKeyQ 12 81 16
rbKeyW 13 87 17
rbKeyE 14 69 18
rbKeyR 15 82 19
rbKeyT 17 84 20
rbKeyY 16 89 21
rbKeyU 32 85 22
rbKeyI 34 73 23
rbKeyO 31 79 24
rbKeyP 35 80 25
rbKeyA * 65 30
rbKeyS 1 83 31
rbKeyD 2 68 32
rbKeyF 3 70 33
rbKeyG 5 71 34
rbKeyH 4 72 35
rbKeyJ 38 74 36
rbKeyK 40 75 37
rbKeyL 37 76 38
rbKeyZ 6 90 44
rbKeyX 7 88 45
rbKeyC 8 67 46
rbKeyV 9 86 47
rbKeyB 11 66 48
rbKeyN 45 78 49
rbKeyM 46 77 50
rbKey0 29 48 11
rbKey1 18 49 2
rbKey2 19 50 3
rbKey3 20 51 4
rbKey4 21 52 5
rbKey5 23 53 6
rbKey6 22 54 7
rbKey7 26 55 8
rbKey8 28 56 9
rbKey9 25 57 10
rbKeyPeriod 47 190 52
rbKeyComma 43 188 51
rbKeySlash 44 191 53 The key with /? generally next to right shift key.
rbKeyNum0 82 96 82 On numeric keypad or with NumLock
rbKeyNum1 83 97 79 On numeric keypad or with NumLock
rbKeyNum2 84 98 80 On numeric keypad or with NumLock
rbKeyNum3 85 99 81 On numeric keypad or with NumLock
rbKeyNum4 86 100 75 On numeric keypad or with NumLock
rbKeyNum5 87 101 76 On numeric keypad or with NumLock
rbKeyNum6 88 102 77 On numeric keypad or with NumLock
rbKeyNum7 89 103 71 On numeric keypad or with NumLock
rbKeyNum8 91 104 72 On numeric keypad or with NumLock
rbKeyNum9 92 105 73 On numeric keypad or with NumLock
rbKeyMultiply 67 106 55 On numeric keypad or with NumLock
rbKeyAdd 69 107 78 On numeric keypad or with NumLock
rbKeySubtract 78 109 74 On numeric keypad or with NumLock
rbKeyDivide 75 111 98 On numeric keypad or with NumLock
rbKeyDecimal 65 110 83 On numeric keypad or with NumLock
rbKeyNumEqual 81 * 117 On numeric keypad or with NumLock

from:http://classicteck.com/rbarticles/mackeyboard.php

mysqldump的where选项

mysqldump -uxxx -pxxx -hxxx --opt --where="id=2312" dbname tablename 

———–
post by Email~