- 博客(228)
- 资源 (2)
- 收藏
- 关注
原创 epoll实现服务端异步通信
epoll_create open an epoll file descriptorSYNOPSIS#include int epoll_create(int size)DESCRIPTIONOpen an epoll file descriptor by requesting the kernel allocate an event backing store dim
2012-12-07 20:59:56 1748
原创 linux线程私有数据
今天在看线程的私有数据时,一直想找个例子,实际的验证下,用数据告诉自己:"对,就是那样的,那就是TSD“,于是乎我看到了这个例子http://www.ibm.com/developerworks/cn/linux/thread/posix_threadapi/part2/,不得不说IBMdeveloperworkshop这的很好,有很多非常优秀的文章,至于原创与否我没有考证,不下结论,于是乎下
2012-11-26 17:16:37 2262 2
原创 poll函数实现多路复用
结构体pollfdstruct pollfd{int fd; //file descriptorshort event; //event of interest on fdshort reven; //event that occurred on fd}每一个pollfd结构体指定了一个被监视的文件描述符,可以传递多个结构体,指示pol
2012-11-21 09:26:03 1602
原创 hadoop单机部署
废话少说,以下是我的安装过程。工具如下Pc是学校的台式机,32位E4600CPU,1G内存,自己的笔记本虚拟机centos5.8 32位、jdk-6u13-linux-i586.bin、hadoop-0.22.0.tar.gz、SecureCrt(远程登陆PC)、百度(外网只能上csdn、cnblog,其余是百度快照)闲着无聊,想把学校的电脑搭成hadoop,电脑太烂,登陆太慢,只
2012-11-20 22:10:52 1944
原创 fd_set解析
用到select,就难免不了要接触一下几个宏 fd_set set; FD_ZERO(&set); FD_SET(read_fd,&set); select(MAX_NUM+1,&set,NULL,NULL,NULL); if(FD_ISSET(read_fd,set){……}这几个经常是按这种次序组合出现的,之前虽然也用过,但说实话,也就是用,根本不知道怎么
2012-11-13 23:23:34 7030 2
原创 socket通信趣解
socket通信真的好麻烦,记起来也特麻烦,就想了这么个办法,很形象,穿插着重要的函数,应该会方便点。源代码及部分函数的说明 http://blog.csdn.net/xluren/article/details/8043484#t3下图是socket通信的服务器端,我把他比作要开电话亭的商家,也许有点欠妥,纯粹为了记忆。下面是client端,把他比作打电话的人
2012-11-11 23:02:48 1430
原创 The Uncertainty Of C/C++
在学习c/c++语言中总有一些隐晦的地方让我们感觉到不确定,但知道其中的奥妙后,又会惊叹“啊,太巧妙了”,抑或对于语言的使用,已经达到了熟练或者甚至炉火纯青的地步,但是一刨根问底追究其本质的时候,我们却又不知所以然。慢慢地从新深入地再认真学习一遍,我也无法保证自己分析或查到资料百分之百正确,如果有什么错误之处还请留下宝贵意见。对于某一个不是非常清楚地,如果借用了您的部分blog,那么先在此谢过了。
2012-11-04 15:51:16 1296
原创 socket通信之完整的多路复用
前一篇文章是介绍的select一个极为简单的用法,这篇将select和socket结合使用,完成单线程多用户连接,用户退出后,可用连接自动+1,。客户端同http://blog.csdn.net/xluren/article/details/8043484 中的客户端服务器端代码如下:#include #include #include #include #include #
2012-10-07 14:46:58 3731
原创 socket通信之最简单的I/O 多路复用
在Linux/UNIX 下,有下面这五种I/O 操作方式:1.阻塞 I/O2. 非阻塞 I/O3.I/O 多路复用4.信号驱动 I/O(SIGIO)5.异步 I/O至于每种模式的含义自己去查吧,百度百科、wiki百科介绍的都很详细,要是介绍的话,我也就是抄袭过来,要学会使用搜索引擎~~还记得上一篇文章的例子吧,那就是基于阻塞I/O模式的,简单的不能再简单的socket通
2012-10-07 13:22:02 4022
原创 数据开发必知必会 - 数据仓库理论总结
数据仓库开发=90%的业务领域知识+10%的大数据/后端开发技术数据仓库组成=模型建设+数据治理+需求满足10年互联网研发经验,数据平台总监及投放增长研发负责人,负责数据平台期间,完成埋点改造、数据工具建设、离线及实时数仓建设,业务日增数据量约500T;负责增长平台期间,完成自助归因平台的建设,涉及归因、回传优化、回传等功能,支撑日投放金额近千万,同时在RTA/RTB也有深度实践。目前,在做特征工程和算法模型相关的工作。
2024-03-02 16:22:03 1549
转载 Jinja2 example for generating a local file using a template
原文链接:https://pythonadventures.wordpress.com/archives/Here I want to show you how to generate an HTML file (a local file) using a template with theJinja2 template engine.Python source (proba.
2015-10-15 13:42:13 1133
原创 TCP 算法总结
1.TCP Tahoe1.new ack: if (cwnd < sstresh) cwnd += 1 else cwnd += 1/cwnd2.timeout/3rd dup ack: retransmit all unacked ssthresh = cwnd/2cwnd = 1 jump to 1
2015-10-10 10:13:38 1490
转载 tcp拥塞控制时间轴上三种状态的关系,慢启动,拥塞避免,以及快速恢复的教学状态图。
原文出处:http://blog.csdn.net/brother_lei/article/details/8117484发现Computer Networking: A Top-Down Approach中关于拥塞控制的状态图非常好,写篇博客,方便自己以后复习。名词解释:slow start: 慢启动。congestion avoidance: 拥塞避免。
2015-10-09 20:30:55 3173
转载 TCP数据包分片机制详解
原文地址:http://www.cnitblog.com/donne/archive/2010/12/23/72500.aspxIP分片 在以太网上,由于电气限制,一帧不能超过1518字节,除去以太网帧头14字节(mac地址等)和帧尾4字节校验,还剩1500字节,这个大小称为MTU(最大传输单元)。 如果你的IP包大于1500字节,IP层就会分片了。 而1492的MTU值的来源,是因为PP
2015-09-24 17:16:01 18445 2
转载 How MongoDB’s Journaling Works
This was originally posted to Kristina Chodorow’s blog, Snail in a TurtleneckI was working on a section on the gooey innards of journaling for The Definitive Guide, but then I realized it’s an imple
2015-09-08 17:23:23 614
原创 vagrant 使用
vagrant 简直就是神器,当然可以相比较的就是比较火热的docker,个人还是感觉vagrant比较爽,但是要比docker重很多。0.三个概念provider,一个媒介,熟悉的有vmware,virtualbox之类的vagrant,管理虚拟机的工具,针对provider的封装使用box,一个个的虚拟机镜像1.软件的依赖安装很简单,假设基于virtualbox进行,那
2015-08-27 10:03:13 1769 1
转载 基于朴素贝叶斯的文本分类算法
原文地址:http://cn.soulmachine.me/blog/20100528/作者: 灵魂机器新浪博客:www.weibo.com/soulmachine摘要:常用的文本分类方法有支持向量机、K-近邻算法和朴素贝叶斯。其中朴素贝叶斯具有容易实现,运行速度快的特点,被广泛使用。本文详细介绍了朴素贝叶斯的基本原理,讨论了两种常见模型:多项式模型(MM)和伯努利模型(B
2015-08-03 10:36:41 10548 3
转载 Abstract Classes and Factory Design Pattern in Python
Abstract Classes are one of the most useful and important concepts in Object Oriented Programming. I’ll attempt to illustrate their usefulness, and their usage in Python 2.7 with the following (seem
2015-07-14 11:15:23 712
转载 Multiprocessing vs Threading Python
Q:I am trying to understand the advantages of multiprocessing over threading. I know thatmultiprocessing gets around the Global Interpreter Lock, but what other advantages are there, and can threa
2015-07-13 14:58:15 1052
转载 Python thread pool similar to the multiprocessing Pool?
Q:Is there a Pool class for worker threads, similar to the multiprocessing module's Pool class?I like for example the easy way to parallelize a map functiondef long_running_func(p):
2015-07-13 14:39:52 1206
转载 Dead simple example of using Multiprocessing Queue, Pool and Locking
Q:I tried to read the documentation at http://docs.python.org/dev/library/multiprocessing.html but I'm still struggling with multiprocessing Queue, Pool and Locking. And for now I was able to
2015-07-13 14:17:42 500
转载 Python multiprocessing.Pool: when to use apply, apply_async or map?
来自stackoverflowQ:I have not seen clear examples with use-cases for Pool.apply, Pool.apply_async and Pool.map. I am mainly using Pool.map; what are the advantages of others?A:Back
2015-07-13 13:53:15 7411
转载 strategy pattern in Python
1.function based#!/usr/bin/env pythonimport typesdef method_property(name): def getter(self): return getattr(self, name) def setter(self, value): setattr(self, name, type
2015-07-13 11:14:47 670
转载 Prototype pattern (Python recipe)
原文链接:http://code.activestate.com/recipes/86651-prototype-pattern/http://dongweiming.github.io/python-pototype.htmlfrom copy import deepcopyclass Prototype: def __init__(self): self
2015-07-08 14:50:33 842
转载 coverage.py的覆盖率统计原理
原文出处:http://blog.theerrorlog.com/how-coverage-py-produce-coverage-statistics.html在Erlang下,用rebar可以在运行单元测试的同时调用cover模块,从而得 到单元测试的覆盖率,这是很方便的一个功能。最近发现Python下的nose也可 以通过--with-coverage选项达到类似的效果,
2015-07-08 10:18:23 6301 1
转载 ZooKeeper多种方式安装
原文出处:http://www.linuxidc.com/Linux/2014-11/109591.htmlinuxidc 出品的文章,一直这么简单易懂。赞!1、单机模式安装zookeeper1.1、创建帐号zk[root@master ~]# useradd -d /opt/zk zk[root@master ~]# echo "zk" |passwd --s
2015-07-05 17:36:57 959
转载 Understanding free command in Linux/Unix
free is a command which can give us valuable information on available RAM in Linux machine. But many new Linux users and admins misinterpret its output. In this post we will walk through its output fo
2015-06-02 17:02:39 530
转载 Linux Kernel: What is the major difference between the buffer cache and the page cache?
The page cache caches pages of files to optimize file I/O. The buffer cache caches disk blocks to optimize block I/O.Prior to Linux kernel version 2.4, the two caches were distinct: Files were in
2015-06-02 15:40:13 775
转载 linux free 命令中的 buffer & free
Short answer: Cached is the size of the page cache. Buffers is the size of in-memory block I/O buffers. Cached matters; Buffers is largely irrelevant.Long answer: Cached is the size of the
2015-06-02 15:27:40 660
转载 Folder Structure for Single Page Applications
It makes me sad to see so many people still use old, archaic folder structure for their projects. It seems that while front-end development has moved light years ahead, the structure people use did
2015-05-31 16:15:35 595
转载 What Is the Difference Between a Block, a Proc, and a Lambda in Ruby
原文链接:http://awaxman11.github.io/blog/2013/08/05/what-is-the-difference-between-a-block/感觉写的很清晰易懂,虽然不一定全面,但是我感觉还是蛮不错的,转载了下。What are blocks, procs, and lambdas?Coder Talk: Examples of clos
2015-05-17 21:21:59 925
转载 Class method differences in Python: bound, unbound and static
原文出处:http://stackoverflow.com/questions/114214/class-method-differences-in-python-bound-unbound-and-staticWhat is the difference between the following class methods?Is it that one is static
2015-05-04 09:39:10 694
转载 Python属性和方法
转载出处:http://abyssly.com/2013/08/19/python_attributes_and_methods/关于此文解释了Python新式对象的属性访问机制:函数是如何成为方法的?descriptor和property是如何工作的?如何确定方法解析顺序(method resolution order)?新式对象是从Python2
2015-05-04 09:30:58 4533
原创 Python 总结
1.如何实现自己的iter2.如何实现自己的range3.如何实现一个dict4.如何实现一个list5.如何实现类似ruby的open clas6.如何实现
2015-05-01 20:30:42 654
转载 Python的垃圾回收机制深入分析
无聊的五一,蛋疼的五一。看书吧!转载,原文链接:http://www.jb51.net/article/52229.htm一、概述:Python的GC模块主要运用了“引用计数”(reference counting)来跟踪和回收垃圾。在引用计数的基础上,还可以通过“标记-清除”(mark and sweep)解决容器对象可能产生的循环引用的问题。通过“分代回收”(gener
2015-05-01 15:03:42 696
转载 difference between Python shallow copy and deep copy
A:Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individ
2015-05-01 13:07:56 817
原创 zabbix mysql 迁移总结
之前的zabbix,item已经达到了27w,nvps达到了3.5K,高峰可以达到5K+,但是手里还有200台机器没有添加,还有若干个模板没有添加。面对如此情况,不得不对zabbix,做点啥了,zabbix的瓶颈在于mysql,首先的要点是mysql,我们的计划是mysql从sas迁移到ssd,顺便把主从同步,partition都做了。2015年4月27日下午决定做这件事,整体流程和大
2015-04-28 15:42:38 5492 5
转载 Golang channels tutorial
原文链接:http://guzalexander.com/2013/12/06/golang-channels-tutorial.htmlgolang channels 入门足矣Golang has built-in instruments for writing concurrent programs. Placing a go statement before a functi
2015-04-25 17:21:05 954
转载 channel in Go's runtime
原文链接:http://studygolang.com/articles/1806?from=timeline&isappinstalled=0那张图是我看明白channel 实现的关键下面是我之前困惑的一段代码,func main() { message := make(chan string) // no buffer count := 3 go f
2015-04-25 17:18:04 1300
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人