Skip to content

Instantly share code, notes, and snippets.

View gothburz's full-sized avatar
🎯
Focusing

Peter Girnus gothburz

🎯
Focusing
View GitHub Profile
@gothburz
gothburz / get-extensions.ps1
Created April 24, 2024 13:00
Enumerates file extensions in the HKEY_CLASSES_ROOT hive from the Windows Registry
Get-ChildItem -Path Registry::HKEY_CLASSES_ROOT\.* -ErrorAction SilentlyContinue | Out-GridView
@gothburz
gothburz / main.rs
Created October 15, 2023 05:09
Demo on how to deserialize JSON with HashMap & serde_json::Value in Rust lang.
use reqwest;
use serde_json;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// KNOWN RETURN - HashMap
const URL2: &str = "https://httpbin.org/ip";
match reqwest::get(URL2).await {
@gothburz
gothburz / windows-metadataext.rs
Created October 9, 2023 17:05
Rust Metadata Extensions for the Windows Platform
use std::fs;
use std::os::windows::fs::MetadataExt;
fn main() {
const FILE: &str = "./examples/hello.txt";
let metadata = fs::metadata(FILE).unwrap();
println!("{:?}", metadata);
// Filetype
let file_type = metadata.file_type();
println!("{:?}", file_type);
typedef struct _BY_HANDLE_FILE_INFORMATION {
  DWORD    dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD    dwVolumeSerialNumber;
  DWORD    nFileSizeHigh;
  DWORD    nFileSizeLow;
  DWORD    nNumberOfLinks;
  DWORD    nFileIndexHigh;
@gothburz
gothburz / main.rs
Created October 9, 2023 02:21
An example of various Rust MetadataExt trait implementations.
use std::fs;
use std::os::linux::fs::MetadataExt;
fn main() {
const FILE: &str = "./examples/hello.txt";
let metadata = fs::metadata(FILE).unwrap();
// Filetype
let file_type = metadata.file_type();
println!("{:?}", file_type);
// is_dir()
@gothburz
gothburz / main.rs
Created October 9, 2023 00:25
blocks()
let unix_num_of_blocks_value = metadata.blocks();
@gothburz
gothburz / main.rs
Created October 9, 2023 00:25
blksize()
let unix_blksize_value = metadata.blksize();
@gothburz
gothburz / main.rs
Created October 9, 2023 00:24
ctime_nsec()
let unix_ctime_nsec_value = metadata.ctime_nsec();
@gothburz
gothburz / main.rs
Created October 9, 2023 00:23
ctime()
let unix_ctime_value = metadata.ctime();
@gothburz
gothburz / main.rs
Created October 9, 2023 00:22
mtime_nsec()
let unix_mtime_nsec_value = metadata.mtime_nsec();