Skip to content

Instantly share code, notes, and snippets.

View chenchun's full-sized avatar
🦖
go for{vacation()}

Chun Chen chenchun

🦖
go for{vacation()}
View GitHub Profile
@chenchun
chenchun / DumpClassURL.java
Created October 10, 2012 04:03 — forked from rednaxelafx/DumpClassURL.java
Using the ProtectionDomain of an InstanceKlass to see where it was loaded from
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
public class DumpClassURL extends Tool {
public void run() {
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
import sun.jvm.hotspot.utilities.*;
public class DirectMemorySize extends Tool {
@chenchun
chenchun / get_ip.sh
Last active August 29, 2015 14:10 — forked from hex108/get_ip.sh
#!/bin/bash
# Get IP for specified host using 'http://ping.eu/ping', then write it to hosts.
if [ $# -ne 1 ]; then
echo "Usage: $0 host"
echo " e.g. # $0 baidu.com"
exit 0
fi
@chenchun
chenchun / .tmux.conf
Last active January 22, 2017 08:58
linux tmux session remember script
# bind Ctrl-a as command prefix
set -g prefix C-a
unbind C-b
bind-key -r Space next-layout
bind ^z run "tmux-zoom"
@chenchun
chenchun / 0_reuse_code.js
Created October 21, 2015 02:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
## ip address info
root@6f62c03f8f5a:/go/src/github.com/docker/libnetwork# ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: br-55bac522026e: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:b4:4b:95:ee brd ff:ff:ff:ff:ff:ff
@chenchun
chenchun / docker_vxlan.sh
Last active March 21, 2020 01:42
Setup a docker-libnetwork like vxlan overlay network on two hosts manually
#!/usr/bin/env bash
function setup_overlay() {
ip netns add overlay
ip netns exec overlay ip li ad dev br0 type bridge
ip li add dev vxlan42 type vxlan id 42 l2miss l3miss proxy learning dstport 4789
ip link set vxlan42 netns overlay
ip netns exec overlay ip li set dev vxlan42 name vxlan1
ip netns exec overlay ip li set dev vxlan1 master br0
ip li add dev vetha1 mtu 1450 type veth peer name vetha2 mtu 1450
@chenchun
chenchun / latency.markdown
Created October 22, 2015 04:49 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

package main
import (
"net"
"runtime"
"fmt"
"github.com/vishvananda/netns"
"os"
)
@chenchun
chenchun / c_invoke_go.md
Last active November 21, 2018 09:02
Go invoke c code, unsafe Pointer, invoke asm code