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 / NettyConnection.java
Last active January 11, 2024 01:32
netty client reconnect if the connection is lost or the server is not started
package com.nokia.nls.nmif;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@ochinchina
ochinchina / centos7_in_virtualbox_behind_proxy.md
Last active August 29, 2015 14:26
install the centos7 in virtualbox behind the firewall

install the minimal centos-7 in the virtualbox

add host-only network adapter

set the ip address for enp0s3

# ip addr add 10.0.2.15/24 enp0s3
@ochinchina
ochinchina / top_jstack_thread_cpu.md
Created July 24, 2015 07:51
use linux top command and the jdk utility jstack to find which java thread consumes most CPU

use top command to find which java thread consume high CPU

Using the following command to find what java threads consume high CPU

$ top -n1 -p <pid> -H
Tasks:  47 total,   0 running,  47 sleeping,   0 stopped,   0 zombie
Cpu(s): 22.1%us,  2.2%sy,  0.0%ni, 74.8%id,  0.0%wa,  0.0%hi,  0.9%si,  0.0%st
@ochinchina
ochinchina / use_wnameless_oracle-xe-11g.md
Last active April 3, 2025 17:43
how to use wnameless/oracle-xe-11g docker image

##pull wnameless/oracle-xe-11g

$ sudo docker pull wnameless/oracle-xe-11g

##start the wnameless/oracle-xe-11g

$ sudo docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
@ochinchina
ochinchina / docker_container_inter_communication.md
Last active August 29, 2015 14:22
cross node docker container communication

This Gist demos how to make the inter communication between docker containers ( cross node)

###inter communication through Birdge

suppose there are two nodes n1: 192.168.1.1 and n2: 192.168.1.2, in the node n1 start container c1 and in the node n2 start container c2.


  --------------------         ------------------------
 |                    |        |                        |
 |      --------      |        |      ---------         |
@ochinchina
ochinchina / clear_ubuntu_unused_kernel_image.md
Created May 29, 2015 01:33
clear unused linux kernel image from /boot

###clear unused linux kernel image from /boot

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
@ochinchina
ochinchina / pipe_demo.go
Created May 28, 2015 08:13
golang: connect two commands with pipe
package main
import (
"bytes"
"io"
"os"
"os/exec"
)
func main() {
@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
@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 / 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"