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 / BoostPoolTest.cpp
Created January 20, 2015 08:47
C++ library boost pool & object_pool usage demo
#include <boost/pool/pool.hpp>
#include <boost/pool/object_pool.hpp>
#include <iostream>
class TestObject {
public:
TestObject( int i = 0, int j = 0)
:i_( i ),
j_( j )
{
@ochinchina
ochinchina / docker_proxy_ubuntu.txt
Last active August 29, 2015 14:14
pull docker image behind firewall in ubuntu
edit file /etc/default/docker and set the http_proxy properly
or
edit file /etc/default/docker.io and set the http_proxy
then restart the docker.io like:
$ sudo service docker.io restart
@ochinchina
ochinchina / boost_1.39_gcc_4.8.2.txt
Created March 13, 2015 05:14
compile C++ library boost 1.39 under gcc 4.8.2
1) apply patch to boost/config/stdlib/libstdcpp3.hpp, add the line 37 after line 36
33 33
34 34 #ifdef __GLIBCXX__ // gcc 3.4 and greater:
35 35 # if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
36 || defined(_GLIBCXX__PTHREADS)
36 || defined(_GLIBCXX__PTHREADS) \
37 || defined(_GLIBCXX_HAS_GTHREADS)
37 38 //
38 39 // If the std lib has thread support turned on, then turn it on in Boost
@ochinchina
ochinchina / attribute.py
Last active August 29, 2015 14:17
python study example
# this python program demo the __setattr__ and __getattr__
class AttributeDemo:
#set one field of object
def __setattr__(self, name, value):
#set the field value
self.__dict__[name] = value
#the __getattr__ should return a method
def __getattr__(self, name ):
@ochinchina
ochinchina / comple_boost_to_32_bit_under_64bit_linux
Created March 20, 2015 09:21
compile boost 32-bit library under 64-bit environment
1) For the boost 1.39, we can compile 32-bit boost library using following command:
$ ./bjam -a address-model=32 architecture=x86 variant=debug threading=multi link=shared runtime-link=shared
the most important flag is: "address-model=32 architecture=x86", if only set the address-model to 32, the gcc compiler still can't compile 32bit library. we must also set the architecture to x86
@ochinchina
ochinchina / CalculatorHandler.java
Last active August 29, 2015 14:19
thrift 0.8 tutorial aysnc server & client
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@ochinchina
ochinchina / vim_syntax_highlightining.md
Last active August 29, 2015 14:19
How to enable/disable the syntax highlighting in vim

After installing vim editor to Raspberry pi, when I open a java source file, no java syntax is highlight. After google the internet, vim provides some command to enable the syntax highlighting.

###enable/disable the syntax highlighting in the vim

enable the hightlighting, in the vim we just need to enable it like

:syntax on

if want to disable it, just need to

@ochinchina
ochinchina / try_docker_swarm.md
Last active August 29, 2015 14:20
try docker swarm in the docker 1.5 under ubuntu 14.04 LTS

###install the swarm

$ sudo docker pull swarm

###change the docker start options

change the DOCKER_OPTS in /etc/default/docker ( in ubuntu ) or /var/lib/apps/docker/1.6.1.002/etc/docker.conf ( in ubuntu core ) to "-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"

@ochinchina
ochinchina / thrift_0.8.0_arch_linux_rpi.md
Last active December 29, 2015 18:21
compile thrift-0.8.0 in arch linux for raspberry pi2

###clone the thrift

$ git clone https://github.com/apache/thrift.git

###checkout the thrift-0.8.0

$ cd thrift
$ git checkout thrift-0.8.0
@ochinchina
ochinchina / ubuntu_core_in_openstack.md
Last active August 29, 2015 14:21
ubuntu core in openstack

###download the ubuntu core image

download the ubuntu core image like:

$ wget http://releases.ubuntu.com/15.04/ubuntu-15.04-snappy-amd64-generic.img.xz

$ unxz ubuntu-15.04-snappy-amd64-generic.img.xz