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
/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license //@ sourceMappingURL=jquery.min.map */ (function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",
@chenchun
chenchun / vxlan_multicast.sh
Created December 29, 2015 16:35
vxlan using l3 multicast to resolve location
# set up on host1 192.168.33.11, 08:00:27:f8:73:79
ip link add vxlan0 type vxlan id 42 group 239.1.1.1 dev eth1 dstport 4789
ip link set vxlan0 address 54:8:20:0:0:1
ip address add 10.0.0.1/8 dev vxlan0
ip link set up vxlan0
# set up on host2 192.168.33.12, 08:00:27:d9:18:aa
ip link add vxlan0 type vxlan id 42 group 239.1.1.1 dev eth1 dstport 4789
ip link set vxlan0 address 54:8:20:0:0:2
ip address add 10.0.0.2/8 dev vxlan0
@chenchun
chenchun / irc-0
Last active November 18, 2015 03:12
irc, you need to be identified with services
/msg nickserv register [password] [email]
/msg nickserv identify [password]
@chenchun
chenchun / CMakeLists.txt
Last active September 9, 2019 15:03
play with different kernel verison #cmake
cmake_minimum_required(VERSION 3.8)
project(linux C)
include_directories(include)
file(GLOB_RECURSE ALL_FILES
"*.h"
"*.c"
)
@chenchun
chenchun / compact_vmdk.md
Last active July 13, 2020 08:17
Add another disk for your vagrant box, dd

http://vladimir-ivanov.net/how-to-compact-virtualboxs-vdmk-file-size/

  1. Fill the free space with zeros VirtualBox only knows that the space is really free if it’s been set to zero, and standard deletion won’t do this. Login into the virtual machine and run the following command:
cat /dev/zero > zero.fill; sync; sleep 1; sync; rm -f zero.fill
  1. compact vmdk
@chenchun
chenchun / bond_vlan_bridge.md
Last active June 6, 2022 08:41
Linux vlan over bridge demo, VLAN bond bridge
@chenchun
chenchun / c_invoke_go.md
Last active November 21, 2018 09:02
Go invoke c code, unsafe Pointer, invoke asm code
package main
import (
"net"
"runtime"
"fmt"
"github.com/vishvananda/netns"
"os"
)
@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

@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