随笔分类 -  转载精华

不好的绝对不转
摘要:访问顺序: 实例的__getattribute__()、Descriptor的__get__()、实例的__dict__、只读Descriptor的__get__()、实例的__getattr__(); 实例的__setattr__()、Descriptor的__set__()、实例的__dict__; 实例的__delattr__()、Descriptor的__delete_... 阅读全文
posted @ 2013-09-22 13:12 紫红的泪 阅读(314) 评论(0) 推荐(0) 编辑
摘要:Use __new__ when you need to control the creation of a new instance. Use __init__ when you need to control initialization of a new instance. __new__ is the first step of instance creation. It's ... 阅读全文
posted @ 2013-09-18 11:35 紫红的泪 阅读(557) 评论(0) 推荐(0) 编辑
摘要:官网下载安装,我这里用的x64版。拷贝个sublime_text.exe副本到sublime_text_copy.exe,并用Sublime打开。 把3032前的3342改为3242保存。然后填入注册码,并注册: —–BEGIN LICENSE—– hiwanz Unlimited User License EA7E-26838 5B320641... 阅读全文
posted @ 2013-05-30 14:09 紫红的泪 阅读(937) 评论(0) 推荐(0) 编辑
摘要:JSON doesn't require you to do that, it allows you to do that. It also allows you to use "\u0061" for "A", but it's not required. Allowing \/ helps when embedding JSON in a <script> tag, which doesn't... 阅读全文
posted @ 2013-02-28 17:10 紫红的泪 阅读(11041) 评论(0) 推荐(0) 编辑
摘要:Unity3D中C#实现协程需要注意一下几点: # An iterator member's signature cannot contain any out or ref parameters. # An iterator cannot contain a return statement . # An iterator may not contain any unsafe ... 阅读全文
posted @ 2013-02-07 20:53 紫红的泪 阅读(487) 评论(0) 推荐(0) 编辑
摘要:Python的super()在多继承下的方法推导顺序(MRO, Method Resolution Order)涉及到C3线性化算法(C3 linearization wiki)。其中关键是, children precede their parents and the order of appearance in __bases__ is respected. 例子, ... 阅读全文
posted @ 2013-01-17 15:54 紫红的泪 阅读(467) 评论(0) 推荐(0) 编辑
摘要:>>> def a():... print "a executed"... return []... >>> >>> def b(x=a()):... x.append(5)... print x... a executed>>> b()[5]>>> b()[5, 5]Actually, this is not a design flaw, a... 阅读全文
posted @ 2013-01-07 16:59 紫红的泪 阅读(1033) 评论(0) 推荐(0) 编辑
摘要:The supplemental garbage collection facility, however, is enabled by default and should be able to free that structure, if none of its components are reachable from the outside anymore and they do not... 阅读全文
posted @ 2013-01-06 16:46 紫红的泪 阅读(894) 评论(0) 推荐(0) 编辑
摘要:像if…else…这种没必要细说,Python中比C/C++多出来的有while…else…/for…else…/try…else…。while…else…/for…else…工作顺序为:在循环中使用时,else语句只在循环完成后执行,也就是说,break语句也会跳过else代码块,只要循环是正常结束,而不是通过break,else语句就会执行。try…else…功能和循环中的else语句没有多大区别:在try范围内没有检测到异常的时候,执行else子句。 阅读全文
posted @ 2012-12-24 14:12 紫红的泪 阅读(1916) 评论(1) 推荐(0) 编辑
摘要:在stackoverflow上看到的一篇,刚好解答了我的疑惑:http://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python The "dis" module disassembles the byte code for a function and is usefu... 阅读全文
posted @ 2012-12-24 12:49 紫红的泪 阅读(295) 评论(0) 推荐(0) 编辑
摘要:看MongoDB源码,发现里面有用这种诡异智能指针的,以前没见过,学习了。原文地址 阅读全文
posted @ 2012-11-19 16:06 紫红的泪 阅读(1071) 评论(0) 推荐(0) 编辑
摘要:主要是要注意两种析构语义上的不同:http://www.cnblogs.com/flier/archive/2004/07/08/22333.html 阅读全文
posted @ 2012-11-08 13:34 紫红的泪 阅读(188) 评论(0) 推荐(0) 编辑
摘要:所谓Stemming,可以称为词根化,这里有个overview。在英语这样的拉丁语系里面,单词有多种变形。比如加上-ed、-ing、-ly等等。在分词的时候,如果能够把这些变形单词的词根找出了,对搜索结果是很有帮助的。Stemming算法有很多了,三大主流算法是Porter stemming algorithm、Lovins stemming algorithm、Lancaster (... 阅读全文
posted @ 2012-11-06 11:51 紫红的泪 阅读(813) 评论(0) 推荐(0) 编辑
摘要:当这两个头文件顺序颠倒时,编译会出现许多莫名其妙的错误,错误如下: 1>…\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition 1>…\include\winsock.h(460) : see previous definition of 'AF_IPX' … [原因分析] 主要原因... 阅读全文
posted @ 2012-11-05 15:18 紫红的泪 阅读(6280) 评论(0) 推荐(0) 编辑
摘要:一直以来都是在Win32环境下Build和使用boost,但现在基本上每天都在64位Win7下工作,所以很有必要把这几天的经验总结下来。和32位环境不同,x64环境下编译得先从开始菜单启动Visual Studio的Visual Studio 2008 x64 Win64 Command Prompt进入命令提示符,而不是随便打开任意一个命令行窗口就行。然后转到boost根文件夹,运行... 阅读全文
posted @ 2012-11-05 11:04 紫红的泪 阅读(16641) 评论(3) 推荐(3) 编辑
摘要:KDTREE主要用来做范围查询,比如找与给定点距离最近的点。也有类似的面试题,如, 找一个点集中与给定点距离最近的点,同时,给定的二维点集都是固定的,查询可能有很多次,时间复杂度O(n)无法接受,请设计数据结构和相应的算法。 类似于@陈利人:附近地点搜索,就是搜索用户附近有哪些地点。随着GPS和带有GPS功能的移动设备的普及,附近地点搜索也变得炙手可热。在庞大的地理数据库中搜索地点,索引... 阅读全文
posted @ 2012-11-01 21:12 紫红的泪 阅读(5365) 评论(0) 推荐(1) 编辑
摘要:跟字符串的编辑距离不同,这里通常采用VSM+余弦定理:http://www.dewen.org/q/6668/%E5%A6%82%E4%BD%95%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E6%AF%94%E8%BE%83%E4%B8%A4%E7%AF%87%E6%96%87%E7%AB%A0%E7%9B%B8%E4%BC%BC%E6%80%A7%E7%9A%84%... 阅读全文
posted @ 2012-11-01 21:06 紫红的泪 阅读(1276) 评论(0) 推荐(0) 编辑
摘要:这几天笔试了好几次了,连续碰到一个关于常见排序算法稳定性判别的问题,往往还是多选,对于我以及和我一样拿不准的同学可不是一个能轻易下结论的题目,当然如果你笔试之前已经记住了数据结构书上哪些是稳定的,哪些不是稳定的,做起来应该可以轻松搞定。本文是针对老是记不住这个或者想真正明白到底为什么是稳定或者不稳定的人准备的。 首先,排序算法的稳定性大家应该都知道,通俗地讲就是能保证排序... 阅读全文
posted @ 2012-10-21 21:27 紫红的泪 阅读(148460) 评论(11) 推荐(56) 编辑
摘要:看到了Angry Master博客的文章,写的很浅显易懂,就转来了:http://pan.baidu.com/share/link?shareid=84575&uk=3106100059 阅读全文
posted @ 2012-10-20 21:42 紫红的泪 阅读(499) 评论(0) 推荐(0) 编辑
摘要:From StackOverflow: http://stackoverflow.com/questions/3788605/if-debug-vs-conditionaldebug From MSDN: http://msdn.microsoft.com/en-us/library/aa983575(v=VS.71).aspx 阅读全文
posted @ 2012-10-11 17:10 紫红的泪 阅读(366) 评论(0) 推荐(0) 编辑