Skip to content

Instantly share code, notes, and snippets.

@paul-d-ray
paul-d-ray / Nushell_Last_Friday_of_Year.md
Created September 19, 2025 17:00
Nushell Get Last Friday of Each Month of a Year

Last Friday of Each Month

I had a need to get the last Friday of each month of 2025.

  • This can be changed to get any other last day by changing the wday variable.
    • su, mo, tu, we, th, fr, sa

Nushell Code

let wday = 'fr'
let year = 2025
cal -m -t --week-start $wday --full-year $year |
@paul-d-ray
paul-d-ray / Nushell_add_percentage_to_list.md
Last active December 2, 2025 01:13
Nushell Add a percentage to a list of numbers

Purpose

I had a need to add a percentage, in this case 35%, to a list of numbers. This nushell code allows this to be done in three lines of code.

Nushell Code

[50 55 60 65 70 75 80 85 90 95] | each { |it|
    let multiplied = ($it * 1.35);
    { amount: $it, multiplied: $multiplied, addamt: ($multiplied - $it) }
}
@paul-d-ray
paul-d-ray / Nushell_Month_Num_Name.md
Last active September 18, 2025 01:27
Nushell Get Month Number and Month Name

Month Number and Month Name

I had a need to get the month number and month name of the odd number moonths.

  • This code can be changed to get the even months by changing the mod statment (1 to 0).
  • To get all months, comment out the mod statement.

Code for Odd Months

1..12 |
each { |x|
    {
@paul-d-ray
paul-d-ray / UniGetUI.md
Last active November 9, 2025 21:23
One program to oversee Windows Package mangers

In Windows, I have programs that have the updates managed a number of ways. I don't like to have programs auto update.

  • I like to wait a few days (weeks) to update a program to see if there are any issues caused by the update.
  • Sometimes a program update will:
    • remove features / functions that I like to use.
    • cause issues with other programs.
    • cause system issues (even a system crash).
  • I also have auto updates turned off in Windows. I run the updates manually.
@paul-d-ray
paul-d-ray / Calculators.md
Last active September 28, 2025 03:02
Calculators (OpalCalc, SpeedCrunch, Qalculate)

For this last 15 years I have always had a calculator open and running in my Windows PC. I used the calculate to quicky calculate percentages, multiply rates.
I also use the calculatr for just a quick note (I know not really the purpose for a calculator).1

SpeedCrunch

SpeedCrunch

speedcrunch_image

  • I used this after I found out about it around 2007.
  • At the time, I wished it had a dark mode, and in 2014 (version 0.11) it did have dark mode.
@paul-d-ray
paul-d-ray / Nushell_Factors.md
Created August 12, 2025 01:30
Using Nushell, given a number, find all the factors

Show all factors for a given number

Small number

Nushell code

let n = 24
  1..($n | math sqrt | math floor) |
    where { |$f| $n mod $f == 0 } |
  each { |$f| [$f (($n / $f) | into int) ] } |
  sort | grid -w 80
@paul-d-ray
paul-d-ray / Nushell_File_Size_Accumulated.md
Last active August 10, 2025 20:48
File Size Accumulated

This was from Nushell's Discord channel, on 2025/08/10, in the help chat.

@Bahex @timtimtim

I have some file sizes in a table like this [ {size: 12B} {size: 34B} {size: 56B} ]. How can I add a column to this table of the "accumulated" size as we iterate through the records? In this instance, it'd be additional fields (say accumulated) with values [ {accumulated: 12B} {accumulated: 46B} {accumulated: 102B} ], where 46 = 12 + 34, and 102 = 12 + 34 + 56. I'm trying to do this without a global counter variable if possible. (If the only reasonable solution is a counter variable, then I'd know how to do that)

@paul-d-ray
paul-d-ray / Nushell_Unixdict_Vowels.md
Created August 10, 2025 18:26
Unixdict Vowels vs Consonants with histogram

Vowels Histogram

Using the unixdict.txt file, get the vowels, consonants, and word length of each word.

Nushell code

open unixdict.txt
  | lines
  | filter {|w| ($w | str length) > 3 }
  | filter {|w| not ($w in [
      a e i o u i a an and are as at be
      by for from how in is it of on or
@paul-d-ray
paul-d-ray / Nushell_US_States_Vowels_Consonants.md
Last active August 10, 2025 20:48
Nushell Get a list of US states that have have more vowels than consonants

Get a list of US states that have have more vowels than consonants

Sort by Numbers of Vowels

Nushell Code

[
  "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut",
  "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa",
  "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
@paul-d-ray
paul-d-ray / Nushell_Update_Sum_Using_Polars_Xan.md
Last active August 12, 2025 16:37
Nushell Update a column, ussing Polars to sum, using Xan to sum

Update a column and Polars Sum

I have a table of Software purchased and / or donated to free software. I found I had a record that should have a type of Free instead of Paid.

Update a Column using Nushell

Wrong Type value

open software.tsv | 
  update Type { |row| if $row.Company =~  "Eric" { "Free" } else { $row.Type } }| 
  save -f software.tmp.tsv; mv -f software.tmp.tsv software.tsv