- 博客(80)
- 收藏
- 关注
原创 epoll多进程回显服务器示例
#include#include#include#include#include#include#include #include#include #include#include#include#include#include #include #include#include #include #include#include#includeusing
2014-03-26 14:01:03 866
原创 一个epoll多进程服务器示例
#include#include#include#include#include#include#include #include#include #include#include#include#include#include #include #include#include #include #includeusing namespace std;#
2014-03-25 15:49:09 941
原创 螺旋数组小计
#includeusing namespace std;#include #define M 11 void show(int arr[][M], int i, int js, int size) { for(int index = 0x00; index < size; index++) { for(int j = 0x00; j < size;j++) std:
2014-03-24 13:09:16 705
原创 python操作excel 批量发送工资信息
#encoding:gbkimport sysreload(sys)sys.setdefaultencoding( "gbk" )import xlrdimport xlwtimport smtplib import stringimport osfrom email.mime.text import MIMEText mail_host="smtp.163.com"
2014-03-24 10:54:14 1980
原创 三角矩阵一则
#include#include#include#includeusing namespace std;void show_msg(int* arr, int size, int max_line){ int ts = 0x00; for(int index = 0x00; index < max_line; index++) { int tmp = max_line;
2014-03-20 17:10:02 760
原创 GOLANG 端口扫描示例
这段代码主要来自网络,源代码存在问题,现在已经修复,可以直接编译运行package mainimport ( "net" "fmt" "os" "runtime" "time" "strconv")func loop(startport, endport int, inport chan int) { for i := startport; i <= endpo
2014-02-14 16:25:06 2602
原创 一个golang http包自带的绝佳示例
package mainimport ( "bytes" "expvar" "flag" "fmt" "io" "log" "net/http" "os" "os/exec" "strconv" "sync")// hello world, the web servervar helloRequests = expvar.NewInt("hello-request
2014-02-14 12:52:18 4754
原创 golang waitgroup 及 sync.Once 示例
下面代码修改自golang示例源码package mainimport ( "fmt" "sync" "net/http" "io/ioutil" "log")func GetDemo(addr string) { res, err := http.Get(addr) if err != nil { log.Fatal(err) } robots, err :=
2014-02-14 11:28:32 2649
转载 制作gif图片
虽然曾经被认为是过时的艺术形式,但动态GIF图片现在复苏了。如果你还没有留意到,不少在线分享和社交网络网站都开始支持动态GIF图片,例如,Tumblr,Flickr,Google+和Facebook的部分地方。由于在消费和共享上的容易,GIF的动画已经成为主流互联网文化的一部分了。所以,你们中的一些人会好奇怎样才能生成这样的动态GIF图片。已经有各种各样专门用来生成动态GIF图
2014-02-14 10:52:22 1054 1
原创 golang flag 用法示例
file.gopackage mainimport "flag"import "fmt"import "os"func main() { if len(os.Args) < 2 { fmt.Println("too less param") return } var ip = flag.Int("flagname", 1234, "help mess
2014-02-14 10:25:57 3013
原创 cgo 用法示例
file.go内容如下package main/*#cgo linux LDFLAGS: -lrt#include #include #include #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)int my_shm_open(char *name) { return shm_open(nam
2014-02-14 10:23:42 1528
原创 golang发送邮件,带附件
package mainimport ( "github.com/scorredoira/email" "net/smtp" "log" ) func main() { m := email.NewMessage("Hi", "this is a test") m.From = "jackma_xx@126.com" m.To = []string{"x
2014-02-14 10:03:20 4980 1
原创 golang 发送邮件(不带附件)
package mainimport ("log""net/smtp""flag""fmt""strings")var ( subject = flag.String("s","","subject of the mail") body = flag.String("b", "", "body of email") reciMail = flag.String("m","
2014-02-14 09:55:03 1241
原创 关于golang 文件映射的API
var mapper = &mmapper{ active: make(map[*byte][]byte), mmap: mmap, munmap: munmap,}func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
2014-02-14 09:52:11 3254
原创 golang tcp 回显服务器示例
golang代码服务器:package mainimport ( //"io" "log" "net" "time" "fmt" "runtime")func main() { runtime.GOMAXPROCS(4)//设置cpu个数 // Listen on TCP port 2000 on all interfaces. l, err := net.Listen
2014-02-14 09:50:40 1910
原创 golang 自定义错误示例
package mainimport ( "fmt" "time")// MyError is an error implementation that includes a time and message.type MyError struct { When time.Time What string}func (e MyError) Error() string { r
2014-02-14 09:46:56 3491
原创 golang zip 操作示例
下面的代码,来之golang的示例源码,其中涉及的常见zip文件,修改了部分代码,在ExampleWriter中添加了如下fw, err := os.Create("/home/xxx/mem_sub/go/z.zip") if err != nil { //panic(err) fmt.Println(err) return } defer
2014-02-14 09:44:48 3606
原创 golang 操作mysql测试用例
package mainimport ("fmt""database/sql" _ "github.com/go-sql-driver/mysql")type TestMysql struct {db * sql.DB}func Init()(*TestMysql, error) { test
2014-02-14 09:39:11 1885
转载 NOTEPAD++ 配置golang 高亮显示
go自带了notepad++的语法高亮配置,只需要在notepad++里导入即可:1. 打开go的安装目录misc\notepadplus下的userDefineLang.xml,把开头的和结尾的的注释取消掉2. 把misc\notepadplus目录下的go.xml放到notepad++安装目录下的plugins\APIs目录里3.
2014-02-14 09:38:06 1449
原创 GOLANG 遍历文件夹
package mainimport ("fmt". "io/ioutil")func readAll(path string) []string { var all_file []string finfo, _ := ReadDir(path) for _ ,x := range finfo { real_
2014-02-14 09:36:39 1594
原创 shell拷贝依赖库文件
ldd libcmylib.so | grep -e '=>' | awk '{ print ($3)}' | grep "so" | xargs -I {} cp {} /home/savedir/
2013-11-28 15:32:13 1139
转载 linux zip cmd
linux zip 命令详解 功能说明:压缩文件。 语 法:zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b ][-ll][-n ][-t ][-][压缩文件][文件...][-i ][-x ]补充说明:zip是个使用广泛的压缩程序,文件经它压缩后会另外产生具有".zip"扩展名的压缩文件。 参 数: -A 调整可执行的自动解压缩文件。
2013-11-28 14:11:55 821
原创 关于asio的interrupted
asio 的io_service中运用epoll的地方,除了epoll自身等待触发正常事件和以大小堆为代表的timer事件,还有一种中断事件在文件 boost\asio\detail\epoll_reactor.hpp的函数中void epoll_reactor::run(bool block, op_queue& ops),有如下流程代码: // Calculate a timeo
2013-11-08 15:24:09 1412
翻译 ipc 通讯之 ipcs、ipcrm摘录
NAME ipcs - provide information on ipc facilitiesSYNOPSIS ipcs [ -asmq ] [ -tclup ] ipcs [ -smq ] -i id ipcs -hDESCRIPTION ipcs provides information on
2013-11-07 13:36:59 814
原创 ipc 通讯之ftok
man ftok 记录如下:NAME ftok - convert a pathname and a project identifier to a System V IPC keySYNOPSIS # include # include key_t ftok(const char *pathname, i
2013-11-07 13:15:34 883
转载 git 使用简记
1,branch的建立及使用git clone user@192.168.0.136:/media/projiect/omap4/nexttab/kernel kernel/android3.0/ //下载内核源码git checkout -b xx //建立分支并切换到分支xxgit branch //查看当前分支的状态git
2013-11-05 12:34:51 743
原创 当mmap遇到sigbus
今天遇见程序出现sigbus的问题。仔细查看了程序的源码,应该没什么逻辑问题。程序每次运行到memcpy(&sum_cnt,addr,data_len)的时候就sigbus了~真是奇怪啊,查看了addr不为空。addr使用的是文件映射之后得到的内存地址:如下:map_addr 就是映射之后所得。bool scan_mapfile(char* file_path, c
2013-11-04 15:09:11 1633
转载 linux 进程前后台切换
当你用shell启动一个程序时,往往他是在前台工作的。 例如经常用PUTTY连接到远程服务器执行脚本的时候,如果本地网络中断后,这个时候前台进程就结束了,比较的懊恼,必须重新执行。因此有必要进行前后台进程的切换。例如直接在终端里输入firefox,那么会打开firefox,但当你关闭此终端或者ctrl+c强制终止时,firefox也随机关闭了。你可以在执行时后面加一个&,这样就在后台工作了。
2013-11-01 11:16:28 865
原创 zeromq 利用protobuf通信
利用zeromq进行编程时候,服务器和客户端的通信,利用protobuf时候之前的项目里面,需要对protobuf进行编码解码
2013-10-17 17:12:01 3826
原创 ICEGRID通信截图
图中显示了客户端和icegrid通信的大体流程先进行tcp的三次握手(客户端和icegrid)客户端获取到icegrid返回的真正服务端的通信端口等信息之后,便与该服务器端进行tcp三次握手之后进行数据交互
2013-10-17 16:30:15 813
原创 peerconnection_server 的编译
项目中需要修改webrtc的peerconnection_server,之前的环境已经没有了,只得重新部署环境。源码是下载到windows环境中的,linux机器不能联网。上传到linux机器之后1.gclient runhooks --force #生成linux下的工程配置文件,即makefile2.make peerconnection_server在执行到现在这一步的时
2013-10-12 11:05:26 1153
转载 makefile 常用函数
在Makefile中可以使用函数来处理变量,从而让我们的命令或是规则更为的灵活和具有智能。make所支持的函数也不算很多,不过已经足够我们的操作了。函数调用后,函数的返回值可以当做变量来使用。一、函数的调用语法函数调用,很像变量的使用,也是以“$”来标识的,其语法如下: $()或是 ${}这里,就是函数名,make支持的函数不多。是函数的参数,参数间以逗
2013-10-12 10:50:06 530
转载 c算法100例
【程序1】 题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。 2.程序源代码: main() { int i,j,k; printf("\n"); for(i=1;ifor(j=1;jfor (k=1;k{
2013-09-25 20:47:03 901
转载 使用 Python 实现跨平台的安装程序
引言我们在使用类 Unix 系统时,经常会用到一些以“.bin”或者“.run”结尾的安装程序 (Installer)。(为描述方便,这里我们使用“Bin 安装程序”来泛指这种安装程序。)Bin 安装程序不依赖于系统发行版自己的包 (package) 管理器来实现应用程序的安装和卸载,而是完全自己控制安装的整个过程,程序卸载的时候需要用户执行应用程序安装目录下的卸载脚本来完成。Bin 安装
2013-09-25 20:42:17 1150 1
转载 关于IOCP那些事
HTTP Server design with I/O Completion Ports encompases:I/O Completion port queueThread PoolsWindows Sockets (WinSock)Asynchronous socket read/writeAsynchronous file read/write Buffer Memo
2013-09-24 23:36:57 1493
转载 编译WEBRTC
Before you startFirst, be sure to install the prerequisite software.The currently supported platforms are Windows, Mac OS X, and Linux.Getting the code and buildingCreate a working directo
2013-09-22 21:17:10 860
原创 thrift 安装
/configure --prefix=/home/mm/install/thrift09x/ --with-libevent=/home/mm/install/libevent/ --without-php指定了libevent之后,能够支持异步服务
2013-09-11 14:17:22 832
翻译 thrift特点介绍
Apache Thrift Features· interface description language - Everything is specified in an IDL file from which bindings for many languages can be generated. See Thirft IDL· language bindings - Thrift
2013-09-11 14:14:39 1180
翻译 thrift 网络结构说明
Thrift network stackSimple representation of the Apache Thrift networking stack +-------------------------------------------+ | Server | | (single-threaded
2013-09-11 14:12:58 903
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人