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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / thread.go
Created January 7, 2015 08:30
go routine practice
// Goroutine practice
package main
import (
"fmt"
"strconv"
"sync"
"time"
)
/*
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
/*
* Copyright (c) 2014 by its authors. Some rights reserved.
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software