Last active
December 1, 2024 01:58
-
-
Save danielbayley/f2d5adbc5ef182c6aad67f218890c981 to your computer and use it in GitHub Desktop.
Revisions
-
danielbayley revised this gist
Dec 1, 2024 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,11 @@ add: &add [4, 5] total:: reduce(+ *add) # 9 # Merge extend: <<: *object d: 4 merge:: merge(*object { :d 4 }) # a: 1, b: 2, c: 3, d: 4 concat:: concat(*array *add) # 1–5 # Flatten nested: &nested [0, *array] -
danielbayley revised this gist
Nov 29, 2024 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -42,11 +42,11 @@ flatten:: flatten(*nested) # 0–3 # Paths pwd:: CWD.replace(ENV.HOME, "~") # ~/path/to/load.ys glob:: fs-glob("*") # [] dirname:: fs-dirname(FILE) # ~/path/to basename:: fs-filename(FILE) # load.ys filename:: fs-filename(FILE):fs/strip-ext # load extension:: fs/split-ext(FILE):last # ys # Define repository: -
danielbayley revised this gist
Nov 29, 2024 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,7 @@ # https://npm.im/@yaml/yamlscript # https://yamlscript.org/doc/cheat # https://yamlscript.org/doc/core # https://yamlscript.org/doc/ys-std # ys --yaml */load.ys #--json # tail -n+2 < */load.ys | pnpx yaml --single --json --indent ${TABSIZE-2} @@ -43,8 +44,8 @@ flatten:: flatten(*nested) # 0–3 pwd:: CWD.replace(ENV.HOME, "~") # ~/path/to/load.ys glob:: fs-glob("*") # [] dirname:: fs-dirname(FILE) # ~/path/to basename:: fs-filename(FILE) # load.ys filename:: fs-filename(FILE):fs/strip-ext # load extension:: split(FILE "\."):last # ys # Define -
danielbayley revised this gist
Nov 28, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -41,6 +41,7 @@ flatten:: flatten(*nested) # 0–3 # Paths pwd:: CWD.replace(ENV.HOME, "~") # ~/path/to/load.ys glob:: fs-glob("*") # [] dirname:: fs-dirname(FILE) # ~/path/to basename:: &basename fs-filename(FILE) # load.ys filename:: split(*basename "\."):butlast:last # load -
danielbayley revised this gist
Nov 28, 2024 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,6 @@ map-object:: map((fn [[k, v]] [k inc(v)]) *object):omap # a: 1, b: 2 c: 3 # Filter filter:: filter(even? *array) # 2 filter-object:: dissoc(*object "b") # a: 1, c: 3 grep:: grep((has? ["b"]) *keys) # b # Reduce @@ -44,10 +43,7 @@ flatten:: flatten(*nested) # 0–3 pwd:: CWD.replace(ENV.HOME, "~") # ~/path/to/load.ys dirname:: fs-dirname(FILE) # ~/path/to basename:: &basename fs-filename(FILE) # load.ys filename:: split(*basename "\."):butlast:last # load extension:: split(FILE "\."):last # ys # Define -
danielbayley revised this gist
Nov 28, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -42,8 +42,8 @@ flatten:: flatten(*nested) # 0–3 # Paths pwd:: CWD.replace(ENV.HOME, "~") # ~/path/to/load.ys dirname:: fs-dirname(FILE) # ~/path/to basename:: &basename fs-filename(FILE) # load.ys #defn basename(path): TODO #filename:: basename(FILE).split("."):first filename:: split(*basename "\."):butlast:last # load -
danielbayley revised this gist
Nov 28, 2024 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -64,8 +64,10 @@ url =: &url "https://raw.githubusercontent.com/$(*repository)/refs/heads/$(*bra fetch =: json/load(curl("$(*url)/package.json")) name:: fetch.name # semver-spec # Fetch Line(s) markdown =: slurp("$(*url)/semver.md") #?plain=1#L7-L15 summary:: markdown.lines().subvec(6 16).join("\n") pattern:: markdown.lines().nth(356) # Recursive this =: yaml/load(slurp(FILE).lines().drop(3).join("\n")) -
danielbayley revised this gist
Nov 26, 2024 . No changes.There are no files selected for viewing
-
danielbayley revised this gist
Nov 26, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
danielbayley renamed this gist
Nov 26, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
danielbayley renamed this gist
Nov 26, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
danielbayley revised this gist
Nov 26, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ *.ys linguist-language=yaml -
danielbayley created this gist
Nov 26, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ #! /usr/bin/env ys-0 !yamlscript/v0/data # https://eemeli.org/yaml#yaml # https://npm.im/@yaml/yamlscript # https://yamlscript.org/doc/cheat # https://yamlscript.org/doc/core # ys --yaml */load.ys #--json # tail -n+2 < */load.ys | pnpx yaml --single --json --indent ${TABSIZE-2} # Convert object: &object a: 1 b: 2 c: 3 keys:: &keys keys(*object) # a–c values:: &array vals(*object) # 1–3 object->entries:: &entries into([] *object) # [[a, 1], [b, 2], [c, 3]] entries->object:: omap(*entries) # a: 1, b: 2 c: 3 # Map map:: map(inc *array) # 2–4 map-object:: map((fn [[k, v]] [k inc(v)]) *object):omap # a: 1, b: 2 c: 3 # Filter filter:: filter(even? *array) # 2 filter-object:: dissoc(*object "b") # a: 1, c: 3 #filter((fn [[k v]] (not (in? k ["b"]))) *object):omaps grep:: grep((has? ["b"]) *keys) # b # Reduce add: &add [4, 5] total:: reduce(+ *add) # 9 # Merge concat:: concat(*array *add) # 1–5 # Flatten nested: &nested [0, *array] flatten:: flatten(*nested) # 0–3 # Paths pwd:: CWD.replace(ENV.HOME, "~") # ~/path/to/load.ys dirname:: split(FILE "/"):butlast:last # ~/path/to basename:: &basename split(FILE "/"):last # load.ys #defn basename(path): TODO #filename:: basename(FILE).split("."):first filename:: split(*basename "\."):butlast:last # load #filename:: split(FILE "[/.]"):butlast:last extension:: split(FILE "\."):last # ys # Define repository: - &owner semver - &repo semver - &branch master #main # Interpolation repo =: &repository "$(*owner)/$(*repo)" url =: &url "https://raw.githubusercontent.com/$(*repository)/refs/heads/$(*branch)" # Fetch Data fetch =: json/load(curl("$(*url)/package.json")) name:: fetch.name # semver-spec # Fetch Line pattern:: slurp("$(*url)/semver.md").lines().nth(356) #?plain=1#L357 # Recursive this =: yaml/load(slurp(FILE).lines().drop(3).join("\n")) recursive:: this.nested:first # 0