This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"设置TAB键为4个空格 | |
set tabstop =4 | |
"显示行号 | |
set number | |
"关闭vi兼容模式 | |
set nocompatible | |
"自动语法高亮 | |
syntax enable | |
syntax on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
# trans.py | |
# create :2010-6-2 | |
# last modify: 2010-6-3 | |
# author : ice_cube | |
import urllib,urllib2 | |
from sgmllib import SGMLParser | |
class URLLister(SGMLParser): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from myThread import MyThread | |
from time import ctime | |
from time import sleep | |
import sys | |
def fib(x): | |
# sleep(0.005) | |
if x<2:return 1 | |
return (fib(x-2) + fib(x-1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> | |
<html> | |
<head> | |
<title>this rose</title> | |
<meta charset="utf-8"> | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-1948154-1']); | |
_gaq.push(['_trackPageview']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> | |
<html> | |
<head> | |
<title>this is rose</title> | |
<meta charset="utf-8"> | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-1948154-1']); | |
_gaq.push(['_trackPageview']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from HTMLParser import HTMLParser | |
import urllib | |
import sys | |
class parselinks(HTMLParser): | |
def __init__(self): | |
self.data=[] | |
self.href=0 | |
self.linkname='' | |
HTMLParser.__init__(self) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var check = require('validator').check, | |
sanitize = require('validator').sanitize | |
//Validate | |
check('[email protected]').len(6, 64).isEmail(); //Methods are chainable | |
check('abc').isInt(); //Throws 'Invalid integer' | |
check('abc', 'Please enter a number').isInt(); //Throws 'Please enter a number' | |
check('abcdefghijklmnopzrtsuvqxyz').is(/^[a-z]+$/); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
一、文本文件比较命令diff | |
1>diff命令的功能 | |
Linux中diff命令的功能为逐行比较两个文本文件,列出其不同之处。它对给出的文件进行系统的检查,并显示出两个文件中所有不同的行,不要求事先对文件进行排序。 | |
2>语法 | |
diff [options] file1 file2 | |
该命令告诉用户,为了使两个文件file1和file2一致,需要修改它们的哪些行。如果用”-”表示file1或file2,则表示标准输入。如果file1或file2是目录,那么diff将使用该目录中的同名文件进行比较。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PageRank algorithm | |
# By Peter Bengtsson | |
# http://www.peterbe.com/ | |
# [email protected] | |
# | |
# Requires the numarray module | |
# http://www.stsci.edu/resources/software_hardware/numarray | |
from numarray import * | |
import numarray.linear_algebra as la |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
最近我开始学习 Hadoop,本来以为课程应该会更多的侧重如何管理 Hadoop 集群,没想到开始阶段,老师为了让我们更好的理解 Hadoop 的 MapReduce 机制,让我们自己先来实现一个谷歌的 PageRank 算法,本来我想打算使用 Java 来实现的,因为毕竟过段时间,我需要在 Hadoop 集群上部署 Java 代码从而实现数据分析,但我从毕业后就再没用过 Java 写过一行代码,所以我真是写不出来啊,尤其是 PageRank 基本就是矩阵和向量的迭代运算,用 Java 的话一定用到二维数组,我上学的时候学的就不太好。我考虑再三还是决定用 Python 来实现,毕竟上半年的时候自学了一些 Python 语言,而且我知道 Python 有一个第三方模块叫 python-graph,用它来做图论方面的编程容易很多。我是在 Linode VPS 上搭建的 Python 编程环境。相关的模块安装过程如下: | |
[root@chenjunlu ~]# yum install graphviz* | |
[root@chenjunlu ~]# yum install vsftpd | |
[root@chenjunlu ~]# wget http://python-graph.googlecode.com/files/python-graph-core-1.8.2.tar.gz | |
[root@chenjunlu ~]# tar -zxvf python-graph-core-1.8.2.tar.gz | |
[root@chenjunlu ~]# cd python-graph-core-1.8.2 | |
[root@chenjunlu ~]# python setup.py install |
OlderNewer