Skip to content

Instantly share code, notes, and snippets.

View ssrlive's full-sized avatar

ssrlive

  • telegram: realssrlive
  • ssrlivebox(at)gmail(dot)com
View GitHub Profile
@ssrlive
ssrlive / proxyhttp.md
Created January 28, 2023 12:06
rust http proxy

Cargo.toml

[dependencies]
anyhow = "1.0.68"
futures-util = "0.3.25"
hyper = { version ="0.14.23", features = ["full"] }
hyper-rustls = "0.23.2"
hyper-tls = "0.5.0"
tokio = { version = "1.24.2", features = ["full"] }
fn main() {
let f = move || -> anyhow::Result<()> {
let url = url::Url::parse("ws://127.0.0.1:9001")?;
let (mut socket, response) = tungstenite::connect(url)?;
println!("Connected to the server");
println!("Response HTTP code: {}", response.status());
println!("Response contains the following headers:");
for (ref header, _value) in response.headers() {
@ssrlive
ssrlive / quicksort.rs
Created October 31, 2022 01:04
Quick sort in rust
pub fn quick_sort<T: Ord + Copy>(slice: &mut [T]) {
if slice.len() <= 1 {
return;
}
let p = slice[0];
let (mut left, mut right): (Vec<T>, Vec<T>) = slice[1..].iter().partition(|&x| *x < p);
quick_sort(&mut left);
quick_sort(&mut right);
slice.copy_from_slice(&[left, vec![p], right].concat());
}
@ssrlive
ssrlive / server.rs
Created October 26, 2022 10:30
Tokio server code.
// tokio = { version = "1.21.2", features = ["full"] }
use tokio::net::TcpListener;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let listener = TcpListener::bind("127.0.0.1:6379").await?;
loop {
let (mut socket, _) = listener.accept().await?;
@ssrlive
ssrlive / SwitchyOmega.md
Last active February 9, 2023 02:00
SwitchyOmega 設定
127.0.0.1
[::1]
localhost
192.168.*
*.bilibili.com
*.biliapi.net
*.hdslb.com
*.bilivideo.com
*.zhihu.com
use structopt::StructOpt;
#[derive(StructOpt, PartialEq, Eq, Debug)]
enum Opt {
/// Fetch stuff from GitHub
Fetch {
#[structopt(short, long)]
/// Fetch all the repository contents
all: bool,
@ssrlive
ssrlive / self-sign-cert.sh
Last active October 1, 2022 10:44
Self-signed certificate generator (自簽名證書生成器)
#! /bin/bash
if [ "$#" -ne 1 ]
then
echo "Error: No domain name argument provided"
echo "Usage: Provide a domain name as an argument"
exit 1
fi
DOMAIN=$1
@ssrlive
ssrlive / workflow.md
Last active August 8, 2022 04:44
New Linux Mint workflow
  • install Mint

    • install from iso file, write it to usb-disk with Rufus
    • do NOT upgrade from old version to new version, Never.
    • big version upgradation is bullshit.
    • install vim by sudo apt install vim -y
  • install proxy suit

    • install ssr client, and config it, and run it.
    • install privoxy, config it listen on 1080 port, run it.
@ssrlive
ssrlive / host_port_accessable_from_china.py
Last active July 22, 2022 01:03
host : port is accessable from china
from time import sleep
from bs4 import BeautifulSoup
from requests_html import HTMLSession
def host_port_accessable_from_china(host: str, port: int, delay: bool) -> bool:
"""
test if the host:port is accessable from China
"""
url = "https://tool.chinaz.com/port?host={}&port={}".format(host, port)
@ssrlive
ssrlive / hosts.txt
Created July 3, 2022 13:26
github copilot hosts file
140.82.112.21 central.github.com
185.199.108.133 desktop.githubusercontent.com
185.199.108.153 assets-cdn.github.com
185.199.108.133 camo.githubusercontent.com
185.199.108.133 github.map.fastly.net
199.232.69.194 github.global.ssl.fastly.net
140.82.114.4 gist.github.com
185.199.108.153 github.io
140.82.112.3 github.com
140.82.114.5 api.github.com