男单 618

生活象筒装的卫生纸,开始的时候怎么扯都不觉得在转,后来转的越来越快。

Google Reader可以订阅任何网页——好消息?坏消息?

without comments

之前,对于没有提供RSS输出的网站,我一直使用Page2RSS订阅网页的更新,现在Google Reader直接提供了这一功能。应该说是好消息,但是谁知道呢。

Written by amao

2010/01/26 at 22:03

Posted in 软件

Tagged with

Sage绘制摆线动画

without comments

在Sage中绘制动画,实际上是先画出每一帧,再使用imagemagick将多幅图像转化为gif动画。先来看一个简单例子:

t,u=var(‘t,u’)
cc=[point((cos(t),sin(t)),pointsize=30,rgbcolor='red')+parametric_plot((cos(u),sin(u)),(0,t)) for t in srange(0.01,2*pi,0.2)]
myan=animate(cc,xmin=-1.5, xmax=1.5,ymin=-1.5, ymax=1.5,aspect_ratio=1)
show(myan)

第2行中每帧图像由两部分组成,一是动点,二是圆弧。这里,srange函数中的初值不能取零,否则会出错。第3行中将绘图的坐标范围固定,如果不固定,Sage会将当前图像主体放置在图像中央,自动调整坐标轴的显示范围。这一特性在绘制静态图像时,非常有用,但这样得到的动画往往不是我们想要的。

下面来看圆摆线x=a*(u-sin(u)), y=a*(1-cos(u)),  0<u<2*pi的绘制:

u=var(‘u’)
a=2
pic=[parametric_plot((a*(u-sin(u)),a*(1-cos(u))),(u,0,t),rgbcolor='red')\
+circle((a*t,a),a,rgbcolor='blue')\
+point((a*(t-sin(t)),a*(1-cos(t))),pointsize=20,rgbcolor='red')\
+line([(a*t,a),(a*(t-sin(t)),a*(1-cos(t)))],rgbcolor=’blue’) for t in srange(0.01,2*pi+0.1,0.2)]
bbb=animate(pic,xmin=-0.5,xmax=(2*pi+1)*a,ymin=-1, ymax=2*a+1,aspect_ratio=1)
show(bbb)

注:其他一些数学软件绘图时,如果不手工清除绘图区域,则上一个图像会保留下来,这与Sage的工作方式不同。Sage中的每一帧都是“全新”绘制的。

下面将其转化为交互式的图形:

@interact
def _(t=(0.01,2*pi,0.5)):
u=var(‘u’)
a=2
pic=parametric_plot((a*(u-sin(u)),a*(1-cos(u))),(u,0,t),rgbcolor=’red’)\
+circle((a*t,a),a,rgbcolor=’blue’)\
+point((a*(t-sin(t)),a*(1-cos(t))),pointsize=20,rgbcolor=’red’)\
+line([(a*t,a),(a*(t-sin(t)),a*(1-cos(t)))],rgbcolor=’blue’)
show(pic,xmin=-0.5,xmax=(2*pi+1)*a,ymin=-1, ymax=2*a+1,aspect_ratio=1)

由于刷新的问题,更新不连贯,拖放之后,需要等一下。

Written by amao

2010/01/21 at 22:23

Posted in sage

Tagged with

24-第8季

without comments

明天,期待。

Written by amao

2010/01/17 at 17:24

Posted in 其他

Tagged with

Mysql乱码问题(备忘)

without comments

升级网站的时候,php版本高了,mysql的版本也高了,再加上原来没经验,用的都是GBK,没用UTF8,数据库导过去经常乱码。
两次成功的经验如下。
先保证phpmyadmin中看到的字符是正确的,再在mysql_connect语句之后加一句mysql_query(“SET NAMES ‘GBK’”),差不多就可以了。

Written by amao

2010/01/16 at 1:52

Posted in linux, 软件

8310一周年

without comments

准确的说是1月11日,那天还看了阿凡达。

作为手机,满意。作为PDA,远不如Palm系列。

Written by amao

2010/01/15 at 20:52

Posted in 其他

Tagged with ,

使用Sage绘制动画的一个例子

without comments

先把代码放在这里,有时间再解释:

t,u=var(‘t,u’)
cc=[point((cos(t),sin(t)),pointsize=30,rgbcolor='red')+parametric_plot((cos(u),sin(u)),(0,t)) for t in srange(0.01,2*pi,0.2)]
myan=animate(cc,xmin=-1.5, xmax=1.5,ymin=-1.5, ymax=1.5)
show(myan)

Written by amao

2010/01/15 at 1:29

Posted in sage

Tagged with

Sage Tutorial中文版

with one comment

Sage Tutorial是一份快速了解Sage的入门文档,花了两周多的时间将其翻译为中文。但是“Some more advanced mathematics”一节没有翻译,因为完全不熟悉这一节所涉及到的内容。

第一次翻译开源软件的技术文档,水平有限,希望各位多提意见,任何方面的都可以。如果没有大的问题,大概一周后会向Sage开发组提交。

源文件使用Sphinx管理,PDF文件是由自动转换而来的LaTeX文件编译的,因此其中很多格式不符合中文的习惯。所以请大家先以HTML文件为准,最后发布前,我会手工调整LaTeX文件后再编译。

Email: amao@ai7.org

相关内容:翻译Sage文档的准备工作

Sage Tutorial 中文版rst源文件

Sage Tutorial 中文版(HTML)

Sage Tutorial 中文版(PDF)

Written by amao

2010/01/09 at 10:43

Posted in linux, python, sage

Tagged with ,

Ubuntu 9.10下unzip的乱码问题

without comments

Ubuntu 9.10中unzip升级为6.0,结果原来的-O参数没有了,解压缩Win平台来的带中文文件名的文件时,会有乱码。Google,Baidu无果后,自行使用Python解决。

01 #!/usr/bin/python
02 #coding=utf8
03
04 import zipfile
05 import sys
06
07 if len(sys.argv)<2:
08     print u’punzip zipfilename’
09 else:
10     f=zipfile.ZipFile(sys.argv[1])
11     nlist=f.namelist()
12     for n in nlist:
13         m=unicode(n,’gb2312′).encode(‘utf8′)
14         file(m,’wb’).write(f.read(n))
15     f.close()

只有基本功能,解压缩到当前目录下,不能新建目录……
请自行修改。

Written by amao

2010/01/01 at 17:56

Posted in linux, python

Tagged with ,

新蛋的推荐系统真猛

without comments

卖清洁液推荐X200……

Written by amao

2009/12/30 at 21:30

Posted in 其他

Tagged with

关于7天连锁酒店

without comments

下午在公交车上看到7天连锁酒店一家分店打出的条幅说,7天已在钮约证交所上市,刚才就看到这篇文章:天天睡好觉:7天连锁酒店的“加减法”。
不是会员,也没有住过7天,有机会考虑尝试一下。

Written by amao

2009/12/27 at 23:23

Posted in 其他

Tagged with