-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port
before_v0.60/data_extraction
before_v0.60/examples
`before_v…
…0.60/duplicates` (#847) This PR is part of porting all old scripts #221 and includes a set of modules: - `data_extraction` - `examples` - `duplicates` ## 7 changed files: ### `data_extraction` - `data_extraction/ultimate_extractor.nu`: removed. Has already been ported to `modules/data_extraction/ultimate_extractor.nu` ### `duplicates` - `duplicates/duplicates.nu` -> `modules/duplicates/duplicates.nu` - `duplicates/example.nu` -> `modules/duplicates/example.nu` - `duplicates/README.md` -> `modules/duplicates/README.md`: unchanged ### `examples` - `examples/netstat.nu` -> `modules/examples/netstat.nu` - `examples/date_in_local_timezones.nu` -> `modules/examples/date_in_local_timezones.nu` - `befove_v0.60/assets/core_team.nu`: removed. This table has been embedded into `date_in_local_timezones.nu`
- Loading branch information
Showing
9 changed files
with
81 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
12 changes: 7 additions & 5 deletions
12
before_v0.60/duplicates/example.nu → modules/duplicates/example.nu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
# duplicates example | ||
echo $info | from json | ||
use mod.nu * | ||
|
||
let info = "[{name: "John", lastname: "Doe"}, {name: "John", lastname: "Roe"}, {name: "Jane", lastname: "Soe"}]" | ||
echo $info | from json | duplicates name | ||
print ($info | from json) | ||
print ($info | from json | duplicates name) | ||
|
||
#duplicates files example | ||
echo A | save A.txt | ||
echo A | save B.txt | ||
# note that if I used "echo B | save B.txt" the function will give a false positive | ||
echo ABC | save C.txt | ||
ls | ||
duplicates files | ||
rm A.txt B.txt C.txt --permanent | ||
print (ls) | ||
print (duplicates files) | ||
rm A.txt B.txt C.txt --permanent |
14 changes: 7 additions & 7 deletions
14
before_v0.60/duplicates/duplicates.nu → modules/duplicates/mod.nu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
def "nu core-team" [] { | ||
[ | ||
[ 'name', 'tz']; | ||
[ 'andres', 'America/Guayaquil'] | ||
[ 'fdncred', 'US/Central'] | ||
[ 'gedge', 'US/Eastern'] | ||
[ 'jt', 'NZ'] | ||
[ 'wycats', 'US/Pacific'] | ||
[ 'kubouch', 'Europe/Helsinki'] | ||
['elferherrera', 'Europe/London'] | ||
] | ||
} | ||
|
||
def "date local" [now] { | ||
insert time {|value| | ||
let converted = ($now | date to-timezone $value.tz); | ||
|
||
$converted | format date '%c' | ||
} | ||
} | ||
|
||
let next_call = ("2021-08-31 15:00:21.290597200 -05:00" | into datetime); | ||
let people = (nu core-team | date local $next_call); | ||
|
||
def say [closure] { | ||
$in | each {|person| | ||
do $closure ( | ||
$person | update name {|row| $row.name | str capitalize} | ||
) | ||
} | str join (char newline) | ||
} | ||
|
||
print ($people | say {|person| $"($person.name)'s timezone is ($person.tz)"}) | ||
|
||
print ($" | ||
for the next call happening on ($next_call | format date '%c').. in their timezones they would be: | ||
") | ||
|
||
print ($people | say {|person| $"($person.name)'s: ($person.time)"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let ns = (netstat | lines | skip 1) | ||
|
||
let first_batch = ($ns | take until {|it| $it =~ Active } | str join (char nl) | from ssv -m 1) | ||
let second_batch = ($ns | | ||
skip until {|it| $it =~ Active } | | ||
skip 1 | | ||
str join (char nl) | | ||
str replace '\[ \]' "[]" --all | | ||
from ssv -m 1 | | ||
default I-Node "" | | ||
default Path "" | ||
| each {|row| if $row.Type == DGRAM { | ||
$row | update Path { get I-Node } | update I-Node { get State } | update State "" | ||
} else { | ||
$row | ||
} | ||
} | ||
) | ||
|
||
print $first_batch | ||
print $second_batch | ||
|
||
|
||
|
||
|