- 博客(80)
- 收藏
- 关注
原创 今天遇到的两个问题
晚上编译代码的时候,一直报这个错误:___@@_PchSym_@00@UywhdxlwvUywhdPkilqUyzhrxUlfgkfgUlyqUdrmDCPivovzhvUywhdUgvnkUywhdOlyq@ already defined in bdsw.obj折腾了半天,发现是每个cpp的Create/Use Precompiled Header设置的是Create Precompi
2015-02-09 19:21:52
709
原创 _read函数的一个陷阱
晚上用evhttp编了一个http服务器,请求静态文件的时候,发现半天没反应。vs 2013的调试器也很奇怪,按个F10直接跳到下一个断点了。点击下断点的时候,提示“断点未能绑定”。后来,在网上搜到了解决办法:在 工具 -- 选项 -- 调试 -- 编辑并继续 里面 勾选启用本机“编辑并继续”。解决了这个问题,就调试一步步跟踪吧。代码中,先用open打开文件,然后调用evbu
2015-02-08 01:35:09
1207
原创 windows版tinyhttpd
单线程,同步阻塞的socket。去掉了cgi的功能,只处理静态文件请求,改了accept_request中的几处bug。/* J. David's webserver *//* This is a simple webserver. * Created November 1999 by J. David Blackstone. * CSE 4344 (Network concepts),
2015-02-07 16:47:23
3557
原创 sqlite3插入记录慢的解决办法
sqlite3_exec(db, "PRAGMA synchronous = 0;PRAGMA journal_mode = OFF;", nullptr, 0, nullptr)关闭同步和日志,当然,这种办法是有风险的。PRAGMA synchronous = 0With synchronous OFF (0), SQLite continues without syncin
2015-01-27 23:30:19
1472
原创 nginx中获取当前时间的函数
voidngx_gettimeofday(struct timeval *tp){ uint64_t intervals; FILETIME ft; GetSystemTimeAsFileTime(&ft); /* * A file time is a 64-bit value that represents the number *
2015-01-13 22:23:24
8880
原创 nginx中的多线程时间更新模型
在nginx中,ngx_time_update函数可以被多个线程执行,但只要有一个线程执行了这个函数,其他线程无需执行这个函数。对于这种需求,nginx给出的实现方案挺有意思。ngx_time_update开头两句如下: if (!ngx_trylock(&ngx_time_lock)) { return; } // do something...
2015-01-13 22:17:29
1967
原创 C语言实现的list -- 源码摘自wine
#ifndef __WINE_SERVER_LIST_H#define __WINE_SERVER_LIST_H#include struct list{ struct list *next; struct list *prev;};/* add an element after the specified one */static inline void li
2015-01-13 14:12:40
8965
原创 C++ 事件回调机制的几种实现方式
1、duilib中的CEventSource。以下代码摘自duilib,并且有一点改动。delegate.h#include class CDelegateBase{public: CDelegateBase(void* pObject, void* pFn); CDelegateBase(const CDelegateBase& rhs); virtual ~CDelega
2015-01-12 22:35:41
5838
原创 vs2005里auto_ptr的指针赋值一个陷阱
先来一段代码:#include #include class A{public: A() : ma(0) {} void print() { ATLTRACE(_T("%d"), ma); }private: int ma;};int _tmain(int argc, _TCHAR* argv[]){ std::auto_ptr aPtr = new A(
2015-01-12 21:12:44
626
原创 GUI程序中使用windows消息实现并行
一个消息循环做的并行类。class ClsA{public: ClsA(); LRESULT HandleMessage(HWND, UINT, WPARAM, LPARAM); void Method1();public: static LPCTSTR WindowClass; static ATOM RegisterWndClass(HINSTANCE hInst);
2015-01-12 09:00:59
617
原创 SendMessage的大致流程
1、构造send_message_info结构体,然后调用send_message函数。 SendMessageA和SendMessageW的区别有两处:info.type一个是MSG_ASCII,一个是MSG_UNICODE;send_message函数的第三个参数一个为TRUE一个为FALSE。LRESULT WINAPI SendMessageA( HWND hwnd, UINT msg,
2015-01-09 00:10:53
5102
原创 python win32com对多接口类的处理
下午碰到这么一个问题,一个COM类实现了多个接口,使用win32com创建com对象之后,不知道怎么从默认接口查询到其他接口。回来仔细看了看win32com的源码和文档,发现有个CastTo函数,它可以完成接口间的转换。import pythoncomimport win32com.clientfrom pywintypes import IIDobj = win32com.c
2015-01-08 21:14:41
3324
原创 开发IE下js使用的com组件,包含事件处理
很简单,将事件做成属性,并设置属性的bindable, displaybind标记。在js下面直接将function传给这个属性,com组件里面调用这个IDispatch的函数即可。idl文件,注意onevent1这里。import "oaidl.idl";import "ocidl.idl";[ object, uuid(6A6140E8-9356-4FBD-B0F
2015-01-06 23:07:45
3332
原创 面试总结
晚上又去面了一次搜狐,另一个职位的一面,照旧也写写总结吧。题跟上一次的差不多,选择题稍微多了几道。这一次跟面试官聊起来才发现上一次做错了几道。一、一个算错的问题。union U{ int i; char ch[2];};int _tmain(int argc, _TCHAR* argv[]){ U u; u.i = 0; u.ch[0] = 10; u.ch[1]
2015-01-06 22:32:16
677
原创 面试总结
晚上去面了一下搜狗,总的来说感觉还行吧。不过,有些问题回答的不好。总的来说在windows消息机制部分,理解还是不够深刻。1、windows消息有没有优先级http://support.microsoft.com/kb/96006/en-us/http://blog.youkuaiyun.com/FreeWave/article/details/2056469?reload2、Se
2015-01-05 00:00:53
783
原创 win8.1下vs2013编译nginx
我的环境是win8.1 + vs2013社区版1、安装msys。http://sourceforge.net/projects/mingw/files/ Installer文件夹下有mingw-get,安装之后,弹出的界面中选择msys即可安装msys。2、下载 zlib、openssl和pcre下的几个版本为:openssl-1.0.1j、pcre-8.32、zlib-1
2015-01-03 18:21:58
5619
原创 nodejs提取网页内容
今天,在公司想用nodejs提取一下http://msdn.microsoft.com/zh-CN/library/windows/desktop/hh802935(v=vs.85).aspx 里面的API函数列表,做一个帮助文档。谁知道,公司电脑上安装的是vs2005,在安装jsdom进行编译的时候一直报错,node-jquery也是一样。晚上,回来了在自己电脑上又试了一遍,笔记本上装的
2014-12-30 00:25:27
6438
原创 windows下使用virtualenv进行多版本python共存
今天,想写个nodejs下载网页的脚本,打算用node-curl实现。运行npm install node-curl的时候,编译的时候报错,提示不能用python3.4,只能用2.5~3.0之间的python。网上说virtualenv能解决这种多版本python共存的问题,这么好的东西,赶紧下下来试试吧。cd /d C:\Python34\Scriptseasy_install v
2014-12-29 14:36:08
8178
原创 阅读nginx源码_win32
本打算周末好好看看nginx源码的,却玩了两天的游戏。还没有开始编译nginx,cygwin还没装好,mirror不给力啊。过了一遍http://blog.youkuaiyun.com/kenbinzhang/article/category/603177关于nginx系列的文章,对nginx工程结构有了个大致的印象。int ngx_cdecl main(int argc, char *const *
2014-12-28 23:47:13
1089
原创 coroutine协程
对协程还没有很深刻的认识,先贴上几个例子吧。lua编写的协程例子:yield的参数由resume返回了,resume的参数由yield返回。。function foo (a) print("foo", a) return coroutine.yield(2*a)end co = coroutine.create(function (a,b) print("co-bod
2014-12-26 23:22:48
512
原创 win32com调用ATL编写的COM组件
IDL文件import "oaidl.idl";import "ocidl.idl";[ object, uuid(B325C169-61FA-4513-9DB1-0CC231CCB633), dual, nonextensible, helpstring("IComTestClass Interface"), pointer_default(unique)]interf
2014-12-25 10:39:36
2466
原创 VBS调用ATL编写的COM组件
参考文章:http://blog.youkuaiyun.com/collin1211/article/details/1864624不使用连接点,而是使用属性来处理事件回调。IDL文件import "oaidl.idl";import "ocidl.idl";[ object, uuid(7E153966-BF67-4F02-BE64-80CB780A2EEF), dual, n
2014-12-24 21:19:59
3827
原创 vba调用vs2005使用atl开发的com组件
1、新建工程New -- Project -- ATL Project勾选Allow merging of proxy/stub code2、添加接口右键工程 -- Add -- ATL Simple Object3、添加接口函数类视图中,右键接口 -- Add -- Add Method4、添加事件类视图中,展开类型库,
2014-12-24 20:17:02
2895
原创 windows下使用vs2005编译libevent 2.0.21
使用makefile编译1、打开vs2005编译控制台。cd /d E:\an_ui\Demo\Projects\libevent-2.0.21nmake /F Makefile.nmake cleannmake /F Makefile.nmake使用工程编译两个工程都要加头文件目录:$(SolutionDir)$(SolutionDir)\include
2014-12-22 14:33:02
702
原创 evhttp实现的http服务器
/* A trivial static http webserver using Libevent's evhttp. This is not the best code in the world, and it does some fairly stupid stuff that you would never want to do in a production webserve
2014-12-22 14:14:19
12924
转载 libevent里的timer使用
/* * XXX This sample code was once meant to show how to use the basic Libevent * interfaces, but it never worked on non-Unix platforms, and some of the * interfaces have changed since it was first
2014-12-22 10:39:55
870
转载 bufferevent实现的echoserver
// echoserver.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include #include #include #include #include #include #include static void echo_rea
2014-12-22 10:23:35
527
转载 bufferevent实现的简易http client
工程链接库:libevent_core.lib Ws2_32.lib libevent_extras.lib
2014-12-22 10:10:32
1889
原创 win7下libevent实现的rot13服务器
// libev_rot13.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include #define MAX_LINE 16384void do_read(evutil_socket_t fd, short events, void *arg)
2014-12-19 18:07:50
704
原创 win7+VS2005编译libevent-2.0.21-stable
编译方法还是很简单的。1、打开vs2005工具命令行。C:\Program Files (x86)\Microsoft Visual Studio 8\VC>cd /d E:\an_ui\Demo\Projects\libevent-2.0.21E:\an_ui\Demo\Projects\libevent-2.0.21>nmake Makefile.nmake2、编译输出l
2014-12-19 17:17:26
1076
原创 python用http.server实现的http服务器
import osimport shutilfrom io import StringIOfrom pymongo import MongoClient, ASCENDINGfrom urllib.parse import urlsplit, parse_qsfrom http.server import HTTPServer, BaseHTTPRequestHandlerclien
2014-12-19 16:47:22
3018
原创 PHP使用SyntaxHighlighter显示xml文件
<?phpheader("Content-Type: text/html; charset=gb2312");if(!isset($_GET["key"])) { header("Location: /skinhelp/index.php"); exit;}?> <?php echo "皮肤库帮助"?> <?php$filepath = $_SER
2014-12-19 15:53:09
1115
原创 自定义类处理消息循环HWND_MESSAGE
LRESULT CALLBACK CCustomMsgObject::__WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){ CCustomMsgObject* pThis = NULL; if (uMsg == WM_NCCREATE) { LPCREATESTRUCT lpCS = reinterpret_cas
2014-07-30 08:45:55
2495
1
原创 virtualbox中安装配置ubuntu桌面版系统
在virtualbox中安装了个ubuntu,学学linux。virtualbox虚拟机功能强大,而且还免费。virtualbox下载:https://www.virtualbox.org/wiki/Downloadsubuntu下载:http://www.ubuntu.org.cn/download/desktop安装完virtualbox之后,新建一个虚拟机,设置网卡为“桥
2014-03-23 22:56:21
2677
翻译 指向函数的指针数组
我们可以创建一个有趣的结构式指向函数的指针数组。为了选择一个函数,只需要使用数组的下标,然后间接引用这个指针。这种方式支持表格式驱动码(table-driven code)的概念;可以根据状态变量(或状态变量的组合值)去选择被执行函数,而不用条件语句或case语句。这种设计方式对于要从表中添加或删除函数(或者想动态的创建或改变表)十分有用。下面的例子使用预处理宏创建了一些哑函数,然后使用自动聚
2012-04-01 21:45:59
1973
翻译 成员函数指针表
函数指针和成员函数指针的一个公共用途是,将它们存储在函数表中。函数表是函数指针的集合,在运行时从中选择给定调用。对具有几个相同类型成员的类而言,可以使用这样的表来从这些成员的集合中选择一个。假定扩展screen类以包含几个成员函数,其中每一个在特定方向移动光标:class Screen{public: //other interface and implementation memb
2012-03-31 17:07:36
875
原创 [vs 2005]vector双参数构造流程
源代码:#include using namespace std;int main(){ vector vec(20, 10); return 1;}分析:vector实现中有两个函数,一个是vector(size_type _Count, c
2011-07-25 22:02:57
1143
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人