有B格的写作软件Desk

  博客是很久没有更新了,不过wordpress却是一直跟随升级到最新的4.1版本,界面越来越好,新特性也越来越多,写blog的欲望却没了。。每次登陆后台,无非是删下垃圾评论,升级下插件。人也越来越懒,对酒的热情已经高过写垃圾代码。

于是为了提高写blog的兴致,入手了一款专门用于写作的mac软件:Desk。额,话说我对这类软件要求很低了,只要满足2点就够了:1.界面够简单,能贴图 2.可以发布到wordpress。至于排版,我是没有什么要求了,如果写东西还要关注字号粗细,那还有tmd神马乐趣。。

木有看错,就一块简单的编辑区,类似之前用过的一款叫zenwriter的软件(截图黑漆漆是开了夜间模式)。

OK,发出去看看效果。。

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

修改自一个矩阵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

wordpress 隐藏非主页的侧边栏

function bluehua_hide_widgets($sidebars_widgets) {
    if (is_home()) {
        return $sidebars_widgets;
    } else {
        return array();
    }
}

add_filter('sidebars_widgets', 'bluehua_hide_widgets', 10);

[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