Articles tagged as

  1. 有爱的小脚本:启动终端时显示一句箴言



    说话的东西和说的话都随机出现。这个效果是我在Linux Mint里面看到的,感觉很有爱。下周考Unix环境编程,周末恶补一下,顺便写这个小脚本练手。

    以我在用的 ubuntu 为例。首先确保安装 fortunescowsay 两个包。前者用于显示各种各样的趣味短句,后者则提供了一头会说话的奶牛(和其它各种诡异的东西)。关于fortunes还有一些有趣的包你可能也想一起安装,比如fortune-zh里有唐诗宋词,fortunes-ubuntu-server则有关于使用Ubuntu Server的贴士,等等。

    # Cow randomly says a hopefully interesting adage
    # Get a short message from fortune, both offensive and not.
    # Remove -a if you don't want to see offensive ones.
    # Remove -s if you don't mind reading the long messages.
    msg=`fortune -a -s`
    # Randomly pick a mode of the cow
    modes=("" -b -d -g -p -s -t -w -y ); mode=${modes[$(($RANDOM % 9))]}
    # cowsay or cowthink?
    cowdos=(cowsay cowthink); cowdo=${cowdos[$(($RANDOM % 2))]}
    # Radomly pick a cow picture file
    speaker=`cowsay -l | sed '1d;s/ /n/g'| sort -R | head -1`
    # That's it ^^
    echo "$msg" | $cowdo -n -f $speaker $mode


    chmod +x cowsay-fortune


    sudo cp cowsay-fortune /usr/bin


    sudo gedit /etc/bash.bashrc





  2. 恶搞巴赫:Deconstructing Johann

    偶然发现的一段很好玩的视频,是 The King’s Singers 在 2000 年巴赫音乐节表演的 Deconstructing Johann。他们从巴赫的一些有名的作品中选出片段拼凑了一下,填上词,虚构出巴赫在写d小调托卡塔与赋格时与妻子很恶搞的对话。


    Deconstructing Johann

    J. S. Bach had a little problem.
    J. S. Bach was in a fix.
    J. S. Bach couldn’t find an answer.
    What to do?
    “I’ve written most of a rather fabulous work!
    Toccata, it’s in D minor, but now I’m feeling a bit of a jerk!
    I can’t think of what should come after it…”
    “Now,” said his wife, who was resting up after her 33rd child,
    “Johann, my dear, you should just go to bed.
    Something always comes up.”
    “Don’t be a tweet!
    It’s a real crisis and I’m working to a deadline!
    What can I fit?
    What to fit after the great toccata?
    Maybe it needs to be something faster?
    I haven’t got a clue
    and in a week the piece is due.
    I’m in a panic!
    I’m stuck like glue!”
    “Don’t get your knickers in a twist, Johann.
    ‘Those are only notes’, you’ve always said.
    There’s only twelve so use your head.
    How many arrangements of twelve notes can there possibly be?”
    “That’s a problem ...
  3. 谁发明了递归











    现在你知道是谁发明递归的了。 @_@

Page 1 / 1