diff --git a/before_v0.60/git/git_branch_cleanup.nu b/before_v0.60/git/git_branch_cleanup.nu deleted file mode 100644 index b87d7ba..0000000 --- a/before_v0.60/git/git_branch_cleanup.nu +++ /dev/null @@ -1,4 +0,0 @@ -# Script that remove outdated local branches from a git repo -# More information on this article https://www.techwatching.dev/posts/cleaning-git-branches - -git branch -vl '*/*' | lines | split column " " BranchName Hash Status --collapse-empty | where Status == '[gone]' | each { git branch -D $it.BranchName } \ No newline at end of file diff --git a/before_v0.60/maths/math_functions.nu b/before_v0.60/maths/math_functions.nu deleted file mode 100644 index 9249f82..0000000 --- a/before_v0.60/maths/math_functions.nu +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/nu -# -# BE CAREFUL WITH ROOTS MADE ON BIG NUMBERS (10 digits and more) — the result is rounded so you may get wrong result. -# just modify the round -p or calculate it manually - -#Root with a custom denominator -def root [ denominator: number, num: number ] { - $num ** ( 1 / $denominator ) | math round -p 10 -} - -#Cube root -def croot [num: number] { - $num ** ( 1 / 3 ) | math round -p 10 -} - -#Root with a custom scaler and denominator -def aroot [ scaler: number, denominator: number, num: number ] { - $num ** ($scaler / $denominator) | math round -p 10 -} - -#calculate delta of the quadratic function -def delta [ a: number,#x^2 factor -b: number, #x factor -c: number #the rest -] { - ( $b ** 2 ) - ( 4 * $a * $c) -} - -#Factorial of the given number -def fact [num: int] { - if $num >= 0 { if $num < 2 {$num} {seq 2 $num | math product} } { echo 'Error: can only calculate non-negative integers'} -} - diff --git a/before_v0.60/git/README.md b/modules/git/README.md similarity index 100% rename from before_v0.60/git/README.md rename to modules/git/README.md diff --git a/before_v0.60/git/git_branch_age.nu b/modules/git/git_branch_age.nu similarity index 67% rename from before_v0.60/git/git_branch_age.nu rename to modules/git/git_branch_age.nu index 9e30bf6..8b36747 100644 --- a/before_v0.60/git/git_branch_age.nu +++ b/modules/git/git_branch_age.nu @@ -1,13 +1,13 @@ # Creates a table listing the branches of a git repository and the day of the last commit -def "git age" [] { +export def "git age" [] { git branch | lines | - str substring 2, | + str substring 2.. | wrap name | insert last_commit { get name | each { - git show $it --no-patch --format=%as | str to-datetime + git show $in --no-patch --format=%as | into datetime } } | sort-by last_commit diff --git a/before_v0.60/parsing/README.md b/modules/parsing/README.md similarity index 100% rename from before_v0.60/parsing/README.md rename to modules/parsing/README.md diff --git a/before_v0.60/parsing/sample_andres.json b/modules/parsing/sample_andres.json similarity index 100% rename from before_v0.60/parsing/sample_andres.json rename to modules/parsing/sample_andres.json diff --git a/before_v0.60/parsing/sample_andres.nu b/modules/parsing/sample_andres.nu similarity index 54% rename from before_v0.60/parsing/sample_andres.nu rename to modules/parsing/sample_andres.nu index edbb43f..122fe79 100644 --- a/before_v0.60/parsing/sample_andres.nu +++ b/modules/parsing/sample_andres.nu @@ -5,17 +5,17 @@ def look_for [word] { insert comp { get shoes_name | split row " " | - each --numbered { - [[idx, loc]; [$it.index, ($it.item | str index-of $word)]] - } + enumerate | each { + [[idx, loc]; [$in.index, ($in.item | str index-of $word)]] + } | flatten } | flatten | where comp.loc >= 0 | flatten | - update idx { $it.idx + 1 } | + update idx { $in + 1 } | reject name price loc | rename nameWords targetWordIndex } -look_for "leather" | to json --pretty 4 -look_for "low-top" | to json --pretty 4 \ No newline at end of file +print (look_for "leather" | to json --indent 4) +print (look_for "low-top" | to json --indent 4)