用gnome-web-photo进行网页截屏

参考下这里: http://ubuntuforums.org/showthread.php?t=1085872 还有这里: [http://groups.google.com/group/python- cn/browse_thread/thread/f25350d5e4d415af/08140024364b819d?lnk=gst&q;=html#](http://groups.google.com/group/python- cn/browse_thread/thread/f25350d5e4d415af/08140024364b819d?lnk=gst&q=html#) 使用gnome-web-photo进行网页截屏,效果相当好,不过保存为jpg格式失败了 514 ~/script/sh>gnome-web-photo --format "png" http://blog.notsobad.cn blog.png Registering '@mozilla.org/module-loader/python;1' (libpyloader.so) Registering '@mozilla.org/network/protocol/about;1?what=python' (pyabout.py) 515 ~/script/sh>animate blog.png 516 ~/script/sh>gnome-web-photo --mode=photo --format "jpeg" http://blog.notsobad.cn blog.jpg Registering '@mozilla.org/module-loader/python;1' (libpyloader.so) Registering '@mozilla.org/network/protocol/about;1?what=python' (pyabout.py) JPEG parameter struct mismatch: library thinks size is 372, caller expects 356

August 3, 2009 · notsobad

python实现一个strip_tags和unicode笔记

python实现一个strip_tags, 去处html标记 from HTMLParser import HTMLParser def strip_tags(html): result = [] parser = HTMLParser() parser.handle_data = result.append parser.feed(html) parser.close() return ''.join(result) 关于unicode: 参考这里 http://evanjones.ca/python-utf8.html 总结:出现编码错误时,用type检查变量的类型,容易找出问题,print是不行的 unicote <--> str, 互相转换 In [28]: a=‘a’ In [29]: type a -——> type(a) Out[29]: In [30]: b=unicode(a, ‘utf-8’) In [31]: type b -——> type(b) Out[31]: In [32]: b.decode(‘utf-8’) Out[32]: u’a’ In [33]: b.encode(‘utf-8’) Out[33]: ‘a’ ...

August 3, 2009 · notsobad

Lilei和Hanmeimei的欲望人生

也许这就是我们的人生路吧 Lilei和Hanmeimei的欲望人生 一个豆瓣小组: 李雷都这么牛逼了韩梅梅却不喜欢他

August 2, 2009 · notsobad

今天的事

今天石家庄了 去时坐上了传说当中的CRH和谐号,果然很不错,座椅和飞机上的座椅很像,在车上一会就睡着了,这是我第一次能这么快在火车上睡着。2个小时就到了石家庄 回来时就惨了,买了无座的T5686,春运是的噩梦又一次上演了,可能因为是双层的车,中间是上下的楼梯,所以看不到里面的情况,导致人都堵在两边的过道里了。 上一次做硬座就发誓再也不座这个了,没想到今天又给来了一次。 ...

August 2, 2009 · notsobad

grep查找进程存在与否

linux下查看进程存不存在: 517 ~>ps -elf|grep -w ‘cron’|grep -v grep 5 S root 3179 1 0 80 0 - 925 hrtime 09:02 ? 00:00:00 /usr/sbin/cron 下面这个比较巧妙: 518 ~>ps -efl|grep -w [c]ron 5 S root 3179 1 0 80 0 - 925 hrtime 09:02 ? 00:00:00 /usr/sbin/cron ps时会出现grep这个进程,看下面的: 1: grep cron => “grep cron” 2: grep [c]ron => “grep [c]ron” 但是grep cron 和 grep [c]ron 的实际效果都是查找cron这个字符串 很明显的只有1的时候会把grep本身给找出来。 ...

July 31, 2009 · notsobad

prototype's getElementsByClassName

一个有意思的问题 http://ejohn.org/blog/getelementsbyclassname-pre-prototype-16/ prototype有一个getElementsByClassName的方法,添加在document对象上 他们是这样做的 if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){ // ... }; 上面的代码实际上还给返回的数组添加了新的方法,如.each, 我们可能这样用 document.getElementsByClassName("monkey").each(Element.hide); 但是Firefox3和Safari 3.1出来后,这几个浏览器本身支持getElementsByClassName方法,也是在document上,然后问题来了。 浏览器自身的document.getElementsByClassName(“monkey”) 是没有.each方法的,一个bug出现了 ...

July 31, 2009 · notsobad

imagemagick

imagemagick实在是太庞大了,想要全部搞懂看来不现实。 这里是它的实例页面,内容应该够一本上千页的书了。 http://imagemagick.org/Usage/ 内容包含基本绘图、图像处理、组合、变形、动画,我能用到的也许不到千分之一吧

July 29, 2009 · notsobad

passwd cmd in shell script

批量增加用户,设置密码,用shell来实现 要先确认你的passwd支持“–stdin”参数 参考这里 <http://stackoverflow.com/questions/714915/using-the-passwd-command-from- within-a-shell-script> from “man 1 passwd”: --stdin This option is used to indicate that passwd should read the new password from standard input, which can be a pipe. So in your case adduser “$1” echo “$2” | passwd “$1” –stdin [Update] a few issues were brought up in the comments: Your passwd command may not have a –stdin option: use the chpasswd utility instead, as suggested by ashawley. If you use a shell other than bash, “echo” might not be a builtin command, and the shell will call /bin/echo. This is insecure because the password will show up in the process table and can be seen with tools like ps. In this case, you should use another scripting language. Here is an example in Perl: #!/usr/bin/perl -w open my $pipe, ‘|chpasswd’ or die “can’t open pipe: $!”; print {$pipe} “$username:$password”; close $pipe ...

July 29, 2009 · notsobad

sh, bash, dash

ubuntu下的sh是到dash(the Debian Almquist Shell)的链接 原因参考这里 https://wiki.ubuntu.com/DashAsBinSh 502 ~>ls /bin/bash -l -rwxr-xr-x 1 root root 729040 2009-03-02 22:22 /bin/bash 503 ~>ls /bin/sh -l lrwxrwxrwx 1 root root 4 2008-11-05 02:05 /bin/sh -> dash 504 ~>ls /bin/dash -l -rwxr-xr-x 1 root root 87924 2008-11-05 15:51 /bin/dash 505 ~>echo $SHELL /bin/bash 以前以为sh就是到/bin/bash的链接,昨天就遇到了问题 The Debian policy manual has long mandated that “shell scripts specifying ‘/bin/sh’ as interpreter must only use POSIX features”; in fact, this requirement has been in place since well before the inception of the Ubuntu project. Furthermore, any shell scripts that expected to be portable to other Unix systems, such as the BSDs or Solaris, already honoured this requirement. Thus, we felt that the compatibility impact of this change would be minimal. ...

July 29, 2009 · notsobad

heredoc in shell

heredoc 参考下面几个链接 http://en.wikipedia.org/wiki/Here_document http://tldp.org/LDP/abs/html/here-docs.html $ cat « EOF > Working dir $PWD > EOF Working dir /home/user 不解释变量 $ cat « “EOF” > Working dir $PWD > EOF Working dir $PWD 创建脚本的脚本 #!/bin/bash OUTFILE=generated.sh # Name of the file to generate. ( cat «‘EOF’ #!/bin/bash echo “This is a generated shell script.” # Note that since we are inside a subshell, #+ we can’t access variables in the “outside” script. echo “Generated file will be named: $OUTFILE” a=7 b=3 let “c = $a * $b” echo “c = $c” exit 0 EOF ) > $OUTFILE if [ -f “$OUTFILE” ] then chmod 755 $OUTFILE else echo “Problem in creating file: "$OUTFILE"” fi exit 0 ...

July 28, 2009 · notsobad