2020年的清明

清明 今天是2020年4月4日,中国的清明节。今年的清明节尤其特殊,从年前1月份开始,陆续的有人感染新型冠状病毒,能够使得肺部逐渐纤维化,不能呼吸,但是意识还是清醒的,因此病人如果得不到及时的救治,就会非常痛苦地死亡。目前为止,全球已经超过109万人感染,超过5.8万人去世。 目前最……

阅读全文

2020年的武汉新年

手机里的2020武汉新年(来源微博-清影Tsingying) 在这一场无硝烟的战争中,武汉人们付出了太多,我们全国乃至全球都不能忘记这个历史。人类在这次战争中完败,目前全球已经有超过100w人感染。中国上半场,外国下半场。 向在这次疫情中去世的人们致最崇高的敬意!……

阅读全文

linux shell脚本监控进程崩溃自动重启

linux shell脚本监控进程崩溃自动重启 在工作的时候,有时候会碰到程序非常慢,但是又容易崩溃的程序,这时候可以考虑使用一个进程来时刻监督进程执行,如果崩溃就重启。 1 2 3 4 5 6 7 8 9 10 11 # ! /bin/sh while true do procnum=`ps -ef|grep 进程名称|wc -l` if [ $procnum -eq 0 ] then echo "start service...................." ${START_CMD} fi sleep 1 done……

阅读全文

大疆在线直播

大疆在线直播 2020-04-10更新 突然发现新大陆,可以使用各种平台来直播restream 直接将直播地址以及密码添加进来就ok rtmp://live.restream.io/live/re_2162584xxxxxxx 正文开始 很久之前买了一个大疆无人机,它长这样 这款无人机能够飞行15min,高度500m,长度2km,能够满足我们一般人的需求。 开始玩这个无人机的时候,并……

阅读全文

Rust by Example(chapter17)

标准库 这一章主要介绍标准库,Rust中提供了各种各样的标准库供我们使用。 String vectors Option Result Box Box Box是一个智能指针,在计算机程序中,所有的值都是在栈中分配的,同时是固定大小的。但是可以使用Box来向堆中分配空间,同时返回一个指针,如果指针不在上下文中,那么分配的区域就会被回收。 1 2 3 4 5 6……

阅读全文

Rust by Example(chapter16)

macro_rules! 在Rust中,宏非常之强大,宏就像一个函数一样,但是接着!。However, unlike macros in C and other languages, Rust macros are expanded into abstract syntax trees, rather than string preprocessing, so you don’t get unexpected precedence bugs. 1 2 3 4 5 6 7 8 9 10 // 将() 展开为打印字符 macro_rules! say_hello{ () => { println!("Hello!"); }; } fn main() { say_hello!() } Designators 通过一种宏来创建函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 macro_rules! create_function{ ($func_name:ident) => { fn $func_name() { println!("You called {:?}()", stringify!($func_name)); } }; } create_function!(foo);……

阅读全文

Rust by Example(chapter15)

Derive(派生) 在Rust中,提供了各种各样的派生特性。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #[derive(PartialOrd, PartialEq)] struct Centimeters(f64); struct Inches(i32); impl Inches { fn to_centimeters(&self) -> Centimeters { let &Inches(inches) = self; Centimeters(inches as f64 * 2.54) } } fn main() { let foot = Inches(12); let meter = Centimeters(100.0); let cmp = if foot.to_centimeters() < meter { "smaller" } else { "bigger" }; println!("{}", cmp); } 在这里,首先定义了Centimeters,同时重载了比……

阅读全文