Skip to content

Instantly share code, notes, and snippets.

View chendotjs's full-sized avatar

Chen Yaqi chendotjs

  • Shanghai
  • 17:24 (UTC +08:00)
View GitHub Profile
@chendotjs
chendotjs / complie command
Created June 27, 2017 09:17
memory mock test
g++ -Wl,--wrap=malloc -Wl,--wrap=free test.cpp
@chendotjs
chendotjs / eventpoll.c
Last active March 2, 2018 15:17
a commented epoll implemention in kernel
/*
 *  fs/eventpoll.c (Efficient event retrieval implementation)
 *  Copyright (C) 2001,...,2009  Davide Libenzi
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Davide Libenzi <davidel@xmailserver.org>
@chendotjs
chendotjs / godoc.vim
Last active August 24, 2019 15:25
goman
" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
" ~/.vim/syntax/godoc.vim
if exists("b:current_syntax")
finish
endif
noremap <buffer> q :q!<CR>
@chendotjs
chendotjs / usb_example.cc
Created November 27, 2018 14:09
usb_example for pixelx
// https://www.beyondlogic.org/usbnutshell/usb5.shtml
#include <bits/stdc++.h>
#include <libusb-1.0/libusb.h>
using namespace std;
#define PIXELX 1
#define ABORT_ON(ret, msg) \
do { \
if (ret < 0) { \
function e() {
set -eu
ns=${2-"default"}
pod=`kubectl -n $ns describe pod $1 | grep -A10 "^Containers:" | grep -Eo 'docker://.*$' | head -n 1 | sed 's/docker:\/\/\(.*\)$/\1/'`
pid=`docker inspect -f {{.State.Pid}} $pod`
echo "entering pod netns for $ns/$1"
cmd="nsenter -n --target $pid"
echo $cmd
$cmd
}
@chendotjs
chendotjs / skbtracer.c
Last active May 9, 2024 11:12
ebpf-skbtracer
#include <bcc/proto.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/ipv6.h>
#include <uapi/linux/icmp.h>
#include <uapi/linux/tcp.h>
#include <uapi/linux/udp.h>
#include <uapi/linux/icmpv6.h>
#include <net/inet_sock.h>
#include <linux/netfilter/x_tables.h>
kind: Deployment
apiVersion: apps/v1
metadata:
name: simple-http
spec:
replicas: 2
selector:
matchLabels:
app: simple-http
template:
@chendotjs
chendotjs / l3.png
Last active May 11, 2020 04:10
network-stack-callvis
l3.png
@chendotjs
chendotjs / simple-drop-kp.bt
Last active January 14, 2021 06:05 — forked from florianl/flow.bt
simple bpftrace script to print out drop packet
#!/bin/bpftrace
#include <linux/skbuff.h>
#include <linux/ip.h>
BEGIN
{
printf("follow the white rabbit\n");
}
@chendotjs
chendotjs / sysctl.conf
Created April 1, 2021 07:50 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2