Skip to content

Instantly share code, notes, and snippets.

View ptdecker's full-sized avatar

Peter Todd Decker ("Todd") ptdecker

  • Kansas City
View GitHub Profile
@NerdyDeedsLLC
NerdyDeedsLLC / flnm.sh
Last active June 1, 2023 17:03
BASH: Abridges & Shortens a FIle Path (e.g. flnm "/some/long/path/to/my/file/location/file.ext" 1 1 will produce "/some/.../location/file.ext")
# flnm - Breaks apart a file's path by "/" and returns only the number of folder specified for each side,
# followed by the file name.
#
# usage: flnm <filename> <leading elements> <trailing elements>
# if <leading elements> is provided and <trailing elements> is omitted, then returns ONLY the back n portions
# if <leading elements> is provided and <trailing elements> is omitted, then returns ONLY the file nane
# if <leading elements> + <trailing elements> exceeds the file's actual path length, then returns full file path
# if both <leading elements> and <trailing elements> are omitted, it assumes a value of 1 for each
#
# examples:
@ptdecker
ptdecker / main.rs
Last active October 17, 2024 18:56
TOML Crate Demonstration
//! TOML Value Manipulation Demonstration
//!
//! This code is to supplement this excellent article:
//!
//! [Rust: Read, Write, and Modify .toml Files — Another way to handle User Set Environment Variables](https://medium.com/@itsuki.enjoy/rust-read-write-and-modify-toml-files-another-way-to-handle-user-set-environment-variables-27e1baf1a65f)
//!
//! This demo code assumes you have added additional entries to your ~/.cargo/config.toml file. Although, I used
//! `foo` and `bar` instead of the `password` and `username` that the article uses.
//!
//! Put this code into `main.rs`. And, here is the corresponding `Cargo.toml` needed for this demo.