yamlscript

Ingy döt Net 2024-06-21T15:57:13.182419Z

I had no idea slurp did this!!!

ys -e 'say: slurp("")'

Ingy döt Net 2024-06-21T15:58:58.446309Z

Makes ys::std/curl useless 🙂

chromalchemy 2024-06-21T16:00:50.844369Z

Yeah its pleasently, shockingly simple!

Ingy döt Net 2024-06-21T16:01:29.100229Z

I love it!

Ingy döt Net 2024-06-21T16:04:25.205699Z

Saw it here this morning https://www.youtube.com/watch?v=rQ802kSaip4 while watching videos to boost my repl knowledge

Ingy döt Net 2024-06-21T16:04:39.691579Z

Nice short video

2024-06-21T16:18:13.768359Z

slurp is a wonderful bit of "Java candy" from prehistoric Clojure... just be aware it negotiates and tears down the HTTPS connection every time, so, it is very slow in a loop.

✅ 1
Ingy döt Net 2024-06-21T16:49:37.272089Z

Interesting that its from Java. Makes sense as Clojure feels pretty no nonsense (or do the nonsense on your own)

Ingy döt Net 2024-06-21T16:51:42.476579Z

In that light I'd say YS is pro-nonsense. Function needs a sequence and a string but you forget what order. Don't worry YS got you. If it's too slow, there's 5 other ways to do it, and always the most clojure way...

Ingy döt Net 2024-06-21T16:52:49.593529Z

I literally spend ~25% of my clojure time remembering how to call the functions I used yesterday 😕

Ingy döt Net 2024-06-21T16:53:18.464249Z

I guess I don't want to become a Clojure expert when I grow up...

😂 1
Ingy döt Net 2024-06-21T19:09:51.624709Z

Like why do I have to (atom nil) instead of (atom) ? (hit that a minute ago). Many functions have nice defaults and arities, but then many don't. Many thread nil to nil, and many don't.

2024-06-21T22:53:30.778869Z

You can reliably nil-pun sequences.

Ingy döt Net 2024-06-21T22:59:12.812269Z

I know but it should go further imho

Ingy döt Net 2024-06-21T16:47:42.198089Z

So yesterday I told you I posted https://yamlscript.org/posts/jun-20-2024/ which got no noticable interest here. Well I have to say I'm using this thing in anger now, and quite happy with (at least some of) the results. I just needed to figure out how to split markdown file string into fenced-code and text in between. I decided to ask https://gist.github.com/ingydotnet/0dbc71cf2c827d24855b239a0d518b69 Not perfect but worked really well for me. Was able to make this for my exact needs:

defn split-on-fenced-code(markdown-str):
  code-block-re =: /(?s)(?:
MY:\S+\n.*?\n
\n)/
  texts =:
    split markdown-str: code-block-re
  fenced =:
    re-seq code-block-re: markdown-str
  interleave texts: vec(fenced) + ['']
Seems not the most efficient, but certainly efficient with my time (except that I used more time writing about it here 🙂 )