Skip to content

Instantly share code, notes, and snippets.

View dotSlashLu's full-sized avatar

Zhang Qiang dotSlashLu

View GitHub Profile
@dotSlashLu
dotSlashLu / user_stats.py
Created April 19, 2024 03:54
code tools
import subprocess
import os
import re
import json
import logging
import argparse
from datetime import datetime
def get_author_stat(path: str, since: str, until: str) -> str:
@dotSlashLu
dotSlashLu / redbpf_dpdk_csum.rs
Created May 16, 2022 01:27
rust bpf l4 checksum ported from dpdk
use core::mem::size_of;
use redbpf_probes::xdp::prelude::*;
const RTE_IPV4_HDR_IHL_MASK: u8 = 0x0f;
const RTE_IPV4_IHL_MULTIPLIER: u8 = 4;
pub unsafe fn rte_ipv4_hdr_len(ipv4_hdr: *const iphdr) -> u8 {
let tmp = (((*ipv4_hdr).ihl() & RTE_IPV4_HDR_IHL_MASK) * RTE_IPV4_IHL_MULTIPLIER) as u8;
_ = printk!("csum_dpdk: ipv4_hdr_len: %d", tmp);
tmp
@dotSlashLu
dotSlashLu / concur-test.go
Created June 20, 2019 03:48
concurrent http s/c stress test
package main
import (
"fmt"
"log"
httpcli "moservice/lib/net"
"net/http"
"sync"
"time"
)
@dotSlashLu
dotSlashLu / mon.sh
Created May 24, 2018 08:01
Luminous deploy script
# Usage: bash mon.sh short-hostname
# You should first change the node's hostname, e.g.
# hostnamectl set-hostname mon1.ceph
# Then add it to ~/.ssh/config, e.g.
# Host mon1
dst=$1
ssh $dst systemctl stop firewalld
ssh $dst systemctl disable firewalld
@dotSlashLu
dotSlashLu / main.go
Last active May 9, 2018 09:54
test net unpack
package main
import (
"log"
"fmt"
"net"
"bytes"
"unsafe"
"encoding/binary"
)
@dotSlashLu
dotSlashLu / interchange.c
Created April 19, 2018 08:30
linked list node interchange
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct stack {
int val;
struct stack *next;
};
// find previous node function()
@dotSlashLu
dotSlashLu / mon.py
Last active September 13, 2017 02:56
waf redis llen monitor
import os
import sys
import time
abspath = os.path.split(os.path.realpath(__file__))[0]
sys.path.append("%s/lib" % abspath)
import redis
import gevent
from gevent import monkey; monkey.patch_all()
@dotSlashLu
dotSlashLu / install_ovs-dpdk.sh
Last active August 26, 2021 16:52
Prepare, install Open vSwitch and DPDK rpms, and configure OVS
# Install ovs-dpdk
# Copyright Dotslash.Lu <dotslash.lu@gmail.com>
#
# NOTE:
# Please add `iommu=pt intel_iommu=on` to grub bootline and
# reboot
#
# Installation will cause NETWORK LOST, so it's better to
# execute this script within an admin console
#
@dotSlashLu
dotSlashLu / find_in_dir.erl
Last active August 29, 2015 14:21
erlang script to find a file in directories using regular expression
#!/usr/bin/env escript
%% usage: find_in_dir.erl name dir[ dir2[ ...]]
main(P) ->
[For|L] = P,
{ok, Cwd} = file:get_cwd(),
Matches = flatten(lists:map(fun(Dir) ->
Absdir = case Dir of
"" -> Cwd;
[$/|_] -> Dir;
// this won't work
var obj = {
test: function() {
subfunc();
var subfunc = function() {};
}
};
// this one works
var obj = {