Lisp

最近在用emacs,看了些lisp的东西 原来现代语言的很多特性最早是从lisp中来的 找到几篇很好的文章: 十年学会编程 Lisp之根源 1. 条件语句。当初的语言是没有if else的,goto统治世界。 2. 函数类型。函数成了语言里的类型,可以被变量指代,可以被当成参数传来传去(的一类公民的必要条件,参考SICP第一章)。这一条可以极大简化编程,让我们写出非常漂亮的程序。所以现在的流行语言纷纷加入了这个特性(可惜Java没有)。 3. 递归。这个不用说了吧。 4. 动态类型。smalltalk, python, ruby。。。连C#也有一个类似的var了。 5. 垃圾收集。不要以为GC是Smalltalk的发明哈,更不是Java的。 6. 基于表达式的编程。任何表达式都可以成为另一个表达式的一部分。不像很多语言,把表达和陈述分开。 7. 符号类型。这个在python和ruby里被采用,广受欢迎。 8. 代码即解析树。这个让LISP能方便地定义新的句法,操作程序本身,编写元程序,生成真正意义上的宏。 9. 语言无时不在。代码运行/解析可以在任何时候发生。这点和8.配合可以让语言的扩展和交流变得非常容易。 ...

June 9, 2009 · notsobad

php中的会话阻塞

php中exec, system调用其它脚本,脚本中又将一些脚本放入后台,可能会话会被挂起,也就是其它所有的请求都会被阻塞,点任何链接都没反应。 似乎与这个问题有关: What happens is that the child process which is called by the system() ,exec() or shell_exec() command holds the file lock on the parent process, thus locking the session file. Thus, the session file being locked session_start(); function cannot access the file. This is due to to open file descriptors locking the session file.Your entire session will be locked, so none of the pages of the website can be opened ( which are under session control ) unless you change the browser or delete cookies. ...

June 1, 2009 · notsobad

shell中01-20列表的创建

chinaunix上的一个帖子: http://bbs2.chinaunix.net/viewthread.php?tid=1443099&extra=&page=1 我要快速创建20个文件,test_01.txt。。。。test_20.txt, 01-20这个怎么处理,1..20只是1 2 3 4 5 6 7 。。。20,个位数的时候没有前面的0. 不符合要求。 请求高手指点。 下面是一些不同的做法 ...

May 3, 2009 · notsobad

笔记

我需要做一个页面保存的功能, 在服务端把页面整个wget保存下来。 由于服务端是有会话的,所以需要对本机的请求给自动通过,以前一直是用验证HTTP_HOST 是否为 localhost,这个方法有局限,今天想到可以这样 if($_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']){ //。。。。。。。 } 由于有些内容离线看是没有意义的,所以决定添加一些标记来标识离线时要删掉的内容 如下: ...

April 30, 2009 · notsobad

Debugging django

怎么调试django程序呢? models还好,可以在django shell中很方便的调试 而view中只能发送httpresponse对象到浏览器,print打印的东西不会在浏览器输出 找到了这篇文章 http://simonwillison.net/2008/May/22/debugging/ 收获: 如果用的是development server,print输出到了对应的terminal中 ...

April 30, 2009 · notsobad

Django 1.0 on GAE

在gae上用django1.0 gae的使用就不多说了,它使用的是django0.96,想用1.0需要用到zip import zip import http://code.google.com/intl/zh-CN/appengine/articles/django10_zipimport.html gae helper for django http://code.google.com/intl/zh-CN/appengine/articles/appengine_helper_for_django.html django on gae,已打包好 http://github.com/Surgo/django-on-gae/tree 照上面文章设置既可,最后可以使用django式的manger, url, shell等

April 30, 2009 · notsobad

我的定时脚本

高亮版本看[这里 ](http://not- sobad.appspot.com/show_code/?key=aglub3Qtc29iYWRyCwsSBENvZGUY8WAM)。 作用就是 11,15,18,20,23等几个时间点执行我的脚本。 #!/bin/sh #cron.sh #浪点空间不支持crontab #blog数据同步脚本需要每隔几个小时执行一次,所以自己写了一个简单的 #usage: #nohup cron.sh &>/dev/null & get_local_hour(){ if ! date|grep UTC >/dev/null;then date +%H return 0 fi d=$(expr `date +%H` + 8) if [ $d -gt 24 ];then d=$(expr $d - 24) fi echo $d } cd $HOME/script || exit 1 while [ 1 ];do if ( (echo 11,15,18,20,23 | grep `get_local_hour` >/dev/null ) );then [ -s .rpc_end_link -a -f wp.py ] || exit 2 python wp.py 2>&1 >wp.log fi sleep 3600 done exit 0 后记:白忙了,还不如这样搞。 ...

April 30, 2009 · notsobad

Notsobad.cn is coming back

notsobad.cn,又回来了,希望这次可以做好 买的是浪点带shell的linux空间 接下来要做的事: 将code snipper从gae移到这里来 经常的更新blog 用django作一些小工具 wordpress的自动更新脚本: #!/bin/sh # update my blog from svn, and get the language pack blog=notsobad.cn/public_html/blog/ (cd $blog; svn up) ( cd $blog/wp-includes/languages/; rm zh_CN.*; wget http://svn.automattic.com/wordpress-i18n/zh_CN/tags/2.7/messages/zh_CN.mo; wget http://svn.automattic.com/wordpress-i18n/zh_CN/tags/2.7/messages/zh_CN.po; )

April 27, 2009 · notsobad