Thursday, April 12, 2012

在App Engine上使用bottle框架

application: my-bottle-app\
version: 1
runtime: python
api_version: 1

handlers:
- url: /styles
static_dir: styles

- url: /.*
script: main.py

from framework import bottle
from framework.bottle import route, template, request, error, debug
from google.appengine.ext.webapp.util import run_wsgi_app

@route('/')
def DisplayForm():
message = 'Hello World'
output = template('templates/home', data = message)
return output

def main():
debug(True)
run_wsgi_app(bottle.default_app())

@error(403)
def Error403(code):
return 'Get your codes right dude, you caused some error!'

@error(404)
def Error404(code):
return 'Stop cowboy, what are you trying to find?'

if __name__=="__main__":
main()

Friday, April 6, 2012

批量下载某个网站 0001.jpg 到 0999.jpg 图片的shell脚本

for i in {1..999}; do curl -L -O http://baidu.com/images/pic_$(printf "%0.4d" $i).jpg; done

Monday, April 2, 2012

Linux版本Google Chrome更改字体方法

在Linux下的Google自然可以通过设置更改字体,不过不能选择像“sans-serif”,“monospace”这样的字体。

你需要用编辑器手工编辑 .config/google-chrome/Default/Preferences

"webkit": {
"webprefs": {
"global": {
"fixed_font_family": "monospace",
"sansserif_font_family": "sans-serif",
"serif_font_family": "serif",
"standard_font_family": "sans-serif"
},
"uses_universal_detector": true
}
}

dejavu是我一直使用的字体。

Wednesday, March 14, 2012

在哪里找Google Chrome播放的Flv缓存

这里只是 Linux上的方法

  1. 先找到PID
    ps ax | grep -i chrome | grep -i flash  

  2. 再找到文件
    file /proc/Flash_Plugin_PID/fd/* | grep -i deleted
    或者
    lsof -p Flash_plugin_pid | grep -i deleted

  3. 拷贝文件 /proc/[pid]/fd/[fileno] 到 recovered_file.flv

Monday, March 12, 2012

Telnet到AIX字符界面显示问题

先 [cci]export TERM=VT100[/cci] 再登录。
如果是SSH连接。[cci]export TERM=xterm[/cci]

Friday, March 9, 2012

KVM install windows 2003 guest


qemu-system-i386 -m 1024 -cdrom images/Windows\ Server\ 2003\ SP2.ISO -drive file=win2003.img,cache=writeback,boot=on -fda virtio-win-1.1.16.vfd -boot d -nographic -vnc :0


安装到提示重新启动的时候,必须去掉 boot=on,不然装不上,windows 2008没有这个问题。

Thursday, March 1, 2012

scp太慢了

在转移5G文件到新服务器时用scp只有60k,换用rsync+ssh,4M速度!
[cc]rsync -ave ssh greendome:/home/ftp/pub/ /home/ftp/pub/[/cc]

[cc]$ rsync -avz -e "ssh -i /home/thisuser/cron/thishost-rsync-key" remoteuser@remotehost:/remote/dir /this/dir/[cc]