Skip to content

Instantly share code, notes, and snippets.

View ochinchina's full-sized avatar

Steven Ou ochinchina

  • NOKIA Chengdu, China
View GitHub Profile
@ochinchina
ochinchina / IntrusivePtrExample.cpp
Created June 3, 2014 04:25
intrusive_ptr in boost 1.55
/**
* 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>
@ochinchina
ochinchina / HexPrint.cpp
Created June 18, 2014 05:11
convert a binary string to HEX format
#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 ) {
@ochinchina
ochinchina / redis_streambuf.hpp
Last active August 29, 2015 14:02
implement std::streambuf with redis as storage. This piece code depends on the redis c client library hiredis
#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 ),
@ochinchina
ochinchina / QtDynamicInvokeTest.pro
Created June 25, 2014 06:33
Demo the QT dynamic invokes
#-------------------------------------------------
#
# Project created by QtCreator 2014-06-24T03:02:08
#
#-------------------------------------------------
QT += core
QT -= gui
@ochinchina
ochinchina / ReadMe
Last active August 29, 2015 14:03
Demo the System Tray in java
# 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
@ochinchina
ochinchina / ZkQueueTest.cpp
Created July 14, 2014 02:05
The zookeeper queue implementation using C API
#include <zookeeper.h>
#include <iostream>
#include <string>
#include <unistd.h>
#include <mutex>
#include <condition_variable>
#include <sstream>
class ZkQueue {
public:
@ochinchina
ochinchina / FoundationDBCTest.cpp
Created July 22, 2014 07:35
The foundationdb C API test
#define FDB_API_VERSION 200
#include <foundationdb/fdb_c.h>
#include <iostream>
#include <thread>
#include <string>
#include <unistd.h>
void init() {
fdb_error_t err = fdb_select_api_version( FDB_API_VERSION );
@ochinchina
ochinchina / dockerBehindProxyInCoreOs
Last active August 29, 2015 14:06
docker in coreos usage
If the coreos is deployed behind a proxy, we can simply use following steps to make docker work:
1) copy the /usr/lib/systemd/system/docker.service to /etc/systemd/system/ directory
sudo cp /usr/lib/systemd/system/docker.service /etc/systemd/system/
2) edit the /etc/systemd/system/docker.service file and add
Environment="HTTP_PROXY=http://proxy.example.com:8080"
@ochinchina
ochinchina / VirtualBox.xml
Last active August 29, 2015 14:06
core-os fleet with own deployed discovery service
<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.innotek.de/VirtualBox-settings" version="1.12-linux">
<Global>
<ExtraData>
@ochinchina
ochinchina / HowToSetProxyFor boost2docker
Last active August 29, 2015 14:06
set proxy for boot2docker
1) edit file /var/lib/boot2docker/profile, and add the proxy setting lines to the file
export HTTP_PROXY=http://<proxy host>:<port>
export HTTPS_PROXY=https://<proxy host>:<port>
2) restart the docker
/etc/init.d/docker restart