2008/09/26

第一个python程序

# search IMDB TOP 250 in VeryCD 
# Author: chenqian
# URL: www.stopdesign.cn

import urllib2
from BeautifulSoup import BeautifulSoup

page = urllib2.urlopen("http://www.imdb.com/chart/top")
soup = BeautifulSoup(page.read())
div=soup("table")[11]
vcurl=''
for i in div:
movies = i.contents[2].contents[0].contents[0].contents[0]
#print movies
vcurl+="<a href='http://www.verycd.com/search/folders/"+movies+"'>"+movies+"</a><br />\n"
# age print i.contents[2].contents[0].contents[1]

filename = "top250.html"
file = open(filename, 'w')
file.write(vcurl)
file.close()

用到了beautiful soup,结果在:top250.html

Labels:

2008/09/23

一些有用的快捷键

在终端中:
CTRL + A — 移动到行首
CTRL + E — 移动到行末
CTRL + U — 清除全行
CTRL + B — 向后移动一字符
CTRL + F — 向前移动一字符
CTRL + H — 删除一字符,和delete一样
CTRL + W — 删除最后输入的单词
CTRL + C — 撤销运行中命令
CTRL + D — 退出当前会话
之前还老问KFF怎么移动到行首,被告知可以 fn+shift+左/右,今天看到更快捷的方式,原来 CTRL+C 是有一系列。UNIX 真的很有趣,时不时地 man 会发现许多神奇的东西,包括有时 man man 本身。而当你发现一个东西好用之后,就越发想用它来做更多事情,极致就是完全用键盘工作了。
另外:
fn+上/下/左/右—page up/page down/home/end

Labels: , ,

2008/09/16

一款新出的可用性测试软件

sliverback来自 clearleft 新推出的 silverback,除了录制用户的操作,同时会在屏幕中显示用户使用过程的录像,跟我们在一般的用户测试录像中看到的一样。
优点:简洁,捕捉鼠标、键盘操作;
缺点:Mac-only,用户录像窗口不能设置大小,不能针对某个窗口录制,只能导出mov格式。

Labels: ,

2008/09/14

网站需要在所有的浏览器中看起来都一模一样吗?

do websites need to look exactly the same in every browser?

Labels:

2008/09/10

一篇很长的演讲稿


http://www.cooper.com/journal/agile2008/

2008/09/01

收到书了

收到了蓝色理想寄过来的 flex 书,书已是伤痕累累…
代码部分:
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BitmapFilterType;
import flash.filters.GradientBevelFilter;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.display.Sprite;
stage.scaleMode = StageScaleMode.NO_SCALE;
var url:String = "sound.mp3";
var request:URLRequest = new URLRequest(url);
var s:Sound = new Sound();
s.addEventListener(ProgressEvent.PROGRESS, progressHandler);
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(request);
var song:SoundChannel = s.play();
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();
var gr:Sprite = new Sprite();
gr.x = 20;
gr.y = 200;
addChild(gr);
/*
var bgColor:uint = 0xCCCCCC;
var size:uint = 80;
var offset:uint = 50;
var distance:Number = 5;
var angleInDegrees:Number = 225; // opposite 45 degrees
var colors:Array = [0xFF0000, 0xFFFFFF, 0x000000];
var alphas:Array = [1, 0, 1];
var ratios:Array = [0, 128, 255];
var blurX:Number = 8;
var blurY:Number = 8;
var strength:Number = 2;
var quality:Number = BitmapFilterQuality.HIGH
var type:String = BitmapFilterType.INNER;
var knockout:Boolean = true;
var filter:BitmapFilter=new GradientBevelFilter(distance,
angleInDegrees,
colors,
alphas,
ratios,
blurX,
blurY,
strength,
quality,
type,
knockout);
*/
var bgColor:uint = 0xCCCCCC;
var size:uint = 80;
var offset:uint = 50;
var distance:Number = 0;
var angleInDegrees:Number = 45;
var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF];
var alphas:Array = [0, 1, 1, 1];
var ratios:Array = [0, 63, 126, 255];
var blurX:Number = 50;
var blurY:Number = 50;
var strength:Number = 2.5;
var quality:Number = BitmapFilterQuality.HIGH;
var type:String = BitmapFilterType.OUTER;
var knockout:Boolean = false;
var filter:BitmapFilter=new GradientGlowFilter(distance,
angleInDegrees,
colors,
alphas,
ratios,
blurX,
blurY,
strength,
quality,
type,
knockout);

var farr:Array=new Array();
farr.push(filter);
var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();
function createTextField(x:Number, y:Number, width:Number, height:Number):TextField {
var result:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0xFF0000;
format.size = 10;
result.defaultTextFormat = format;
result.x = x;
result.y = y;
result.width = width;
result.height = height;
addChild(result);
return result;
}
var loading:TextField = createTextField(0, 20, 200, 20);
var loadstr:String;
function progressHandler(event:ProgressEvent):void {
loadstr=String(Math.floor((event.bytesLoaded/event.bytesTotal)*100));
loading.text=loadstr;
trace(loadstr);
//trace(" bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
}
function completeHandler(event:Event):void {
//loading.visible=false;
//s.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
event.target.play();
}
function soundCompleteHandler(event:Event):void {
time.stop();
}
function timerHandler(event:TimerEvent):void {
SoundMixer.computeSpectrum(ba, true);
var i:int;
gr.graphics.clear();
gr.graphics.lineStyle(0, 0xFFFFFF);
gr.graphics.beginFill(0xFFFFFF);
gr.graphics.moveTo(0, 0);
var w:uint = 2;
for (i=0; i<512; i+=w) {
var t:Number = ba.readFloat();
var n:Number = (t * 100);
gr.graphics.drawRect(i, 0, w, -n);
gr.filters=farr;
}
}