不错的bsp

Posted on 2008年7月31日 21:52

这个主题很赞!

测试些代码加亮。

C

 

/* Print the numbers between 1 and 1000. */
/* Add a rule: Don't use any loops. */
/* Add another rule: No recursions. */

#include <stdio.h>

#define A(x) x;x;x;x;x;x;x;x;x;x;

int main(void)
{
  int n = 1;
  A(A(A(printf("%d, ", n++))));
  return 0;
}

 

Python

 

# by Peter Norvig
import re, collections

def words(text): return re.findall('[a-z]+', text.lower())

def train(features):
     model = collections.defaultdict(lambda: 1)
     for f in features:
         model[f] += 1
     return model

 NWORDS = train(words(file('big.txt').read()))

 alphabet = 'abcdefghijklmnopqrstuvwxyz'

def edits1(word):
     n = len(word)
     return set([word[0:i]+word[i+1:] for i in range(n)] +                     # deletion
                [word[0:i]+word[i+1]+word[i]+word[i+2:] for i in range(n-1)] + # transposition
                [word[0:i]+c+word[i+1:] for i in range(n) for c in alphabet] + # alteration
                [word[0:i]+c+word[i:] for i in range(n+1) for c in alphabet])  # insertion

def known_edits2(word):
     return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS)

def known(words): return set(w for w in words if w in NWORDS)

def correct(word):
     candidates = known([word]) or known(edits1(word)) or known_edits2(word) or [word]
     return max(candidates, key=lambda w: NWORDS[w])

 

 

Shell

 

#!/bin/bash

list=`ps aux | grep $1 | grep -v "grep $1"`
pid=`echo $?`

echo $pid

if [ $pid = 0 ]; then
    for i in `echo $list | awk '{print $2}'`; do
        kill -9 $i 2>/dev/null
    done
else
    echo "No such process!"
fi

 

 

 

HTML

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>vvoody's woody house</title>
  <link type="text/css" rel="stylesheet" href="style.css" />
  <link rel="openid.server" href="http://www.myopenid.com/server" />
  <link rel="openid.delegate" href="http://vvoody.myopenid.com/" />
</head>
<body>
<h1>vvoody's &copy; Site-></h1>

<ul>
    <li><a href="blog/">blog</a></li>
    <li><a href="http://vvoody.org/blog/?page_id=9">Do you want to say sth. to me? </a></li>
</ul>
<p>
<b>Keep It Simple, Slack</b>
</p>
<p>
<b>Your heart is free. Have the courage to follow it.</b>
</p>
<!--<p>
-->
<!-- <a href="http://validator.w3.org/check?uri=referer">
-->
<!--  <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" />
</a>-->
<!-- <a href="http://jigsaw.w3.org/css-validator/">
-->
<!--  <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" />
</a>-->
<!--</p>
-->
</body>
</html>