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 / docker_1.9_on_ubuntu_14.04.md
Created September 6, 2015 08:56
install the docker 1.9-dev to ubuntu 14.04

###add patch

get the script from https://get.docker.com/ubuntu/, the script is:

# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
	apt-get update
	apt-get install -y apt-transport-https
fi
@ochinchina
ochinchina / ByteBufInputStream.java
Created December 14, 2015 02:21
netty ByteBuf to InputStream adapter
import java.io.IOException;
import java.io.InputStream;
import io.netty.buffer.ByteBuf;
public class ByteBufInputStream extends InputStream {
private ByteBuf buf = null;
private int len = 0;
@ochinchina
ochinchina / AppConfig.java
Last active December 14, 2015 09:58
spring: autowire bean to non-managed object
package org.spring.test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableLoadTimeWeaving;
import org.springframework.context.annotation.EnableLoadTimeWeaving.AspectJWeaving;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.aspectj.EnableSpringConfigured;
@Configuration
@ochinchina
ochinchina / ClassScanner.java
Created December 18, 2015 06:22
scan all the classes under a specific package recursively
import java.io.File;
import java.net.URL;
public class ClassScanner {
@FunctionalInterface
public static interface ClassProcessor {
void processClass( Class clazz ) ;
}
@ochinchina
ochinchina / remove_snapshot_in_release.md
Created March 3, 2016 06:43
remove snapshot in the apache archiva repositories/internal

if you publish a snapshot release to apache/archiva and start to browse the repository, you will get "managed repo is configured for release only" error.

To fix this, you should:

  1. login to the archiva installed machine
  2. goto the repository repositories/internal to find the component whose snapshot is pushed
  3. delete the snapshot version directory ( like "1.0-SNAPSHOT" )
  4. remove the snapshot version from maven-metadata.xml file
  5. re-generate the md5 and put it to the maven-metadata.xml.md5 like below:
@ochinchina
ochinchina / PCD8544.c
Created March 17, 2016 03:25
PCD8544 in raspberry pi
/*
=================================================================================
Name : PCD8544.c
Version : 0.1
Copyright (C) 2010 Limor Fried, Adafruit Industries
CORTEX-M3 version by Le Dang Dung, 2011 [email protected] (tested on LPC1769)
Raspberry Pi version by Andre Wussow, 2012, [email protected]
Description :
A simple PCD8544 LCD (Nokia3310/5110) driver. Target board is Raspberry Pi.
This driver uses 5 GPIOs on target board with a bit-bang SPI implementation
@ochinchina
ochinchina / rancheros_install.md
Last active May 1, 2019 06:54
rancheros installation & rancher usage

##install rancheros to disk download the rancheros from https://releases.rancher.com/os/latest/rancheros.iso start the rancheros from the downloaded rancheros.iso. After the rancheros is started, login with user/password rancher/rancher,

if your machine is behind the proxy, you can download the rancher/os:v.x.y.z from a machine which docker is installed:

$ docker pull rancher/os:v.x.y.z
$ docker save -o rancheros_v.x.y.z.tar rancher/os:v.x.y.z
@ochinchina
ochinchina / coreos_installation.md
Last active July 18, 2016 08:53
coreos installation & usage

##install coreos to the baremetal server

Prepare the cloud init configuration file like below:

#cloud-config

# include one or more SSH public keys
ssh_authorized_keys:
 - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDi9rg+WeNW2WkhBniXViHoMOJhEIK/JoIxMt6ig2Kksoot4V5oJwRs7odCVejHWaUYMhq8QsuwTejpt5172rtyQLLyd4QbwCct21+XHZul7lgjJR8EAhRBZDPHxg+c4d9gJYCQnxSxdBLYBpg2K8UQJY7jvHwpi2jjpAZQnQzJ5YYzpcyz+SjbONu8FZaqXxt7/s+O8U0OqIeCMJIeinu69xKwtCaW+ROe/kMPoMSrjcr66sRkcWVyrcPCjMI3nLoE6Ix+DB2UHK+mxnR8u5j0S3oX2AMPGZgQE/emd4Epa8KS3/Vh6I35De+RcT5+3HzJviYhxJLY7kLP3FyVsxQX ochinchina@ubuntu-1504-1
@ochinchina
ochinchina / jsonrpc_client.py
Last active July 5, 2016 02:49
json rpc in python
import requests
import json
def main():
url = "http://localhost:4000/jsonrpc"
headers = {'content-type': 'application/json'}
# Example echo method
payload = {
@ochinchina
ochinchina / boost_epoll_reactor_usage.md
Last active August 5, 2016 09:38
use the boost epoll_reactor directly

###in boost 1.39

struct BoostEpollHandler {
	BoostEpollHandler( const boost::function<bool (boost::system::error_code&, std::size_t&) >& _performHandler,
				const boost::function<void (const boost::system::error_code&, std::size_t ) >& _completeHandler )
	:performHandler( _performHandler ),
	completeHandler( _completeHandler )
	{
	}