Lessons Learned

My drop-site for interesting snippets and tips. If it's useful to you as well, great!

Browse by Tags

Tagged Content List
  • Blog Post: One-Liner: Fun with Multi-line Blocktext and –Split/.Split()

    The title is an oxymoron: I’m going to show a one-liner on how to deal with multi-line blocktext.  To start with, I’m using ‘blocktext’ to mean: $blocktext = @" This is an example using @" .. "@ "@; which is known from Unix-dom as ‘heretext’ and what I simply call...
  • Blog Post: One-Liner: Padding a Number with Leading Zeroes

    I’m putting this here only because I’m tired of searching for it.  How to pad an integer with leading zeroes is trivial.  1..16 | % { "{0:D2}" -f $_ } And padding a float with trailing zeroes is more of the same: $i = 2; (1..10) | % { "{0:F5}" -f $i; $i = $i / 2; } Now, how about...
  • Blog Post: Splitting a Hex-Encoded String into Pairs of Hex Characters (a.k.a. To Pull a Noah)

    Simple enough task: I have a hex-encoded string and need to decode it.  Now, we all know that to en code a string to hex is to cast each [char] to [int], then shove it through the "{0:X}" format specifier, then concatenate all the strings. $string = "The quick brown dog"; [string...
Page 1 of 1 (3 items)