This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This code pieces shows how to use the intrusive_ptr in the boost 1.55 | |
* | |
*/ | |
#include <boost/smart_ptr.hpp> | |
#include <boost/smart_ptr/intrusive_ref_counter.hpp> | |
/** | |
* Define our own counter and the intrusive_ptr_add_ref(), intrusive_ptr_release() | |
* function for intrusive_ptr<Test1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* parse csv from file or string | |
* | |
*/ | |
#ifndef _CSV_PARSER_HPP | |
#define _CSV_PARSER_HPP | |
#include <iostream> | |
#include <string> | |
#include <fstream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
using std::string; | |
std::string hexPrint( const char* s, int n ) { | |
std::string result; | |
char buf[4]; | |
for( int i = 0; i < n; i+= 16 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hiredis.h> | |
#include <streambuf> | |
#include <iostream> | |
#include <cstring> | |
class redis_streambuf: public std::streambuf { | |
public: | |
explicit redis_streambuf( redisContext* context, const char* key, std::size_t buf_size = 2048 ) | |
:context_( context ), | |
key_( key ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------- | |
# | |
# Project created by QtCreator 2014-06-24T03:02:08 | |
# | |
#------------------------------------------------- | |
QT += core | |
QT -= gui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get these files and copy it to a directory | |
# Get a .png file and rename it to coffee.png and also put the the same directory as the source file | |
# compile and run it with command: | |
$ java -cp . WindowNotifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
std::size_t read_bytes( std::istream& in, char* buf, std::size_t len ) { | |
std::size_t n = 0; | |
while( len > 0 && in.good() ) { | |
in.read( &buf[n], len ); | |
int i = in.gcount(); | |
n += i; | |
len -= i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CPP = g++ | |
INCS = -I$(ZK_DIR)/src/c/include -I$(ZK_DIR)/src/c/generated | |
LIBS = -L$(ZK_DIR)/src/c/.libs -lzookeeper_mt -lpthread | |
CXX_FLAGS = -std=c++11 | |
all: barrier | |
barrier: ZkBarrierTest.o | |
$(CPP) -o barrier ZkBarrierTest.o $(LIBS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CPP = g++ | |
INCS = -I$(ZK_DIR)/src/c/include -I/home/ochinchina/zookeeper-3.4.6/src/c/generated | |
LIBS = -L$(ZK_DIR)/src/c/.libs -lzookeeper_mt -lpthread | |
CXX_FLAGS = -std=c++11 | |
all: leader | |
leader: ZkLeaderElection.o | |
$(CPP) -o leader ZkLeaderElection.o $(LIBS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <zookeeper.h> | |
#include <iostream> | |
#include <string> | |
#include <unistd.h> | |
#include <mutex> | |
#include <condition_variable> | |
#include <sstream> | |
class ZkQueue { | |
public: |
OlderNewer