This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. first goto video folder | |
| # 2. generate video file(front camera) list of current folder | |
| ls | grep 'front' | awk '{print "file \x27" $0 "\x27"}' > merge.txt | |
| # 3. (optional), edit merge.txt, remove unwanted video files name | |
| # 4. merge videos | |
| ffmpeg -f concat -safe 0 -i merge.txt -c copy output.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(prelude_import)] | |
| #[prelude_import] | |
| use std::prelude::rust_2021::*; | |
| #[macro_use] | |
| extern crate std; | |
| #[forbid(unsafe_code)] | |
| mod entities { | |
| //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 | |
| pub mod prelude { | |
| //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::sync::{Arc, RwLock}; | |
| use std::thread; | |
| use std::thread::sleep; | |
| use std::time::Duration; | |
| /// Option<Arc<i32>> 适合初始化时就能决定是 None 还是 Some 值,后面不需要改的情况 | |
| /// 这个例子里尝试在初始化后重新赋值,导致在不同的线程中无法得到相同的值 | |
| fn main() { | |
| let mut apple = Apple::new(); | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::sync::Arc; | |
| use std::thread; | |
| use dashmap::{DashSet}; | |
| fn main() { | |
| let set = Arc::new(DashSet::<i32>::default()); | |
| { | |
| for i in 0..10 { | |
| let set = set.clone(); | |
| thread::spawn(move || { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::sync::Mutex; | |
| use std::time::Instant; | |
| fn main() { | |
| let last = Instant::now(); | |
| let num = Mutex::new(1); | |
| for _ in 0..1000 * 1000 * 10 { | |
| let mut guard = num.lock().unwrap(); | |
| *guard += 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use yrs::{DeepObservable, Doc, Map, Transact}; | |
| fn main() { | |
| let doc = Doc::new(); | |
| let mut block = doc.get_or_insert_map("block"); | |
| let sub = block.observe_deep(move |_trx, _e| { | |
| println!("subscribe -> observe_deep"); | |
| }); | |
| // drop(sub); // drop sub will lose observation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::sync::Arc; | |
| use std::thread::sleep; | |
| use std::time::Duration; | |
| use tokio::sync::RwLock; | |
| #[tokio::main] | |
| async fn main() { | |
| let (tx, mut rx) = tokio::sync::mpsc::channel::<i32>(100); | |
| for i in 0..100 { | |
| tx.send(i).await.expect("TODO: panic message"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::sync::Arc; | |
| use std::thread::sleep; | |
| use tokio::runtime::Runtime; | |
| fn main() { | |
| let rt = Arc::new(Runtime::new().unwrap()); | |
| rt.spawn(async { | |
| tokio::time::sleep(std::time::Duration::from_secs(1)).await; | |
| println!("finished"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let rt = tokio::runtime::Runtime::new().unwrap(); | |
| let rt2 = tokio::runtime::Runtime::new().unwrap(); | |
| rt.block_on(async { | |
| rt2.spawn(async { | |
| tokio::time::sleep(std::time::Duration::from_secs(1)).await; | |
| println!("finished"); | |
| }); | |
| }); |
NewerOlder