ITeye博客

zs0723

zs0723 · 共 18 篇文章

NPM 安装node.js模块

如果在安装某个模块时发生如下错误: npm install winston -g npm ERR! error installing winston@0.5.6 Error: shasum check failed for C:\DOCUME ~1\myname\LOCALS~1\Temp\npm-1321027028150\1321027046659-0.772715161787346\tmp. tgz npm ERR! error installing winston@0.5.6 Expected: 7d0023eaeb154e8ee9fce75dcb923d 0ed1667774 np…

2011-11-12 00:30 · Node.js · 评论(0)

如何在 windows环境中安装NPM

按照 http://npmjs.org/doc/README.htm步骤进行。 在执行node cli.js npm install -gf 的时候报错: npm ERR! Could not unpack C:\Documents and Settings\myname\npm-cache\npm\1.0.1 05\package.tgz to C:\Documents and Settings\myname\npm-cache\npm\1.0.105 npm ERR! Error: UNKNOWN, The operation completed successfully. npm ER…

2011-11-12 00:03 · Node.js · 评论(0)

C++ STL map essential

Map 是C++ STL中的key-value存储的数据结构,key是唯一的,因此如果在map容器中插入一个已经存在的key,则不会对容器中的对象产生影响。与vector不同的是插入和删除一个element并不会对别的element引用或迭代器产生影响。Map常常使用Self-balancing binary search tree的技术来实现这种需求。

2011-03-16 10:21 · 标准C++ · 评论(0)

C++ STL vector essential

Vector 是C++ STL中的一个常用的数据结构。作为一个动态数组的容器,其典型的内部实现在内部拥有一个动态分配的数组,并有size 和capacity两个成员变量。size用来指示实际存储的element数量,capacity用来指示内部分配的数组大小。 当插入element的时候,如果size大小超过了capacity,就需要重新分配内存,来容纳新的element.这样已经存在的element就需要重新拷贝到新的内存区域中;因为element的地址在重分配的过程中已经发生变化,所以任何对该element的引用(reference)和迭代器(iterator)都将无效,如果使用这些无效…

2011-03-16 10:10 · 标准C++ · 评论(0)

一个简单的win32 service 问题

mport win32service import win32serviceutil import time class aservice(win32serviceutil.ServiceFramework): _svc_name_ = "aservice" _svc_display_name_ = "aservice - It Does nothing" def __init__(self,args): win32serviceutil.ServiceFramework.__init__(self,args) self.isAlive = True def SvcDoRun(self): …

2011-02-16 23:31 · Python · 评论(0)

做事需要一气呵成

RT

2011-02-11 15:59 · 评论(0)

Python 技巧

1 字典排序 (reference:http://www.saltycrane.com/blog/2007/09/how-to-sort-python-dictionary-by-keys/) mydict= {'carl':40, 'alan':2,'bib':1,'danny':3} #根据KEY来排序 for key in sorted(mydict.iterkeys()): print "%s: %s" %(key,mydict[key]) # 根据KEY逆序排列 for key in sorted(mydict.iterkeys(),reverse=True): print "%s…

2010-06-06 21:38 · Python · 评论(0)

原型模式

原型(PROTOTYPE)模式的目的是为了用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。 为什么需要原型模式? 我以QT中的QTableWidget 作为例子。如果我们需要对QTableWidget 中项(QTableWidgetItem)进行定制;就需要继承QTableWidgetItem并重写QTableWidgetItem 中的某些方法(QTableWidgetItem::setData),来达到应用程序的目的。 但是这里就有一个问题,QTableWidget为了要创建一个特殊的QTableWidgetItem子对象,就必须要知道这个 子类的名字;对QTableWid…

2009-07-08 12:56 · 标准C++ · 评论(0)

RationRose generate code for ANSI c++

1 To generate ANSI c++ code from UML class diagram. You need to create component under the "Component View" with language "ANSI C++" selected. 2 After you have created a class diagram , you need to " assign " the class to the componet.

2009-06-25 11:31 · 评论(0)

OTL v4

1 Set trace level to check what OTL done unsigned int trace_level = 0x1 | 0x 2 | 0x4 | 0x8 | 0x10 | 0x20; #define OTL_TRACE_LEVEL trace_level #define OTL_TRACE_LINE_PREFIX "OTL " #define OTL_TRACE_LINE_SUFFIX std::endl 2 How to use OTL a) define some MARCO that the OTL library needed unsigned int t…

2009-06-23 15:31 · 标准C++ · 评论(0)

Comeau c++ try out

代码(for_all实现从Imperfect c++ 拷贝): //需要包含algorithm,vector,iostream using namespace std; template inline F for_all(C v,F func) { return std::for_each(v.begin(),v.end(),func); } //针对数组做特化,使for_all对容器和数组都有统一的接口 template inline F for_all(C (&v)[N],F f) { return std::for_each(&v[0],&v[0]+N,f); } template v…

2009-06-11 21:14 · 标准C++ · 评论(0)

cscope 源码

1 编译 cscope 依赖curse 库 。在调用./configure前,确保该库在编译环境中。

2009-06-09 10:46 · LINUX · 评论(0)

cscope 使用

1 cscope 设置EDITOR变量可以修改打开文件的编辑器 export EDITOR=vim ;这行可以将cscope 默认的编辑器vi 替换。 启动cscope 2 退出程序 CTRL+ D ,HUP,TERM signal Note: CTRL+Z ,将使进程进入background模式。使用fg命令可将程序切换到foreground模式。 3 创建一个文件名为:cscope.files,其中包含你所要浏览的源码文件路径。 4 使用cscope -b 生成交叉引用文件。

2009-05-27 17:07 · LINUX · 评论(0)

常用技巧

1 删除文件中的某一行 sed -e '/pattern/d' file > tmp_file

2009-05-27 17:05 · LINUX · 评论(0)

在HP-UX上使用Rogue Wave 库

目的: 调用RogueWave 的RWWString::hash 方法。 源码: #include <iostream.h> #include <rw/tools/wstring.h> #include <string> const int GUI_INSTANCE_LEN= 11; void OSS(string input) { RWWString instance(input.c_str(),RWWString::ascii); unsigned hashValue = instance.hash(); char buf[GUI_INSTANCE_LEN]; snprintf(buf,…

2009-03-09 15:16 · HP-UX · 评论(0)