原创 適合配置的驗證方案

////////////////////////////////////////////////////////////////////////////// // 配置格式:I32|<1,2,3> -> int32 類型,值在1、2、3中

原创 mysql 高效的update

// 在做一些表結構blob字段的拆分整理,可是一個對於不定長度的blob字段,update操作很耗時,Google發現臨時表這種東西,大意是在mysql的內存分割出的一塊區域,並且跟隨當前session的終止自己會drop掉,很高效。-

原创 記錄:關於三目運算符 ? :

x ? y : z; // 如果y/z是有返回值的函數,會再調用一遍 y/z 返回值類型對應的拷貝構造 // 即使前面沒有寫賦值語句 // 用這種方式代替if的時候還需要關心一下拷貝構造裏面做了什麼

原创 內存的問題

最近遇到的內存問題比較嚴重,測試下來win32的程序在32機上最多可以分配出2G的內存,就會bad_alloc掉了。 下面是整理的一些查找內存使用的代碼。 #include <iostream> struct aaa { int xxx

原创 boost 序列化

#include <iostream> #include <string> #include <vector> #include <sstream> #include <boost/archive/binary_iarchive.hpp

原创 key->value Table方式取值的一種方法 (使用lambda表達式)

// name2id.h #ifndef _NAME2ID_H_ #define _NAME2ID_H_ struct name2id { const char* name; int id; }; int GetIDB

原创 mysql 觸發器實現需求

drop trigger if exists tg_bb_insert;   delimiter $$   create trigger tg_bb_insert   before insert on ceshi   FOR EACH R

原创 計算當前時間到星期N之間的時間差

#include <iostream> #include <string> #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/pos

原创 ENSURE方式的log

#include <iostream> #include <sstream> //---------------------------------------------// // ENSURE 方式的log //--------

原创 簡易版的隨機地圖方法,適合少數場景

簡易版的隨機地圖方法,適合少數場景 int array_1[][4] = { {1, 1, 1, 1}, {3, 3, 3, 3}, {5, 5, 5, 7}, }; int array_2[][5] =

原创 環緩衝模擬實現

class CLoopBuffer { private: char* m_pBegin; char* m_pEnd; char* m_pNextRead; char* m_pNextWrite; unsigned i

原创 vim 另存搜索項

:redir > xxx.txt :g/aaa/p :redir END redir 指定緩衝區結束寫入的文件 g/aaa/p搜索並顯示包含aaa的行(放入緩衝區) redir END 寫入指定文件 linux 緩衝區 cat >

原创 Function & #define Function

我們經常定義#define的宏,比如#define MIN(x, y) (((x) < (y)) ? (x) : (y)) 用來返回較小的一個值,很

原创 std::map特性的小技巧

typedef std::pair<unsigned int, int > KEY; std::map<KEY, int> mapTest; void FuncTest() { auto FnInsert = [&](unsigned

原创 union 應用

// 用在向量裏 struct stVec { union { struct { unsigned int x, y, z; }; struct { unsigned int xyz[3]; }