Skip to content

Instantly share code, notes, and snippets.

@zjp-CN
zjp-CN / cargo-nextest_output.rs
Created May 14, 2023 14:06
pytest-rs/crates $ cargo nextest run -j 8 --workspace
pytest-rs/crates $ cargo nextest run -j 8 --workspace
Finished test [unoptimized + debuginfo] target(s) in 0.06s
Starting 44 tests across 6 binaries
PASS [ 0.045s] lexarg tests::short_opt_equals_sign
PASS [ 0.039s] lexarg tests::test_basic
PASS [ 0.049s] lexarg tests::short_opt_equals_sign_invalid
PASS [ 0.049s] lexarg tests::test_combined
PASS [ 0.051s] lexarg tests::test_dash_args
PASS [ 0.057s] lexarg tests::test_invalid_long_option
PASS [ 0.065s] lexarg tests::test_invalid_short_option
@zjp-CN
zjp-CN / log.lua
Created September 15, 2022 11:38
LuaSnip: vim.inspect(by_ft, {depth=3})
{
autosnippets = {
NeogitCommitMessage = {},
all = {},
c = {},
cobol = {},
cpp = {},
cs = {},
csharp = {},
css = {},
@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 / check_binary_size.sh
Created July 26, 2022 06:48
check the size of binary compiled by Rust
rm pub_visibility -rf
cargo new pub_visibility -q
cd pub_visibility/
cargo_build() {
cargo b --release -q
echo "before strip:"
ls -lh target/release/pub_visibility
strip target/release/pub_visibility
@zjp-CN
zjp-CN / uppercase_first_char.rs
Created July 9, 2022 07:09
Let the first char uppercase
#![feature(let_chains)]
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
fn main() {
helper_upper_ascii(&mut String::from("hello"));
helper_upper_ascii(&mut String::from("World"));
helper_upper_ascii(&mut String::from("ßγ"));
helper_upper_ascii(&mut String::from("你好"));
@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(), })]
}