
Linux Programing
斐然成章
这个作者很懒,什么都没留下…
展开
-
Python: Flask is a micro webdevelopment framework for Python.
Example#!/usr/bin/env python# encoding: utf-8from flask import Flaskapp = Flask(__name__)@app.route('/')def index(): return 'hello world'if __name__ == '__main__': app.run(debug=Tru原创 2018-01-08 11:56:58 · 324 阅读 · 0 评论 -
Python: GEvent
gevent is a coroutine -based Python networking library that uses greenlet to provide a high-level synchronous API on top of the libev event loop.gevent pypi/gevent 基于协程的Python网络库gevent介绍原创 2018-01-08 12:22:41 · 425 阅读 · 0 评论 -
HTTP状态码
状态码 含义 200 请求已成功,请求所希望的响应头或数据体将随此响应返回。 201 请求已经被实现,而且有一个新的资源已经依据请求的需要而建立,且其 URI 已经随Location 头信息返回。假如需要的资源无法及时建立的话,应当返回 ‘202 Accepted’。 202 服务器已接受请求,但尚未处理。正如它可能被拒绝一样,最终该请求可能会也可能不会被转载 2018-01-16 14:58:50 · 832 阅读 · 0 评论 -
GO: 类型断言
go里面的类型断言写法:x.(T)其中x为interface{}类型 T是要断言的类型。 类型断言有个非常好的使用场景:当某个类型为interface{}的变量,真实类型为A时,才做某件事时,这时可以使用类型断言 下面有个例子。只有当某个interface{}的类型 存储的是int时才打印出来。package mainimport ( "fmt" "ma转载 2018-01-05 15:00:58 · 1008 阅读 · 0 评论 -
GO: struct tag Examples
获取tag的内容是利用反射包来实现的,直接上 Example Example01package mainimport ( "fmt" "reflect")type People struct { Name string "name" //引号里面的就是tag Age int "age"}type S struct { F string `species原创 2017-12-28 18:37:46 · 434 阅读 · 0 评论 -
GO: golang sync WaitGroup
golang 的 sync 包,有一个很有用的功能;就是 WaitGroup 。 WaitGroup的用途:它能够一直等到所有的goroutine执行完成,并且阻塞主线程的执行,直到所有的goroutine执行完成。WaitGroup总共有三个方法:Add(delta int),Done(),Wait()。简单的说一下这三个方法的作用。Add:添加或者减少等待goroutine的数量Done:转载 2017-12-28 16:47:46 · 406 阅读 · 0 评论 -
GO: 语言并发与学习笔记
这这两篇文章写的很好,记得看评论 :) GO语言并发与并行学习笔记(一) GO语言并发与并行学习笔记(二)转载 2017-12-26 16:34:19 · 281 阅读 · 0 评论 -
Go: Logrus is a structured logger for Go (golang)
Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger.原创 2017-12-26 10:48:24 · 610 阅读 · 0 评论 -
Go: Yaml support for the Go language
go run yaml_v2.go原创 2017-12-22 15:37:31 · 329 阅读 · 0 评论 -
Linux信号 之 pthread_sigmask函数使用
#include #include #include #include #include #include /* Simple error handling functions */#define handle_error_en(en, msg) \ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)s原创 2014-06-09 15:50:46 · 15824 阅读 · 0 评论 -
类Shell程序的简化实现(from 《Unix环境高级编程》)
此程序是一个类shell程序的简化实现 From:《UNIX环境高级编程》(1-5) #include "apue.h"#include intmain(void){ char buf[MAXLINE]; /* from apue.h */ pid_t pid; int status; printf("%% "); /* print prom原创 2010-03-18 16:06:00 · 1039 阅读 · 0 评论 -
Python: 装饰器
Example#!/usr/bin/env pythonimport functoolsdef log_v1(arg): if callable(arg): func = arg @functools.wraps(func) def wrapper(*args, **kw): print 'call %s(原创 2018-01-08 16:31:01 · 311 阅读 · 0 评论