环境说明:swift服务端安装在UBUNTU12.04LTS,我要从办公系统windows xp机器访问该存储系统。
下载最新版本cyberduck: http://cyberduck.ch/
配置swift为HTTPS连接方式:
首先去swift-proxy服务端,修改配置文件:
/etc/swift/proxy-server.conf
[DEFAULT] bind_port = 443 bind_ip = 172.16.6.100 cert_file = /etc/swift/cert.crt key_file = /etc/swift/cert.key log_level = DEBUG log_facility = LOG_LOCAL1 user = swift [pipeline:main] pipeline = healthcheck cache tempauth proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management= ture account_autocreate = true [filter:tempauth] use = egg:swift#tempauth user_admin_admin = admin .admin .reseller_admin user_test_tester = testing .admin user_test2_tester2 = testing2 .admin user_test_tester3 = testing3 [filter:healthcheck] use = egg:swift#healthcheck [filter:cache] use = egg:swift#memcache memcache_servers = 172.16.6.100:11211
以上加粗的地方是修改的配置,主要是把原来未做HTTPS的改成HTTPS,端口改为了443。
接下来创建数字证书:
cd /etc/swift
openssl req -new -x509 -nodes -out cert.crt -keyout cert.key
确保IPtables打开了443的访问权限,这里略去。
重启swift-proxy服务:
swift-init proxy restart
接下来,在客户端进行配置:
修改CyberDuck默认的一个访问地址: 在windows下打开文件:
C:\Documents and Settings\yourname\Application Data\Cyberduck\Cyberduck.exe_Url_2lo40rrsb1ocwd4jaezr0bb42ppyulnb\4.2.1.9350\user.config
以上距离路径以实际为准。
添加一个属性:<setting name="cf.authentication.context" value="/auth/v1.0" /> 到setting内。
打开cyberDuck,创建一个新连接:

连接,访问即可。
为了尝试一下IPython的使用,今天折腾了很久的从安装包msi文件安装,最后无法成功运行,无奈在可以连外网的机器windows7 64bit环境,重新安装了一次,为了避免后来人少走弯路,记录安装过程(前提是已经安装了官方的Python环境):
- 由于是64bit环境的,官方提示最好是从源代码安装,所以首先安装官方的步骤,安装setuptools:
参照页面:http://pypi.python.org/pypi/setuptools,自己选择是32bit还是64bit的windows,这里我下载ez_setup.py,运行之后setuptools自动安装好了。 - 下载IPython最新的源代码包,并解压到本地磁盘。下载地址:https://github.com/ipython/ipython/downloads
- 进入cmd,进入解压后的源代码目录,执行命令:python setupegg.py install
- 执行后,可以看到提示安装成功。IPython会安装到你的Python目录下的scripts下面,我本地是C:\Python27\Scripts\IPython.exe
- IPython推荐安装readline,下面安装readline。 同样的去 https://launchpad.net/pyreadline/+download 下载readline源码包,解压后进入源码目录,执行python setup.py install 安装。
- 最后,为了方便,把IPython的目录加入path环境变量。
转载本文,请注明来自:http://www.cnblogs.com/helloLinux/archive/2011/09/27/2193457.html
关于Varnish Cache
Varnish Cache是一个web加速软件,用作web服务加速的反向代理,与Squid不同的是它建立在较新的系统内核调用上,并且主要是使用内存作为缓存,它现有的使用者有facebook等,据使用者反馈,其与Squid相比,相同的访问量下连接数大大减少。
本人测试过程
- 准备一个普通的HTTP web服务器,我在虚拟机内启动了一个Linux+Apache+MySQL+Php环境,配置文件未改动,下载一个PHPWind 的bbs程序拿来测试。
- 在另外一个服务器上编译安装Varnish 3.0(IP:192.168.159.5),默认安装路径,安装过程可参考官方文档。
- 编辑Varnish的默认配置文件(/usr/local/etc/varnish/default.vcl):
varnish ACL配置文件
#首先设置一个后端服务器 backend default { .host = "192.168.159.11"; .port = "80"; } sub vcl_recv { if (req.restarts == 0) { if (req.http.x-forwarded-for) { set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip; } else { set req.http.X-Forwarded-For = client.ip; } } #把除了以下这些类型请求以外的访问请求全部直接管道发送到后端的服务器 if (req.request != "GET" && req.request != "HEAD" && req.request != "PUT" && req.request != "POST" && req.request != "TRACE" && req.request != "OPTIONS" && req.request != "DELETE") { /* Non-RFC2616 or CONNECT which is weird. */ return (pipe); } #只有GET与HEAD方法才会使用Lookup,使用缓存。 if (req.request != "GET" && req.request != "HEAD") { /* We only deal with GET and HEAD by default */ return (pass); } # if (req.http.Authorization || req.http.Cookie) { # /* Not cacheable by default */ # return (pass); # } #如果请求的是php页面直接转发到后端服务器 if (req.url ~ "\.(php|cgi)($|\?)") { return (pass); } return (lookup); } sub vcl_pipe { return (pipe); } sub vcl_pass { return (pass); } sub vcl_hash { hash_data(req.url); if (req.http.host) { hash_data(req.http.host); } else { hash_data(server.ip); } return (hash); } sub vcl_hit { return (deliver); } sub vcl_miss { return (fetch); } sub vcl_fetch { if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == "*") { /* * Mark as "Hit-For-Pass" for the next 2 minutes */ set beresp.ttl = 120 s; return (hit_for_pass); } if (req.url ~ "\.(png|gif|jpg)$") { unset beresp.http.set-cookie; set beresp.ttl = 1h; } #设置图片的缓存TTL为一小时 return (deliver); } sub vcl_deliver { return (deliver); } sub vcl_error { set obj.http.Content-Type = "text/html; charset=utf-8"; set obj.http.Retry-After = "5"; synthetic {" <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>"} + obj.status + " " + obj.response + {"</title> </head> <body> <h1>Error "} + obj.status + " " + obj.response + {"</h1> <p>"} + obj.response + {"</p> <h3>Guru Meditation:</h3> <p>XID: "} + req.xid + {"</p> <hr> <p>Varnish cache server</p> </body> </html> "}; return (deliver); } sub vcl_init { return (ok); } sub vcl_fini { return (ok); } # - 添加Varnishd进程用户www,用户组www,创建/var/vcache目录,使www用户有权限可读写。
groupadd www useradd www -g www mkdir /var/vcache chown -R www:www /var/vcache chmod -R 750 /var/vcache
- 编辑/etc/sysctl.conf 优化几个内核参数:
net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1
运行sysctl -p 重新按配置文件设置内核参数。
- 启动Varnishd
varnishd -a 0.0.0.0:80 -f /usr/local/etc/varnish/default.vcl -T 127.0.0.1:2000 -s file,/var/vcache/,1G -u www
参数说明:-f指定了配置文件,-T是指定命令行管理界面监听地址,-s file指定了使用文件做缓存,1G是缓存文件大小,-u就是进程的用户了。
- 在客户端访问http://192.168.159.5/phpwind ,高频率刷新页面观察varnishd一端netstat -n输出,可以发现Varnish端到后端(apache)的TCP连接几乎一闪而过,很快就释放掉。
- 解决后端服务器不能日志记录真实访问者IP的问题,修改apache日志格式。
LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" varnish_combined
之后修改Apache的虚拟主机日志格式或者默认日志格式为 varnish_combined.
点击这里联系作者,转载请注明来自:http://www.cnblogs.com/helloLinux/archive/2011/08/17/2142822.html
新个税计算器(Python):一个极其简单,也没有做任何排错处理的初学脚本,发上来只是为了大家可以增加自己的代码丰富它。
点这里下载:NewTax.zip
2 #This script is using in MIC only,Powered by rexchenhan
3 #养老保险公司比例
4 EI_CoRate=0.323
5 #养老保险个人比例
6 EI_EmpRate=0.11
7 #公积金公司比例
8 HF_CoRate=0.1
9 #公积金个人比例
10 HF_EmpRate=0.1
11 #个税起征点
12 Threshold=3500
13
14 Emp_Salary=input ('请输入你的税前薪水:')
15 #Start to calculate
16 EI_Emp=Emp_Salary*EI_EmpRate+10
17 EI_Co=Emp_Salary*EI_CoRate
18 HF_Emp=Emp_Salary*HF_EmpRate
19 HF_Co=Emp_Salary*HF_CoRate
20 Emp_Sal_Before_Tax=Emp_Salary-(HF_Emp+EI_Emp)
21 Sal_NeedTax=Emp_Sal_Before_Tax-Threshold
22 Tax=0.0
23 Final_Cash=0.0
24 #calculate TAX
25 if Sal_NeedTax<=0:
26 Tax=0.0
27 elif Sal_NeedTax<1500:
28 Tax=Sal_NeedTax*0.03
29 elif Sal_NeedTax<4500:
30 Tax=Sal_NeedTax*0.1
31 elif Sal_NeedTax<9000:
32 Tax=Sal_NeedTax*0.2
33 elif Sal_NeedTax<35000:
34 Tax=Sal_NeedTax*0.25
35 elif Sal_NeedTax<55000:
36 Tax=Sal_NeedTax*0.3
37 elif Sal_NeedTax<80000:
38 Tax=Sal_NeedTax*0.35
39 else:Tax=Sal_NeedTax*0.45
40
41 Final_Cash=Emp_Sal_Before_Tax-Tax
42 #Start to print the result
43 Str1='住房公积金缴纳:个人承担:%6.1f 公司承担:%6.1f' % (HF_Emp,HF_Co)
44 Str2='养老保险金缴纳:个人承担:%6.1f 公司承担:%6.1f' % (EI_Emp,EI_Co)
45 Str3='扣除各类保险后,需缴税部分:%6.1f' % Emp_Sal_Before_Tax
46 Str4='您需要缴税:%6.1f' % Tax
47 Str5='您的最终收入:%6.1f' % Final_Cash
48 print '*'*60
49 print Str1
50 print Str2
51 print Str3
52 print Str4
53 print Str5

