Skip to content

Instantly share code, notes, and snippets.

View corvofeng's full-sized avatar
Do You Want To Build A Snowman.

corvofeng corvofeng

Do You Want To Build A Snowman.
View GitHub Profile
export RTE_SDK=/usr/share/dpdk
make
sudo ./build/l2fwd
@corvofeng
corvofeng / tmux.conf
Last active March 15, 2022 01:35 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@corvofeng
corvofeng / redis_thread.c
Created April 4, 2018 01:27
redis双线程. 一个线程用来PUSH, 另一个线程为SUBSCRIBE
/*
*=======================================================================
* Filename:redis_thread.c
*
* Version: 1.0
* Created on: April 03, 2018
*
* Author: corvo
*=======================================================================
*/
@corvofeng
corvofeng / timer_test.c
Created March 29, 2018 13:47
使用Linux中的信号, 每隔三秒发送一次定时启动handler函数
/* ch14-timers.c ---- demonstrate interval timers */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <signal.h>
#include <sys/time.h>
/* handler --- handle SIGALRM */
@corvofeng
corvofeng / net_hellp.c
Created March 29, 2018 01:43
最近在Linux上编程, inet_ntoa,和inet_aton之间的转换和使用
#include <stdio.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <string.h>
#include <arpa/inet.h> // 如果不添加这个头文件, inet_ntoa获取的字符串也无法读取
int main(int argc, char *argv[])
{
struct in_addr ip_src; // 32bits 源IP地址
@corvofeng
corvofeng / latency.markdown
Created March 9, 2018 08:15 — 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

@corvofeng
corvofeng / cond_test.cpp
Last active February 19, 2018 11:35
信号量使用的测试程序
/**
* 测试环境:
* Archlinux 4.15.3-2
* GCC 7.3.0
*
* g++ -std=c++11 -g -pthread con_test.cpp
*
* 原文链接: https://corvo.myseu.cn/2018/02/17/2018-02-17-Spurious-Wakeup/
*/
@corvofeng
corvofeng / client.c
Created January 27, 2018 10:28
Client-Server
/**
* 编译:
* gcc client.c -o client
*
* 运行:
* ./client 127.0.0.1 12345 <string>
*/
#include "stdio.h"
#include "sys/socket.h"
#include "arpa/inet.h"
@corvofeng
corvofeng / _vimrc
Last active April 30, 2018 02:26
Gvim 配置, 欢迎在Linux上试用
" Just for windows gvim, now maybe you could use it on linux.
colorscheme desert
set nu
" Windows上与Linux上配置是不同的
if has('win32')
set guifont=consolas:h12
@corvofeng
corvofeng / config.fish
Last active January 7, 2018 11:06
fish_proxy_setting
# When i use fish shell, I need export proxy and unset proxy like in bash
# No Proxy
function noproxy
#/usr/local/sbin/noproxy #turn off proxy server
#unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
set -g -e http_proxy
set -g -e https_proxy
set -g -e HTTP_PROXY