Skip to content

Instantly share code, notes, and snippets.

View Sherlock-Holo's full-sized avatar
😀

Sherlock Holo Sherlock-Holo

😀
View GitHub Profile
@Sherlock-Holo
Sherlock-Holo / main.dart
Created January 15, 2023 17:03
video play
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
void main() => runApp(const VideoPlayerApp());
class VideoPlayerApp extends StatelessWidget {
const VideoPlayerApp({super.key});
@Sherlock-Holo
Sherlock-Holo / strip-bpf-tc.sh
Created October 23, 2021 09:46
strip-bpf-tc.sh
#!/bin/bash
for sec in '.BTF.ext' '.eh_frame' '.debug_loc' '.debug_info' '.debug_ranges' '.debug_frame' '.debug_line'
do
llvm-strip --remove-section $sec $1
done
llvm-strip --remove-section .text $1
@Sherlock-Holo
Sherlock-Holo / main.rs
Created May 18, 2020 05:24
get original dst addr
use std::io::{Error, Result};
use std::mem::{MaybeUninit, size_of};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use std::os::unix::io::AsRawFd;
use async_std::net::TcpListener;
use futures::StreamExt;
#[async_std::main]
async fn main() {
@Sherlock-Holo
Sherlock-Holo / main.rs
Created May 5, 2020 01:05
io_uring test
use std::collections::HashMap;
use std::fs::File;
use std::future::Future;
use std::io::Error;
use std::io::IoSliceMut;
use std::io::Result;
use std::marker::PhantomData;
use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
use std::pin::Pin;
@Sherlock-Holo
Sherlock-Holo / lib.rs
Created April 23, 2020 14:47
concurrent iou
use std::io;
use std::io::IoSlice;
use std::io::IoSliceMut;
use std::ops::Deref;
use std::ptr::drop_in_place;
use std::sync::Mutex;
use iou::{CompletionQueue, CompletionQueueEvent, IoUring, Registrar, SubmissionQueue};
struct Ring<'a> {
@Sherlock-Holo
Sherlock-Holo / lib.rs
Created March 9, 2020 10:22
async-std hyper listener and connector
use std::future::Future;
use std::io;
use std::io::ErrorKind;
use std::io::Result;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use async_std::io::{Read, Write};
use async_std::net::{TcpListener, TcpStream};
@Sherlock-Holo
Sherlock-Holo / main.rs
Created February 16, 2020 11:11
third runtime with tokio
// from https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fbb7daec1be993d3a4cd6f6181f332a0
use std::future::Future;
use std::pin::Pin;
use std::thread;
use futures::future::{pending, poll_fn};
use lazy_static::lazy_static;
use tokio::runtime::{Handle, Runtime};
@Sherlock-Holo
Sherlock-Holo / get_original_dst.go
Created January 28, 2020 12:37 — forked from fangdingjun/get_original_dst.go
golang: get the original destination for the socket when redirect by linux iptables
// get the original destination for the socket when redirect by linux iptables
// refer to https://raw.githubusercontent.com/missdeer/avege/master/src/inbound/redir/redir_iptables.go
//
const (
SO_ORIGINAL_DST = 80
IP6T_SO_ORIGINAL_DST = 80
)
func getOriginalDst(clientConn *net.TCPConn) (rawaddr []byte, host string, newTCPConn *net.TCPConn, err error) {
if clientConn == nil {
@Sherlock-Holo
Sherlock-Holo / get_original_dst.go
Created January 28, 2020 12:37 — forked from fangdingjun/get_original_dst.go
golang: get the original destination for the socket when redirect by linux iptables
// get the original destination for the socket when redirect by linux iptables
// refer to https://raw.githubusercontent.com/missdeer/avege/master/src/inbound/redir/redir_iptables.go
//
const (
SO_ORIGINAL_DST = 80
IP6T_SO_ORIGINAL_DST = 80
)
func getOriginalDst(clientConn *net.TCPConn) (rawaddr []byte, host string, newTCPConn *net.TCPConn, err error) {
if clientConn == nil {
@Sherlock-Holo
Sherlock-Holo / map.go
Created November 22, 2019 07:43
functional helper
// Map is a functional map, like Kotlin or Rust map.
// wantType must be a pointer, If you want return a []*string,
// wantType should be **string
func Map(slice interface{}, wantType interface{}, f func(v interface{}) interface{}) interface{} {
if reflect.TypeOf(slice).Kind() != reflect.Slice {
panic("slice type must be slice")
}
value := reflect.ValueOf(slice)