Skip to content

Instantly share code, notes, and snippets.

@zjp-CN
zjp-CN / 开启xterm终端256色和终端下vim 256色
Created September 13, 2022 07:56 — forked from deneschen/开启xterm终端256色和终端下vim 256色
开启xterm终端256色和终端下vim 256色
相同的colorschema,vim和gvim的颜色差距还是很大的,因为gvim使用X的颜色,而vim只能使用终端提供的颜色,所以造成了二者的显示差异。
xterm开启256色
现在的终端模拟器早就支持256色了,不过默认可能还是8色的。
开启xterm终端,查看xterm终端支持的颜色
命令:
$ tput colors
8
@zjp-CN
zjp-CN / download_file.rs
Created September 6, 2021 07:55 — forked from giuliano-macedo/download_file.rs
Download large files in rust with progress bar using reqwest, future_util and indicatif
// you need this in your cargo.toml
// reqwest = { version = "0.11.3", features = ["stream"] }
// futures-util = "0.3.14"
// indicatif = "0.15.0"
use std::cmp::min;
use std::fs::File;
use std::io::Write;
use reqwest::Client;
use indicatif::{ProgressBar, ProgressStyle};
@zjp-CN
zjp-CN / playground.rs
Last active July 8, 2021 10:36 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[derive(Debug)]
struct User { id: u32, pid: u32, name: String, }
fn set_up_option() -> Vec<Option<User>> {
// 注意修改了顺序
vec![Some(User { id: 0, pid: 1, name: "admin1".to_string(), }),
Some(User { id: 2, pid: 2, name: "admin3".to_string(), }),
Some(User { id: 1, pid: 1, name: "admin2".to_string(), }),
Some(User { id: 3, pid: 2, name: "admin4".to_string(), })]
}