Skip to content

Instantly share code, notes, and snippets.

@time-river
time-river / common.h
Created December 27, 2019 12:35
syscall test
#ifndef __COMMON_H
#define __COMMON_H
#define ERRNO_OFFSET 0x80
#endif
@time-river
time-river / http-parse-simple.c
Last active September 15, 2020 16:27
bpfcc dump skb
#include <uapi/linux/ptrace.h>
#include <net/sock.h>
#include <bcc/proto.h>
#define IP_ICMP 1
#define IP_TCP 6
#define ETH_HLEN 14
/*eBPF program.
Filter IP and TCP packets, having payload not empty
@time-river
time-river / Makefile
Created December 5, 2020 15:18
Linux lernel log level test
obj-m += printk_device.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
static int stop;
@time-river
time-river / README.md
Last active May 13, 2022 08:48
a golang demo that makes IPv4 http proxy to global tcp transparent proxy

Introduction

a golang demo that makes IPv4 http proxy to global tcp transparent proxy

Usage

# iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 1080
# go run main.go proxy.go
#include <bits/stdc++.h>
void get_post_order(const std::string &pre_order, const std::string &in_order) {
if (pre_order.length() == 0 && in_order.length() == 0) {
return;
} else if (pre_order.length() == 1 && in_order.length() == 0) {
std::cout << pre_order[0] << ' ';
} else if (pre_order.length() == 0 && in_order.length() == 1) {
std::cout << in_order[0] << ' ';
} else if (pre_order.length() == 1 && in_order.length() == 1) {
@time-river
time-river / rtp-client_default.pa
Last active December 21, 2022 05:28
pulseaudio network unicast configuration (rtp audio method)
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
@time-river
time-river / client-network.pa
Created December 21, 2022 05:32
pulseaudio network configuration (tunnel method)
# save the following to `/etc/pulse/default.pa.d/network.pa`. !!!NOTICE THE SERVER ADDRESS!!!
load-module module-tunnel-sink sink_name="tunnel-sink" server=192.168.122.1
load-module module-tunnel-source source_name="tunnel-source" server=192.168.122.1
#load-module module-zeroconf-discover
set-default-sink tunnel-sink
set-default-source tunnel-source
@time-river
time-river / qemu.sh
Created December 21, 2022 06:33
boot vm via qemu command line
qemu-system-x86_64 \
-name qemu \
-machine pc,accel=kvm,usb=off,vmport=off,dump-guest-core=off \
-kernel vmlinuz \
-initrd initrd.img \
-append "root=/dev/vda1 ro debug loglevel=8 console=ttyS0" \
-cpu host \
-smp 4 \
-m 8192 \
-serial stdio \
@time-river
time-river / opencv-4.2-cuda.patch
Last active January 20, 2023 07:55
Ubuntu 22.04 + OpenCV 4.2 + CUDA fixed
shiFrom 0d99590a7433a11308d3d848c8c11c6d219c68b9 Mon Sep 17 00:00:00 2001
From: "fu.lin" <linfu@autox.ai>
Date: Thu, 12 Jan 2023 23:20:15 +0800
Subject: [PATCH 1/2] debian: compat ubuntu22.04
ref:
- https://github.com/NVlabs/instant-ngp/issues/119
- https://github.com/opencv/opencv/commit/52844614c466a37f64347aca0698157e9bb2e41e
- https://github.com/opencv/opencv/issues/23083