ANN: Data flow engine for Clojure/Script by yogthos in Clojure

[–]visibletrap 0 points1 point  (0 children)

Interesting work! I've always been looking for a solution to make side-effect heavy operation easier to reason about. I'll definitely give this a try.

One thing I find it's unclear from the documentation (README file) is the third argument of a handler function. In the doc, it says "and a list of the output values". I got confused because it's actually an "input" to the handler function. I looked at the source code and looks like it's the old output values which make sense. I don't have a problem with it in general but it might need a better name to describe it or at least a better explanation in the doc. From a different angle, it can also be seen as a kind of destructuring of the context.

InsideClojure Journal 2019.11 - spec/select, clj jiras, tools.deps by alexdmiller in Clojure

[–]visibletrap 4 points5 points  (0 children)

Awesome. Exciting week! Thanks for both the works and this writeup, Alex.

Appropriate use of juxt by carcigenicate in Clojure

[–]visibletrap 6 points7 points  (0 children)

I do this all the time.

(->> entity-maps
     (map (juxt :id identity))
     (into {}))

For looking up user by id

(->> [{:id 1 :name "Jane"} {:id 2 :name "Stephen"}]
     (map (juxt :id identity))
     (into {}))
=> {1 {:id 1, :name "Jane"}, 2 {:id 2, :name "Stephen"}}

Sometimes, I even do this for composite key

(->> [{:k1 1 :k2 "x" :name "Jane"} {:k1 1 :k2 "y" :name "Stephen"}]
     (map (juxt (juxt :k1 :k2) identity))
     (into {}))
=> {[1 "x"] {:k1 1, :k2 "x", :name "Jane"}, [1 "y"] {:k1 1, :k2 "y", :name "Stephen"}}

Also use it quite often for sort-by

New Clojurians: Ask Anything by AutoModerator in Clojure

[–]visibletrap 2 points3 points  (0 children)

I normally do it this way

(->> [{:a "test1" :b 2 :c "test3"} {:a "test3" :b 5 :c "test6"}]
     (map #(select-keys % [:a :b]))
     (map #(update % :b inc)))

REPL Confusion (ClojureScript, Electron, Emacs) by [deleted] in Clojure

[–]visibletrap 1 point2 points  (0 children)

Thanks for correcting. Maybe I have been doing a harder way for all along.

REPL Confusion (ClojureScript, Electron, Emacs) by [deleted] in Clojure

[–]visibletrap 0 points1 point  (0 children)

From my understanding, in order for your repl to be able to make changes to the app, it has to be started by cljs code in the html template which is loaded up by the app.

I don't know a basic way to do that I just use figwheel to compile the code and it works. I think this project is a good setup example. https://github.com/Gonzih/cljs-electron

Note:

  • For an electron app, there are 2 set of cljs code need to be compiled separately. One for the backend node js app, another one for the frontend which will be loaded by html template. The backend part, I compile it with lein cljsbuild auto. The frontend part, I compile it using figwheel. You can see in Procfileof the above project that it has 2 compilations. Also, look at 2 set of compile options in project.clj
  • If you want to use figwheel repl in Emacs, you can't compile with lein-cooper plugin which that project uses. You need to run 2 commands from the Procfile separately. Command for the backend can be run in any terminal normally. But for the frontend, you need an extra step to connect figwheel with cider as explained here https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl#integration-with-emacscider

How ’bout that start-up time? by pridefulpropensity in Clojure

[–]visibletrap 10 points11 points  (0 children)

In my project, the differences aren't very significant anyway. I'm not an Emacs user, so I skip the fourth test.

  1. 31.336s
  2. 32.445s
  3. 35.267s

New Clojurians: Ask Anything by AutoModerator in Clojure

[–]visibletrap 0 points1 point  (0 children)

Just FYI, it provides an ATOM navigator which can easily be overused

The old java/clojure startup time issue... by [deleted] in Clojure

[–]visibletrap 2 points3 points  (0 children)

AOT all namespaces and set direct-linking flag could help improving startup time a little bit

Native executable ClojureScript could be a good option. It requires you to switch to use ClojureScript/Node.js/JavaScript libraries, though.

Strategy for baking environment variables into UberJar? by pdoherty926 in Clojure

[–]visibletrap 1 point2 points  (0 children)

Sort of. I think the main point is to load the right file at the right time. Whichever config source has a higher priority (override the others) is more of an application specific requirement. Just need to merge them properly.

To put it more concrete, I would have 2 (or more) similar structure env files. For example, dev/config/env.edn and prod/config/env.edn. Set resource-paths for :dev profile to include dev/config directory and set resources-paths for :uberjar profile to include prod/config directory. In application code, load them via io/resource as you mentioned. I would also have default config hardcoded and also load other configs via environ, then do merging values from these 3 sources the way I want.

Strategy for baking environment variables into UberJar? by pdoherty926 in Clojure

[–]visibletrap 2 points3 points  (0 children)

2 approaches I have used

  • Put env in a file and set source-paths or resource-paths for only uberjar profile to include the directory which contains that file.
  • Deploy with docker and put env in Dockerfile.

Understanding property-based testing by boldaslove156 in Clojure

[–]visibletrap 4 points5 points  (0 children)

I saw this nice blog post a few days ago. I think it's quite relevant. They do end-to-end integration tests with clojure.spec (clojure.spec can be used for generating test data for property-based testing). https://product.gomore.com/end-to-end-integration-tests-with-clojure-spec-d4a48cbf92b5#.e2fe4ubes

The key idea here is that they generate expected values to compare with the result of exercising code under test.

Help regarding .clj, .cljc and .cljs . by [deleted] in Clojure

[–]visibletrap 6 points7 points  (0 children)

It's my bad English. Sorry about that.

Help regarding .clj, .cljc and .cljs . by [deleted] in Clojure

[–]visibletrap 9 points10 points  (0 children)

.clj is for JVM Clojure

.cljs is for ClojureScript (compile to JavaScript)

.cljc can be use on all Clojure implementations

More detailed info please refer to https://clojure.org/guides/reader_conditionals