- 博客(8)
- 收藏
- 关注
原创 golang源码1- bufio
bufio 官方说明 "Package bufio implements buffered I/O. " , 缓存 I/O。 Reader type Reader struct { buf []byte // 缓冲区, 最小长度为16字节 rd io.Reader // 底层I/O r, w int ...
2018-11-07 23:34:31
236
原创 PRF(伪随机数函数)
PRF(伪随机数函数) 序 看到自己曾经写过一个随机数的文章,当然内容没什么太有意思的东西。今天想着好像也没什么可写的,那么就写个已经存在的PRF吧。 随机数在服务端应用挺广泛的,经常会使用到,但是大体上都是调用系统函数。有一些的实现就不是很安全,比如那个简单的以时间为种子的随机数~~。 更安全的随机数可以通过硬件来获取,当然这得需要相应的硬件支持。其实,在TLS规范中已经提供了一种不错的伪随机生...
2018-11-05 23:16:21
14441
3
原创 感悟
最近烦心的事情还挺多。今晚,不知道怎么回事,想起来登陆下优快云,进来就发现几篇稚嫩的文章~~,甚是感慨,从2012到2018年底,时间过的好快。 现在想来这种记录的方式挺好,若干年回看的时候,突然惊呼,“欧,我曾经做过这些东西啊。当年好嫩啊。好有意思啊。”。 相对于自己的私密空间,这种分享的空间,真是别有风情。 时间一去不复返,回忆总会消散,且行且珍惜。...
2018-11-05 22:16:05
166
原创 python&ruby 与控制台的交互(自动输入密码)
最近工程频繁更新,另外,为了方便,自己维护了release 和 debug两个版本. 那么频繁的去update bitbucket 真是个麻烦事。还好我们可以写脚本。 这个脚本并不难写,最大的问题就是如何自动输入bitbucket密码,恩,这样更省事。 python中有个pexpect模块,但是该模块还不能在py3上使用,pexpect-u 我没有试成功. 自己比较喜欢py3
2013-02-16 21:07:27
903
原创 insertion sort
//insertion sort is an efficient algorithm for sorting a small number of elements. 1) void insertion_sort(int a[],int n) { int key,j; for(int i = 1; i < n; ++i) { key = a[i]; j = i-1;
2012-05-02 10:27:04
395
原创 copy memory & release array
// 1. copy memory /// allocates memory and copy from source array /// \param dst Destination /// \param src Source /// \param numT number of array elements template void DeepCopy(T** dst, con
2012-03-22 22:29:28
293
原创 system info & cpu core id & thread active
//1. get core id unsigned char get_real_core_id() { #ifdef _WIN64 int temp[4] = {0x0}; __cpuid(temp, 1); return (unsigned char)((temp[1]>>24)&0xff); #else unsigned int ebx_value = 0; __
2012-03-22 22:20:00
559
原创 产生随机数
//设置随即种子 srand((unsigned)time(NULL)) // 范围 [range_min,range_max) (double)rand() / (RAND_MAX + 1) * (range_max - range_min) + range_min; [range_min,range_max] 1. (double)rand() / (RAND_M
2012-02-21 20:42:12
299
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人