Fork me on GitHub
#announcements
<
2023-02-06
>
ericdallo11:02:47

Happy monday Clojurians! Announcing https://github.com/ericdallo/jet.el: Parse edn/json/transit/yaml directly from Emacs using a magit-like interface emacs Besides the main entrypoint, the package has lots of commands to parse edn and: • copy to clipboard • to a new buffer • print to messages • just paste at cursor Available at MELPA!

🙌 66
jet 8
cljparrot 26
❤️ 2
2
yes 2
borkdude12:02:29

PR welcome to jet to mention this tool :)

ericdallo12:02:51

Thanks, I'm working on that exactly now :p

cjohansen12:02:41

Amazing stuff 👏

cjohansen12:02:09

Can I somehow make keybindings for common pairs of options?

cjohansen12:02:31

Eg, make an interactive command that sets input to JSON, output to EDN, and copies to the clipboard

cjohansen12:02:11

This is possibly feedback to jet more than this glue, but it would be cool if jet was able to guess the input automatically - seems like it should be possible?

ericdallo12:02:22

it's possible indeed, I'll add a example in the readme

ericdallo12:02:38

guess the input is a little bit harder I guess

borkdude12:02:05

I guess all json is valid transit, so how would you guess the difference?

cjohansen12:02:19

try parsing it as transit first?

cjohansen12:02:30

Sorry, I misunderstood

cjohansen12:02:43

If transit can read both transit-specific JSON and just regular JSON, then there is no big problem? Default behavior with no -i could be to try to parse as edn, then as transit, then as yml.

borkdude12:02:39

I guess you could do this in emacs first and then see how it works out

oly12:02:03

nice I use jet extensively for formatting in emacs and converting between json and edn, I will go install, @U04V15CAJ curious if it would be possible to add in other map types like say python dict's as a quick way to convert, between languages I guess custom parsers would be needed ?

borkdude12:02:56

@UU67HFS2X What does that look like?

ericdallo12:02:50

pretty similar to javascript maps: {'foo': 'bar'} IIRC

borkdude12:02:11

in that case converting from JSON should already work?

borkdude12:02:47

except that JSON doesn't support single quotes I guess

👍 2
cjohansen12:02:08

(defun jet-to-clipboard (thing &optional args)
  "Run jet for THING at cursor and ARGS copying to clipboard."
  ,,,)
It’s been a while since I wrote elisp… What’s thing @UKFSJSM38?

oly12:02:47

Got me wondering now, sure I would have tried the json version, need to go find a python map now and try that

oly13:02:15

I think where the python map fails is on the values, so you can have functions for example, the json parser does not like those, there maybe other data values but I imagine most are compatible

ericdallo13:02:48

Usually (jet--thing-at-point) @U9MKYDN4Q, the region selected or current form at point

cjohansen13:02:02

Yeah, just found it 😅 Thanks 🙏

ericdallo13:02:34

@U9MKYDN4Q I improved the readme mentioning how to customize the functions so you can keybind

cjohansen13:02:57

Cool, thanks

cjohansen13:02:04

I ended up with these:

(require 'jet)

(defun copy-edn-as-json ()
  (interactive)
  (jet-to-clipboard
   (jet--thing-at-point)
   '("--from=edn" "--to=json"))
  (keyboard-quit))

(defun copy-json-as-edn ()
  (interactive)
  (jet-to-clipboard
   (jet--thing-at-point)
   '("--from=json" "--to=edn" "--keywordize"))
  (keyboard-quit))

(global-set-key (kbd "C-c j e j") 'copy-edn-as-json)
(global-set-key (kbd "C-c j j e") 'copy-json-as-edn)

👍 4
cjohansen13:02:39

New Readme will save the next person some time 😄

cjohansen13:02:50

Anyway, amazing stuff, thanks for your effort 👏

ericdallo13:02:44

Added your example to the readme how to keybind, thank you! gratitude

🎉 6
robert-stuttaford14:02:31

this is honestly so damn useful @UKFSJSM38 thank you (and thanks again to borkers!)

gratitude 2
zalky14:02:11

New: Simple https://en.wikipedia.org/wiki/DBSCAN clustering: • Pure Clojure/Clojurescript implementation Hope it is helpful! :rightwards_hand: 🎁 And more to come :face_with_open_eyes_and_hand_over_mouth: https://github.com/zalky/dbscan-clj

👍 16
👀 6
vemv17:02:33

nice! what lead you to write it? 🙂

🙏 2
zalky17:02:52

Thanks! I'm releasing a library in the next couple of days for building Re-frame/React apps that includes a visual debugger that overlays graphical elements onto the live application. I needed a simple clustering algorithm for collecting and grouping certain visual elements on the screen.

🚀 4
Carsten Behring17:02:51

Would you consider to "bind" your library closer to the upcoming Clojure data science stack by using a "tech.ml.dataset" (a column oriented table) as input data, instead of vector-of-maps TMD is living here: https://github.com/techascent/tech.ml.dataset If this is the case, you could as well considre to integrate the DBSCAN algorithm in one of the existing" collections of algorithms working on the same data format.

2
zalky17:02:49

Sure, I actually use tech.ml.dataset quite regularly, it's fantastic. But never thought to connect the two! I'd have to think about what that would entail, are there examples in the code-base of other grouping or clustering bindings I could look at as a pattern to follow?

Carsten Behring18:02:55

It should be very easy . The "core" of your algorithm could even stay as is. You would just convert from dataset to vector-of-maps, run your stuff and convert back to a tech.ml.dataset This might come with small performance penalty (versus rebuilding the algorithm using the TMD primitives), but probably negligible. So you just need a functions like yours : https://github.com/zalky/dbscan-clj/blob/bb7aa0fae89cd9c8477278b0aae70e443517284c/src/dbscan_clj/core.cljc#L88 but it takes a "tech.ml.dataset" as input. (and reurn such dataset as well), so things can be chained easely. Probably you need some options to define on "which columns" your clustering is performed.

Carsten Behring18:02:27

This new code would be a kind of "adapter" to TMD. So where "physically" place your original code and teh adapter is a question to answer. Doing the adapter will require a dependency to tech.ml.dataset , so maybe you code in https://github.com/zalky/dbscan-clj wants to avoid that.

Carsten Behring18:02:40

I would maybe even suggest to have the "adapter" standalone, depending on

io.zalky/dbscan-clj {:mvn/version "0.1.0"}
and
techascent/tech.ml.dataset {:mvn/version "7.000-beta-27"}
and it just does the data conversion and calls dbscan and converts back. A few lines of code in my view.

👍 2
Carsten Behring18:02:56

(one reason being ClojureScript compatibility). TMD is a Clojure library, not compatible with ClojureScript

zalky18:02:43

Yes, I agree with these points. I'll take a bit of a closer look to see what alternatives there are for integrating with tech.ml.dataset's abstractions. There might be some protocols or interfaces that are easy to implement. Thanks for planting the seed, I don't think I would have made the connection otherwise.

hlship17:02:37

com.walmartlabs/lacinia 1.2 Lacinia is an open-source implementation of the GraphQL specification, in Clojure. GraphQL is an outstanding approach to getting diverse clients and servers exchanging data cleanly and efficiently. GitHub repo: https://github.com/walmartlabs/lacinia Documentation: http://lacinia.readthedocs.io/en/latest/ Lacinia 1.2 fills in some gaps in Lacinia's functionality. Notable changes: • Direct control over the Executor used for callbacks • Subscription streamer functions are now on-par with ordinary field resolver functions by supporting directives and supporting access to the preview API • The entire http://lacinia.readthedocs.io/en/latest/tutorial has been rewritten to be more clear, and use modern standards (such as tools.deps for the build, and using Pascal Case field names). https://github.com/walmartlabs/lacinia/issues?q=is%3Aclosed+milestone%3A1.2

🎉 24
Sam Ritchie22:02:19

Announcing v0.3.0 of clerk-utils , a library designed to help write interactive docs like https://clerk-utils.mentat.org with #clerk. This release adds mentat.clerk-utils.build/{build!,serve!,halt!} functions for building custom ClojureScript bundles for #clerk. This lets you use ~any JS or CLJS library when writing custom viewers in Clerk. See the interactive docs notebook section on Custom ClojureScript for more detail: https://clerk-utils.mentat.org/#custom-clojurescript-builds 0.3.0 also adds a clerk-utils/custom #deps-new template (https://github.com/mentat-collective/clerk-utils/tree/main/resources/clerk_utils/custom) for generating a Clerk project with all of the custom ClojureScript stuff baked in. (Here’s https://github.com/mentat-collective/clerk-utils-custom-template.) • Release notes: https://github.com/mentat-collective/clerk-utils/releases/tag/v0.3.0 • Clojars: https://clojars.org/org.mentat/clerk-utils • Github: https://github.com/mentat-collective/clerk-utils

🚀 28
🔥 10
quoll22:02:52

https://github.com/quoll/donatello v0.0.1 A simple Turtle writer. This library converts basic Clojure structures into formatted turtle files. It accepts nested maps, such as used by Asami, or identifiers paired with simple maps. For simplicity, keywords are treated as QNames/CURIEs, and will be written out this way.

🐢 40
Cora (she/her)00:02:41

what's a Turtle in this context?

Cora (she/her)01:02:11

I really don't know much about RDF

Cora (she/her)01:02:24

maybe I should read about it

quoll01:02:33

It’s been my career for over 20 years, so… 😄

Cora (she/her)01:02:02

so ask you instead?? 😜

quoll01:02:33

I’m more than happy to help. But if you want something to read, you can start https://www.w3.org/TR/rdf11-primer/

💜 4
Eugen12:02:54

cool name 🙂

quoll13:02:08

Well, the partner library (for parsing Turtle files) is called https://github.com/quoll/raphael

Eugen13:02:46

makes sense 🙂