| command | description |
|---|---|
| ctrl + a | Goto BEGINNING of command line |
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 windows::core::ComInterface; | |
| // https://learn.microsoft.com/en-us/windows/win32/shell/links#resolving-a-shortcut | |
| fn resolve_lnk_target(lnk_file: &str) -> Result<String, Box<dyn std::error::Error>> { | |
| let psl: windows::Win32::UI::Shell::IShellLinkW = unsafe { | |
| windows::Win32::System::Com::CoInitialize(None)?; | |
| windows::Win32::System::Com::CoCreateInstance( | |
| &windows::Win32::UI::Shell::ShellLink, | |
| None, |
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::cmp::Reverse; | |
| use std::collections::BinaryHeap; | |
| #[inline] | |
| fn maintain_top_k<T: Ord>(min_heap: &mut BinaryHeap<Reverse<T>>, val: T, top_k: usize) { | |
| if min_heap.len() < top_k { | |
| min_heap.push(Reverse(val)); | |
| } else if top_k > 0 && val > min_heap.peek().unwrap().0 { | |
| min_heap.pop(); | |
| min_heap.push(Reverse(val)); |
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::io::Write; | |
| struct FileStream { | |
| file: std::fs::File, | |
| } | |
| impl FileStream { | |
| fn new<S: AsRef<std::path::Path>>(s: S) -> std::io::Result<Self> { | |
| //let file = std::fs::File::create(s)?; | |
| let file = std::fs::File::options().create(true).append(true).open(s)?; |
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 windows_service::service::{ | |
| ServiceType, | |
| ServiceControl, | |
| ServiceStatus, | |
| ServiceState, | |
| ServiceControlAccept, | |
| ServiceExitCode, | |
| }; | |
| use windows_service::service_control_handler::ServiceControlHandlerResult; |
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
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <unistd.h> | |
| #include <assert.h> | |
| #define N 10 | |
| #define SIZE_OF(a) (sizeof(a) / sizeof(*a)) | |
| int main(void) { | |
| uint64_t arr[N] = {}; |
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
| #include <stdio.h> | |
| #ifdef _WIN32 | |
| #include <intrin.h> // __cpuid() | |
| #endif | |
| typedef unsigned int cpuid_t[4]; | |
| #define EAX 0 | |
| #define EBX 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
| diff --git a/examples/user_input.rs b/examples/user_input.rs | |
| index 330d502..22d2739 100644 | |
| --- a/examples/user_input.rs | |
| +++ b/examples/user_input.rs | |
| @@ -12,7 +12,7 @@ | |
| use crossterm::{ | |
| event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode}, | |
| execute, | |
| - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, | |
| + terminal::{disable_raw_mode, enable_raw_mode}, |
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
| #include <errno.h> | |
| #include <poll.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <sys/inotify.h> | |
| #include <unistd.h> | |
| #include <string.h> | |
| /* Read all available inotify events from the file descriptor 'fd'. | |
| wd is the table of watch descriptors for the directories in argv. |
