Archive for 2008
Emacs org-mode的相关链接
Using Emacs org-mode for GTD
http://members.optusnet.com.au/~charles57/GTD/orgmode.html
David O’Toole Org tutorial
http://orgmode.org/worg/org-tutorials/orgtutorial_dto.php
Get Organized with Emacs Org-mode
http://www.linuxjournal.com/article/9116
到底啥才是Type Safety呢
水木的FuncProgram上最近为这个问题引发了一场大水(其实也不大,在那个版上算比较大了 XD),里面有一个很不错的引用,现摘录如下: Read the rest of this entry »
OSDI 08 – CHESS
Finding and Reproducing Heisenbugs in Concurrent Programs
OSDI ’08上微软研究院发的paper,针对并发编程中难以发现的bug问题。
paper的内容主要分两大块。
一是如何在发现bug的时候记录下线程的运行先后(thread interleaving),途径是在线程API和用户程序多写一层wrapper functions,这里还有一些其他的问题,比如只记录下了thread interleaving的话出现data race怎么解决等。
另外一块内容是如何遍历出给定程序运行后所能产生的结果的集合,加入这个能实现的话那就能把所有隐藏的bug都找出来了。但是这个搜索空间很大,是指数级的,的一个结论就是:给定一个程序有n个的线程,所有线程共完成k条指令,那么c次占先调度后线程的排列情况数的复杂度是$$k^{c}$$的,所以在实现遍历代码的时候必须有效的降低k和c的值。
mimeTeX for WordPress
mimeTeX是生成LaTeX图片/ASCII的一个程序,主要用于web
http://www.forkosh.com/mimetex.html
安装很方便,下载程序编译后放到web服务器的cgi-bin目录下就行了。
演示网页
http://www.forkosh.dreamhost.com/source_mimetex.html#preview
偶也装了一个,校内可以通过http://10.132.140.73/cgi-bin/mimetex.cgi访问,以Euler’s identity为例
另外也可以生成ASCII,不过不知道是否支持生成带ANSI颜色的文本,可能要根据它给出的colormap写个脚本转换下
然后有这么个支持在WordPress中直接写LaTeX代码,并在后台自动转成访问mimeTeX服务的图片的插件
http://wordpress.org/extend/plugins/latex/
$$Hello \LaTeX$$
beamer中使用listings包
使用frame时会出错,看到两种解决方案
1
frame{ % 需要修改这一行,加上参数'[containsverbatim]'
frametitle{The --help Option}
begin{itemize}
item Displays usage summary and argument list
item Used by most, but not all, commands\
begin{lstlisting}
test
end{lstlisting}
end{itemize}
}
2
使用begin{frame}[fragile]
Daily Notes on Python[11.17-11.23]
模块动态加载机制
1. Advanced Python(某一期Google TechTalks的话题)上提到import指令本质是个语法糖,import sys等价于sys = __import__(“sys”)。解析import sys的bytecode可以看到四个指令(参数略):
LOAD_CONST
LOAD_CONST
IMPORT_NAME
STORE_NAME
IMPORT_NAME把sys模块导入并保存到栈上,STORE_NAME把这个指针当作普通对象保存在sys这个变量中。
2. IMPORT_NAME指令行为分析
将参数打包并用PyEval_CallObject()这个统一调用接口运行__import__方法,bltinmodule.c中的builtin__import__函数包装了这个功能。help(__import__)显示的__import__方法的参数列表
__import__(…)
__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module
对应于builtin__import__中调用的另一层函数封装
PyObject *
PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals,
PyObject *fromlist, int level)
这个函数调用了真正干活的函数,import.c中的
static PyObject *
import_module_level(char *name, PyObject *globals, PyObject *locals,
PyObject *fromlist, int level)
3. import_module_level函数
首先调用get_parent()得到import发生时的package对象,接下来多次调用load_next依次得到各级的包名,跟踪了下import xml.dom.minidom的行为,发现name的值依次是”dom.minidom”, “minidom”。最后根据import的形式是from … import …还是import …返回不同的处理结果。
4. import_submodule函数
load_next函数中调用这个函数进行模块的查找和载入。主要分三步:find_module, load_module, add_submodule。
5. from … import …
ensure_fromlist处理了这个情况。另外对于from … import *的情况,会从module文件中读入一个__all__对象,从中知道module公开的符号信息。
几个以后可能用到的函数:
[import.c]
/* Parse a source file and return the corresponding code object */
static PyCodeObject * parse_source_module(const char *pathname, FILE *fp);
/* Execute a code object in a module and return the module object
* WITH INCREMENTED REFERENCE COUNT. If an error occurs, name is
* removed from sys.modules, to avoid leaving damaged module objects
* in sys.modules. The caller may wish to restore the original
* module object (if any) in this case; PyImport_ReloadModule is an
* example.
*/
PyObject * PyImport_ExecCodeModule(char *name, PyObject *co);
pyxpcomext
About the Python Extension (pythonext)
This project provides Python Mozilla bindings that enables Python to be used inside of Mozilla applications. The Python bindings are wrapped up in an extension (XPI file) so that users can easily install PythonExt just like any other Mozilla/Firefox extension. The Python bindings are a combination of PyXPCOM and PyDOM.
The Python extension is using Python 2.5.2 and is available to be used in most Mozilla based applications, including Firefox, Thunderbird and XulRunner.
Godel, Escher, Bach [2]
1. 素数判定的形式化系统,精彩!
合数的判定系统比较容易构造,素数的判定当然不能简单的通过“不是合数”来解决。
首先构造一个不整除的概念(DND)
公理模式:xyDNDx,其中x和y是短横组成的符号串。(a>b,a自然不整除b)
生成规则:如果xDNDy是个定理,那么xDNDxy也是个定理。
接下来定义一个描述z在2到x的范围内没有因子的语言,zDFx (Divisor-Free)
规则1:如果–DNDz是个定理,那么zDF–也是个定理。
规则2:如果zDFx与x-DNDz都是定理,那么zDFx-也是个定理。
好了,到这里已经能检查一个数是否在给定范围内找出因子了,定义素数(Pz)就变得很简单。
规则:若z-DFz是个定理,那么Pz-是个定理。
再处理一个特例,为2制定一条公理
公理:P- -
Python Internal Types
From Python Reference Manual 3.2
Internal types
A few types used internally by the interpreter are exposed to the user. Their definitions may change with future versions of the interpreter, but they are mentioned here for completeness.
Read the rest of this entry »
Godel, Escher, Bach [1]
1. 哥德尔定理
用比较通俗的英文来说,就是
All consistent axiomatic formulations of number theory include undicidable propositions.
2. 图形和衬底也许会不带有完全相同的信息
There exist formal systems whose negative space (set of non-theorems) is not the positive space (set of theorems) of any formal system.
用更technical的说法
There exist recursively enumerable sets which are not recursive.
这里recursively enumerable指能按照typographical规则生成,而recursive则对应域指衬底也是个图形的图形。
由此得出一个结论
There exist formal systems for which there is no typographical decision procedure.
证明很简单,用反证法。如果所有的形式系统都能有typographical的判定方法,那么逐个测试所有的符号串,从而能生成一个非定理集合,与前面的定理矛盾。
3. 关于那个数列谜题
{Ai} = 1, 3, 7, 12, 18, 26, 35, 45, 56, 69, …
既然讲到了衬底自然要考虑这个,负空间数列为
{Bi} = 2, 4, 5, 6, 8, 9, 10, 11, 13, 14, …
An = An-1 + Bn-1