05 2013 档案

摘要:改IP地址1、当前立即生效ifconfig eth0 xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx2、写入配置文件 vi /etc/sysconfig/network-scripts/ifcfg-eth0 如果是静态ip,BOOTPROTO=static 否则 dhcp IPADDR = xxx.xxx.xxx.xxx NETMASK=xxx.xxx.xxx.xxx修改主机名1、hostname -f #查看 hostname xxxx.org #修改2、写入配置文件 vi /etc/hosts 127.0.0.1 localhost修改DNSvi... 阅读全文
posted @ 2013-05-31 14:13 践道者 阅读(279) 评论(0) 推荐(0) 编辑
摘要:(1)不喜欢现在的工作,要么辞职不干,要么就闭嘴不言。(2)每个人都有孤独的时候。(3)不要像玻璃那样脆弱。(4)管住自己的嘴巴。(5)机会从不会“失掉”。(6)若电话老是不响,你该打出去。(7)千万不要因为到了结婚年龄而草率结婚。(8)写出你一生要做的事情,放在皮夹里,经常拿出来看。 阅读全文
posted @ 2013-05-28 09:15 践道者 阅读(126) 评论(0) 推荐(0) 编辑
摘要:def add(a, b): """ >>> add(1, 2) 3 >>> add([1], [2]) [1, 2] >>> add("1", "2") '12' """ return a + bif __name__ == "__main__": import doctest doctest.testmod()可以直接在命令行进行测试python-m doctest-v example.py 会输出详细 阅读全文
posted @ 2013-05-27 17:02 践道者 阅读(342) 评论(0) 推荐(0) 编辑
摘要:apt-get update 获取最新软件列表apt-get install packageName 安装一个包apt-cache search package_name 搜索软件包更改源:修改/etc/apt/sources.list如更改163源:在sources.list文件最顶加入下面信息deb http://mirrors.163.com/debian wheezy main non-free contribdeb http://mirrors.163.com/debian wheezy-proposed-updates main contrib non-freedeb-src ht 阅读全文
posted @ 2013-05-22 09:55 践道者 阅读(7407) 评论(0) 推荐(0) 编辑
摘要:今天发现新版服务器的python import 不了httplib模块的HTTPSConnection类,进httplib看源代码发现加载HTTPSConnection的代码是这样的:try: import sslexcept ImportError: passelse: class HTTPSConnection(HTTPConnection):原来是没有ssl模块,经查实,python2.6版之后已经内置ssl模块,不用第三方模块方式安装,因此重新configure make && make install就行了,不影响以前安装的模块configure --with-ssl 阅读全文
posted @ 2013-05-21 09:40 践道者 阅读(469) 评论(0) 推荐(0) 编辑
摘要:// all environmentsapp.configure(function(){ app.set('title', 'My Application');})// development onlyapp.configure('development', function(){ app.set('db uri', 'localhost/dev');})// production onlyapp.configure('production', function(){ app.set('db 阅读全文
posted @ 2013-05-17 13:59 践道者 阅读(353) 评论(0) 推荐(0) 编辑
摘要:var express = require('express');var app = express();app.get('/', function(req, res){ res.send('hello world');});app.listen(3001);非常简单,此代码暂时无视图模板样式等概念 阅读全文
posted @ 2013-05-17 12:00 践道者 阅读(156) 评论(0) 推荐(0) 编辑
摘要:function Animal(){ this.species = "动物";}function Cat(name, color){ this.name = name; this.color = color;}Cat.prototype = new Animal();Cat.prototype.constructor = Cat; //重新把Cat的构造函数指回Catvar c2 = new Cat("大黄", "黄色滴");console.log(c2.name);console.log(c2.species);console.lo 阅读全文
posted @ 2013-05-16 16:52 践道者 阅读(187) 评论(0) 推荐(0) 编辑
摘要:function Cat(name, color){ this.name = name; this.color = color;}Cat.prototype.type = "猫科动物";Cat.prototype.eat = function(){ console.log("吃鱼吃老鼠");}var c1 = new Cat("Tom", "black");console.log(c1.type);c1.eat();//检测类与对象人性关系:isPrototypeOfCat.prototype.isPrototyp 阅读全文
posted @ 2013-05-16 16:20 践道者 阅读(161) 评论(0) 推荐(0) 编辑
摘要:function Shape(){ var init = function(){ } //模拟构造函数 init(); this.x = 1; //公有属性 this.y = 2; this.draw = function(){ console.log( this.x + this.y); }; //公有方法}var ashape = new Shape();console.log(ashape.x);ashape.draw();类属性\方法的定义:Shape.count = 10Shape.staticMethod = function(){} 阅读全文
posted @ 2013-05-16 13:56 践道者 阅读(161) 评论(0) 推荐(0) 编辑
摘要:var mongodb =require('mongodb');var server = new mongodb.Server('localhost', 27018, {auto_reconnect:true});var db = new mongodb.Db('mydb', server, {safe:true});db.open(function(err, db){ if(!err){ console.log('connect'); }else{ console.log(err); }}); 阅读全文
posted @ 2013-05-16 11:19 践道者 阅读(4450) 评论(1) 推荐(0) 编辑
摘要:发现debian不支持ll,在别的linux发行版几乎时刻在用这个命令,没有真不习惯,果断自己写个来实现它,顺便温习一下shell脚本非常简单,就那个几行#!/bin/basha=`pwd`if [ $# -eq 0 ]; then ls -l $aelse ls -l ${1}fipwd 获得当前目录$# 计算命令 行参数个数${0} 无参数则为当前执行文件名${1} 第一个参数写完后把当然文件ln -sf 到 /usr/bin/ll 就搞定了哈哈,其实根本不用写shell脚本,完全可以在 /etc/bashrc 文件里加一句 alias ll='ls -l' 搞定,就是给命 阅读全文
posted @ 2013-05-15 15:41 践道者 阅读(6212) 评论(0) 推荐(1) 编辑
摘要:最新做node.js server时发现windows下链接不了虚拟机的服务,网上一查,关闭iptables就行了chkconfig iptables off && service iptables stop 阅读全文
posted @ 2013-05-13 10:57 践道者 阅读(322) 评论(0) 推荐(0) 编辑
摘要:#coding=utf8class A(object): def __init__(self, name): self.name = name def __eq__(self, obj): return self.name == obj.nameif __name__ == '__main__': a = A("Leon") b = A("Leon") print a == b__eq__ 定义了类的等号(==)行为 阅读全文
posted @ 2013-05-08 16:56 践道者 阅读(12453) 评论(0) 推荐(0) 编辑
摘要:#!/bin/bashecho "What is your favourite OS?"select var in "Linux" "Gnu Hurd" "Free BSD" "Windows" "Other"; do break;doneecho "You have selected $var"ps :var=`date "+%Y%m%d %H%M%S"` 阅读全文
posted @ 2013-05-03 16:28 践道者 阅读(191) 评论(0) 推荐(0) 编辑
摘要:#!/bin/bashftype="$(file "$1")"case "$ftype" in"$1: Zip archive"*) unzip "$1";;"$1: gzip compressed"*) gunzip "$1";;"$1: bzip2 compressed"*) bunzip2 "$1";;*) echo "File $1 can not be uncompressed with smar 阅读全文
posted @ 2013-05-03 16:24 践道者 阅读(270) 评论(0) 推荐(0) 编辑
摘要:格式:if ....; then ....elif ....; then ....else ....fi[ -f "somefile" ] :判断是否是一个文件[ -x "/bin/ls" ] :判断/bin/ls是否存在并有可执行权限[ -n "$var" ] :判断$var变量是否有值[ "$a" = "$b" ] :判断$a和$b是否相等示例:#!/bin/bashif [ ${SHELL} = "/bin/bash" ]; then echo "your l 阅读全文
posted @ 2013-05-03 16:05 践道者 阅读(249) 评论(0) 推荐(0) 编辑
摘要:var_1=2var_2=3var_res="$[$var_1+$var_2]"echo $_var_res #print 5 阅读全文
posted @ 2013-05-03 15:57 践道者 阅读(156) 评论(0) 推荐(0) 编辑
摘要:#!/bin/bash#print hello world in the console windowa="Hello,World"echo "A is:" $a赋值符号左右两边不能有空格,否则语法错误。num=2echo "this is ${num}d"用{}将变量名括起来,起到确定变量名的作用获取命令行参数总数 $#后台执行,模拟多进程#!/bin/bashrsync .... &rsync .... &... 阅读全文
posted @ 2013-05-03 15:46 践道者 阅读(237) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示