- 博客(49)
- 资源 (27)
- 收藏
- 关注

原创 简易web服务器
函数介绍init_socket:初始化网络套接字。 get_line:一次读取网络缓冲区的一行数据。 pare_request_line:解析请求行。 send_line_header:发送响应行和响应头。 send_html:发送html文件。 accept_client:线程函数,用于处理一个连接。流程分析代码的执行顺序为 main->init_socket->pthread_cre
2015-05-18 21:30:04
741

原创 输出nginx执行过程中函数调用关系
添加源文件首先在src/core/目录下添加两个文件,分别是my_debug.h和my_debug.c。#ifndef MY_DEBUG_LENKY_H#define MY_DEBUG_LENKY_H#include <stdio.h>void enable_my_debug(void) __attribute__ ((no_instrument_function));void disable_
2015-05-11 22:02:27
1055

原创 用GDB调试nginx
阅读源码的最好方式就是跟踪调试代码,这里介绍了如何利用GDB调试nginx的配置和步骤。修改配置文件修改nginx.conf:#user nobody;master_process off;daemon off;daemon off;表示关闭守护进程模式,这样就免除了用GDB跟踪fork出的子进程了。如果默认启用守护进程,标准输出是被关闭的。因此关闭守护进程模式能够利用printf方便查看
2015-05-10 11:21:28
812

原创 MFC音乐播放器,界面漂亮,功能齐全+源码下载
源码下载地址 http://download.youkuaiyun.com/detail/wxq714586001/7070663 实现了播放器的绝大多数功能,例如:添加歌曲,保存列表,删除歌曲,删除重复,歌曲根据不同的关键字排序,播放模式的选择,调节音量,进度,显示歌曲进度时间和剩余时间,保存上次播放配置... 程序截图
2014-03-20 12:08:53
5400
1

原创 BFS、加权图最短路径的c++实现
一、测试数据输入顶点数和边数:7 12请输入边:第1条边:1 2 2第2条边:1 4 1第3条边:2 4 3第4条边:2 5 10第5条边:3 1 4第6条边:3 6 5第7条边:4 3 2第8条边:4 5 2第9条边:4 6 8第10条边:4 7 4第11条边:5 7 6第12条边:7 6 1请输入起始结点和终止结点:1 6BFS:
2014-03-16 20:25:25
3327

原创 MFC贪吃蛇+源代码
1、源代码下载地址:2、游戏开始界面3、游戏运行界面4、游戏结束界面 5、不足之处a、代码写得比较乱,还没理解什么事模块化编程b、MFC还有待进一步学习,多看优秀源码
2014-03-02 16:20:01
5782

原创 MFC的GDI对象的构造与释放
一、设备上行文CDC对象封装了设备上下文的一个句柄m_hDC,如果通过GetDC();来操作设备上下文,一定要在退出函数时调用ReleaseDC();GetDC();相当于获得了一个当前设备上下文的一个副本,调用它是会重新分配内存的,ReleaseDC();相当于将新分配的内存free。如果CClientDC来操作设备上下文,那么它会在对象的析构函数中调用ReleaseDC();
2014-02-25 08:57:11
3088

原创 最大子数组的递归实现
源代码//找最大子数组 数组索引从0开始//2014-2-23#include using namespace std;int* FindMiddle(int* array, int low, int high, int middle);int* FindMax(int* array, int low, int high);extern int* gresult
2014-02-23 21:08:11
1401

原创 归并排序、二分法查找的递归实现
一、归并排序// 归并排序// 2014-2-22#include using namespace std;void Merge(int* array, int p, int q, int r);void MergeSort(int* array, int p, int q);int main(){ int array[10]; for (int
2014-02-22 14:42:55
1560
原创 rt3070 无线wifi模块移植到linux,并连接无线路由上网
Linux发行版:ubuntu 10.4无线网卡芯片:rt3070路由器加密方式;WPA-PSK/AES驱动:2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO.bz2一 安装驱动(1) 驱动安装包需要解压两次。(2)修改Makefile-CHIPSET = 5370+CHIPSET = 30
2015-12-05 15:00:36
1746
1
原创 计数排序、基数排序、桶排序
#include #include #include #include #include using namespace std;class MySort {public: MySort(vector v):m_num(v) {} virtual ~MySort() = 0{} virtual void Sort() = 0; void display() { cop
2015-07-17 10:21:56
661
原创 排序算法总结
#include #include using namespace std;class MySort {public: MySort(vector v):m_num(v) {} virtual ~MySort() = 0{} virtual void Sort() = 0; void display() { copy(m_num.begin(), m_num.end(),
2015-07-16 20:28:08
602
原创 N-QueensII : 4ms and short
class Solution {public: void helper(int row, int &res, int n, vector& solution) { if (row == n+1) { ++ res; } for (int i = 1; i <= n; ++ i) { if (canPlac
2015-07-09 15:45:09
606
原创 Restore IP Addresses : 0ms
class Solution {public: void helper(int dot, int pos, int len, vector& res, string& s, string& target) { int deltaLen = len - pos; if (dot == 3) { string tmp = s.substr(pos, de
2015-07-09 10:06:09
537
原创 Sudoku Solver : 53 lines and 12 ms
class Solution {public: bool helper(int r, int c, int mpRow[][9], int mpCol[][9], int mpGroup[][9], vector >& board) { if (r >= 9) { return true; } if (c >= 9){ c = 0; if (helper(r
2015-07-09 09:13:29
928
原创 scrapy抓取知乎话题v0.2(实现qq发送邮件功能)
源码下载地址:一共由两个scrapy工程实现。第一个工程zhihu_topic:实现抓取关注人数超过2000的知乎话题、相应链接、父子话题并存入MySQL数据库。这个工程只要执行一次,第二个工程会利用这里获取到的链接(link_id)。usage: scrapy crawl topic下面是从数据库中获取一部分话题的截图第二个工程zhihu:先贴出
2015-07-07 21:28:43
2291
原创 Longest Substring Without Repeating Characters: 12ms
class Solution {public: int lengthOfLongestSubstring(string s) { int hash[256] = {0}; int len = s.size(); if (len <= 0) return 0; int maxLen = -1, curL
2015-07-02 17:29:46
724
原创 Binary Search Tree Iterator: O(1)时间复杂度,O(h)空间复杂度
class BSTIterator {public: BSTIterator(TreeNode *root) { while (root) { lst.push_back(root); TreeNode *tmp = root->left; root = root->left; }
2015-06-30 17:35:57
1580
原创 Sum Root to Leaf Numbers : 精简实现方式
class Solution {public: int helper(TreeNode* root, int target) { if (root && !root->left && !root->right) return target * 10 + root->val; else if (!root) return 0;
2015-06-30 16:20:15
618
原创 Symmetric Tree: 简单的实现方式
class Solution {public: bool isSymmetric(TreeNode* rootl, TreeNode* rootr){ if (!rootl && !rootr) return true; else if (rootl && rootr && rootl->val == rootr->val
2015-06-30 15:06:00
704
原创 Remove Duplicates from Sorted List II simple and fast
class Solution {public: ListNode* deleteDuplicates(ListNode* head) { ListNode dummy(-1), *pre = &dummy, *iter; dummy.next = head; while (pre && pre->next) { if
2015-06-28 09:39:25
610
原创 Reverse Nodes in k-Group short and 24ms AC
class Solution {public: ListNode* reverseKGroup(ListNode* head, int k) { if (!head || k <= 0) return head; int len = 0; ListNode dummy(0), *iter = &dummy; dummy.next = he
2015-06-27 21:08:59
629
原创 Swap Nodes in Pairs 11行AC
class Solution {public: ListNode* swapPairs(ListNode* head) { ListNode new_head(0); new_head.next = head; ListNode* iter = &new_head; while (iter->next && iter->next->ne
2015-06-27 11:29:44
884
原创 scrapy抓取知乎话题v0.1
一、简介 抓取知乎某一子话题,赞同人数超过10的会被抓取。回答ID、赞同人数、回答时间、内容、提问被保存到mysql数据库中,支持更新(多次抓取时对于同一回答的ID只更新赞同人数)。usage:scrapy crwal zhihu二、效果:抓了一个通宵将编程子话题全部抓完,抓取了13M的内容,下面是保存为json的数据。但是,数据量一大用json来保存就很不方便
2015-06-23 23:12:55
1094
原创 leetcode:Container With Most Water 6行AC
class Solution {public: int maxArea(vector& height) { int start = 0, end = height.size() - 1; int imax = INT_MIN; while (end > start) { int res = (end - start)
2015-06-23 10:20:29
541
原创 leetcode:Merge Sorted Array 5行代码AC
class Solution {public: void merge(vector& nums1, int m, vector& nums2, int n) { int indexNum1 = m - 1, indexNum2 = n - 1, index = m + n - 1; while (indexNum1 >= 0 && indexNum2 >=
2015-06-22 17:03:43
537
原创 scrapy爬取豆瓣读书的图书信息
usagescrapy crawl dou一、效果二、源码下载地址http://download.youkuaiyun.com/detail/wxq714586001/8826869三、实现过程done list: 1、定义Item 2、开始爬取网页 a、定义类继承自CrawlSpider b、定义name/a
2015-06-21 21:18:07
1443
原创 scrapy爬豆瓣电影
usage:scrapy crawl first一、抓取效果二、源码下载http://download.youkuaiyun.com/detail/wxq714586001/8821149三、总结done:1、解决了将unicode字符串(类似于‘\uxxx\n\t\t’)转换为实际的文字,困扰了很久。2、用正则表达式替换字符串。3、scrapy的基本使用方法。
2015-06-19 00:04:12
920
原创 python 知乎回答按赞排序
一、实现效果二、源码#coding:utf-8import reimport timeimport codecsimport StringIO, gzipimport osimport urllibimport urllib2from bs4 import BeautifulSoupimport chardetdef my_cmp(a, b): r
2015-06-15 22:27:31
2204
原创 python 白云黄鹤十大
一、效果能捕获按键的输入,无需按enter确认。二、源码# -*- coding:utf-8 -*-import selectimport sysimport timeimport osimport termiosimport reimport urllibimport urllib2import codecsimport chardetimpo
2015-06-11 21:27:00
1545
原创 python 爬直播吧NBA录像
一、运行结果二、源码# -*- coding:utf-8 -*-import urllibimport urllib2import reimport osimport codecsclass NBA(object): def __init__(self, team = ur'(热火vs马刺)'): self.base_url = ur'h
2015-06-09 20:25:21
1619
原创 nginx动态数组ngx_array_t
ngx_array_t是nginx中设计的动态数组,类似于STL中的vector。下面我们结合实例分析。一、实例#include #include "ngx_config.h"#include "ngx_conf_file.h"#include "nginx.h"#include "ngx_core.h"#include "ngx_string.h"#include "ngx_
2015-06-03 10:32:40
949
原创 nginx双向链表ngx_queue_t
一、介绍ngx_queue_t是nginx中实现的双向链表,在要用到双向链表的自定义结构体中将ngx_queue_t嵌入到自定义结构体中即可。还有一个特点是ngx_queue_t不涉及到内存分配。二、例子下面的源码是将《深入理解nginx》第7章关于ngx_queue_t的源码整合起来。Makefile则是参考http://blog.youkuaiyun.com/livelylittlefish/
2015-06-02 17:35:42
781
原创 配置简单的nginx反向代理
最近在阅读ngx_http_upstream_module源码,首先要让该模块运行起来,然后调试跟踪。这里介绍了配置简单的nginx反向代理。一、安装httpdyum install httpdecho “hello world!” > /var/www/html/index.htmlservice httpd start 完成了上述步骤,可以测试一下:curl htt
2015-06-01 16:27:40
657
原创 ngx_http_concat_module
一、ngx_http_concat_module模块介绍该模块是由淘宝网发布在github,用来合并多个静态文件的请求为一个请求,减少服务被访问的次数。二、配置在/path_install_nginx/html/static/js目录中添加两个js文件,a.js和b.js。在里面写入内容。 修改配置文件:location /static/js { c
2015-05-29 22:29:24
2529
原创 lua与c语言互相调用
lua和c语言之间的互调大量出现在lua-nginx-module中,这里给出《lua程序设计》第24-27章的一些测试代码。#include #include #include #include #include #include #include #include #define MAX_COLOR 255static void stackDump(lua_State
2015-05-27 15:55:21
1770
原创 nginx调试过程:No symbol "*" in current context
原因:自动生成的Makefile开启了编译优化选项 ‘-O’。解决办法:删除Makefile中的-O选项。补充:优化选项有不同级别,-O0、-O1、-O2...。-O等价于-O1。
2015-05-26 22:11:01
780
原创 nginx模块开发:ngx_xqw_backtrace_module
模块介绍当nginx运行过程中收到异常退出信号SIGINT,会将当前函数调用堆栈输出到日志文件当中。除了处理SIGINT之外,还可以在模块中添加相应信号。模块开发流程创建配置结构体typedef struct ngx_xqw_backtrace_conf_s{ ngx_log_t *log; // 日志 ngx_int_t size; // 栈最大深度}ngx_xqw_back
2015-05-20 11:42:52
755
原创 LINK : fatal error LNK1158: 无法运行“cvtres.exe”
在win7的64位操作系统装vs2010遇到了无法运行”cvtres.exe”。解决办法:重新下载cvtres.exe。替换Microsoft Visual Studio 10.0\VC\bin\cvtres.exe。 下载链接:http://download.youkuaiyun.com/detail/wxq714586001/8713287
2015-05-18 18:55:15
16346
原创 python入门总结
python是一门面向对象的脚本语言,有丰富的web库和网络处理能力,在开发nginx模块时也会用到。这里对学习到的基础知识点做一个小总结。变量在定义的过程中不用指定类型,可以用type()函数查看变量或常量类型 i = 1 type(i) type(“hello world”) 函数的定义 def func(arg): command return val 条件执行语句和循环
2015-05-11 22:31:40
598
zhihu_topic_v0.2
2015-07-07
MFC音乐播放器
2014-03-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人