正文内容加载中...
posted @ 2013-05-19 11:16 谷安 阅读(343) 评论(0) 推荐(0) 编辑
摘要:添加服务chkconfig vsftpd onchkconfig --list vsftpd2,3,4,5应该为on配置文件/etc/vsftpd/vsftpd.conf虚拟用户生成文本文件 logins.txtzhang3123456li4123456生成vsftpd认证文件db_load -T -t hash -f logins.txt /etc/vsftpd/vsftpd_login.db设置认证文件只对用户读写chmod 600 /etc/vsftp/vsftpd_login.db建立PAM生成vsftpd.vu文件 /etc/pam.d/vsftpd.vu#vsftpd_login 阅读全文
posted @ 2012-10-10 09:59 谷安 阅读(138) 评论(0) 推荐(0) 编辑
摘要:引用来自:http://stackoverflow.com/questions/472282/show-console-in-windows-application [DllImport("kernel32.dll", SetLastError = true)] static extern bool AllocConsole(); [DllImport("kernel32.dll", SetLastError = true)] static extern bool FreeConsole(); [DllImport("kernel32" 阅读全文
posted @ 2012-05-03 14:50 谷安 阅读(628) 评论(0) 推荐(0) 编辑
摘要:引用自:http://www.hanselman.com/blog/TheWeeklySourceCode31SingleInstanceWinFormsAndMicrosoftVisualBasicdll.aspxusing System;using System.Windows.Forms;using Microsoft.VisualBasic.ApplicationServices;namespace SuperSingleInstance{static class Program{[STAThread]static void Main(){Application.EnableVisua 阅读全文
posted @ 2012-04-25 22:17 谷安 阅读(268) 评论(0) 推荐(0) 编辑
摘要:通用模式# -*- coding: utf-8 -*-def mydecorator(function): def _mydecorator(*args, **kw): #在调用实际函数之前做些填充工作 res = function(*args, **kw) #做完填充后 return res #返回子函数 return _mydecoratordef mydecorator(arg1, arg2): def _mydecorator(function): def __mydecorator(*args, *kw): res = function(*args, **kw) return res 阅读全文
posted @ 2012-04-19 11:50 谷安 阅读(107) 评论(0) 推荐(0) 编辑
摘要:hosts = file('D:/Test.txt')try: for line in hosts: if line.startswith('#'): continue print linefinally: hosts.close()with:可不关闭,与C#中using 类似:with file('D:/Test.txt') as hosts: for line in hosts: if line.startswith('#'): continue print host要使用with,需要类实现 __enter__ 与 __ex 阅读全文
posted @ 2012-04-19 11:42 谷安 阅读(502) 评论(0) 推荐(0) 编辑
摘要:Example1:def fibonacci(): a, b = 0, 1 while True: print 'abc' yield b a, b = b, a+bfib = fibonacci()fib.next()[fib.next() for i in range(10)] #感觉这种写法很精妙Example 2: yield 作为表达式 Send 来填充 yield表达式,throw 抛出异常,close抛出GeneratorExit异常def psychologist(): print 'Please tell me your problems' w 阅读全文
posted @ 2012-04-09 16:24 谷安 阅读(126) 评论(0) 推荐(0) 编辑
摘要:class MyIterator(object): def __init__(self, step): self.step = step def next(self): if self.step == 0: raise StopIteration self.step -= 1 return self.step def __iter__(self): return self [el for el in MyIterator(4)] 阅读全文
posted @ 2012-04-09 11:23 谷安 阅读(223) 评论(0) 推荐(0) 编辑
摘要:seq = ['one', 'two', 'three']def FormatStr(pos, element): return '%d: %s' % (pos, element)[FormatStr(i, el) for i, el in enumerate(seq)] 阅读全文
posted @ 2012-04-09 10:30 谷安 阅读(131) 评论(0) 推荐(0) 编辑
摘要:>>> x = set('abcde')>>> y = set('bdxyz')>>> xset(['a', 'c', 'b', 'e', 'd']) # 2.6 display format>>> 'e' in x # MembershipTrue>>> x – y # Differenceset(['a', 'c', 'e']) 阅读全文
posted @ 2012-02-02 11:33 谷安 阅读(8240) 评论(0) 推荐(1) 编辑