This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-28
Channels
- # aleph (1)
- # announcements (16)
- # bangalore-clj (1)
- # beginners (78)
- # cider (109)
- # clara (3)
- # cljdoc (6)
- # cljsjs (3)
- # clojure (209)
- # clojure-dev (11)
- # clojure-europe (1)
- # clojure-france (9)
- # clojure-italy (13)
- # clojure-nl (3)
- # clojure-spain (2)
- # clojure-spec (19)
- # clojure-uk (50)
- # clojurescript (41)
- # clojutre (2)
- # core-async (45)
- # cursive (2)
- # datomic (14)
- # emacs (6)
- # figwheel-main (1)
- # fulcro (101)
- # graalvm (1)
- # graphql (3)
- # jobs-discuss (3)
- # kaocha (12)
- # leiningen (8)
- # music (4)
- # off-topic (47)
- # parinfer (8)
- # pathom (17)
- # pedestal (53)
- # re-frame (47)
- # reagent (22)
- # reitit (4)
- # shadow-cljs (49)
- # tools-deps (87)
I am coding in CLJS because my employer wanted to build web apps, and I m convinced them to let me have fun with it xD.
Now, I slowly convincing other developers to move to clojure, but the task is hard in the data science field
The ease of R and python is hard to let go.
There are folks working on better interaction between Clojure/Java and data science type libs in Python, having fairly regular meetings and publishing the recordings of them. They are in the data-science channel on Slack, and on Clojurians ZulipChat.
@norilinoriginal Are you looking for the #chlorine channel?
As for the ctl-,
key bindings -- they work fine for me on both Windows and macOS. I haven't tried Linux.
This is my Atom/Chlorine setup https://github.com/seancorfield/atom-chlorine-setup that I use on Windows/macOS.
@norilinoriginal keybindings in atom are not good to put it mildly. ctrl-, in atom may lead to the settings panel / tab in *nix / windows -- you might find the following to be helpful: https://atom.io/packages/keymap-control: > After Atom starts, Keymap Control looks inside your keymap.cson file for any keybindings that conflict with keybindings from other packages and automatically unbinds them, removing the conflicts which can prevent your new keybindings from working. > This can remove keybindings from Atom's core just as easily as from 3rd party packages. Any keybindings you set in your keymap.cson file will always take precedence, so you can concentrate on setting the keybindings you want, instead of why they don't work.
in Java/Clojure when writing to stdout in a command line tool, e.g. print "hello" in a loop forever, how you can you stop doing that, when the next program stops consuming input, e.g. with head -n3
?
concrete use case: https://twitter.com/borkdude/status/1166664789323657216 right now this example doesn't halt
My understanding of Unix architecture is that the pipe operator is basically a file abstraction. As far as your Clojure program is concerned, it’s just writing to a file, and neither knows nor cares whether that file is ever being read. So I wouldn’t think it was possible for your program to know when to stop. (Also I think you can theoretically feed an infinite number of lines to head
— it may stop printing after the first n
lines, but I don’t think that stops it from reading and discarding every line after that.)
That said, you might be able to wrap your command line in a sub-process, and have a consumer function that sent its parent process a kill
signal after a certain number of lines of input.
$ (bb -o '(defn yes [] (repeat (or (first *command-line-args*) "y"))) (yes)' hello | print-and-die -n 3)
well, I don't want a special substitute command for reading a number of lines, head should just work, since that's standard bash 🙂
Yeah, it’s also possible that there’s depths of bash I’ve never plumbed
Substitute head.c
for yes.c
and you can see the source for head
too
https://unix.stackexchange.com/questions/268344/how-does-a-pipeline-knows-when-to-stop
Ah, now that’s interesting.
I’ve seen references to SIGPIPE before but I never really knew what it did.
(import 'sun.misc.Signal)
(import 'sun.misc.SignalHandler)
(def sig (Signal. "PIPE"))
(def handler
(reify SignalHandler
(handle [this signal]
(println "SIGNAL" signal)
(System/exit 0))))
(Signal/handle sig handler)
(loop []
(Thread/sleep 100)
(println "hello")
(recur))
$ clj /tmp/sigpipe.clj | head -n3
hello
hello
hello
Love it 😄
(import 'sun.misc.Signal)
(import 'sun.misc.SignalHandler)
(def signal-state (atom nil))
(def sig (Signal. "PIPE"))
(def handler
(reify SignalHandler
(handle [this signal]
(reset! signal-state :PIPE))))
(Signal/handle sig handler)
(try
(loop []
(Thread/sleep 100)
(println "hello")
(if (= :PIPE @signal-state)
(System/exit 13)
(recur))))
It doesn't see the correct exit code, but otherwise it works.Try printing to STDERR in your handler
fn
$ clojure /tmp/sigpipe.clj | head -n3
hello
hello
hello
PIPE receivedPIPE received
PIPE received
PIPE received
Surprising it would get called 4 times
well, depending where you put it
I read somewhere you might get more than one signal, but at least once is good enough for me
I thought this was pretty interesting: https://codelani.com//posts/does-every-programming-language-have-a-central-package-repository.html
Clojure is in the top 10 for available packages which I find quite respectable for its "niche" status. Then if you add in the access to JVM and JS (the top 2 on the list), Clojure basically has the largest ecosystem in the whole universe, right?! Disclaimer: I have no clue about the accuracy of the methods here, but that can be said about everything these days.
There is JS packages in mvn
repo
https://github.com/cognitect/transit-js
It seems to be mostly because a lack of central repository in a lot of languages. Swift is a lot newer, but already twice the packages of Clojure, not sure why. And Rust is just behind Clojure but somewhat newer.
well if clojure has access to java repositories, and clojurescript has access to javascript repositories, seems like you can add all those together :)
I think these numbers are a good counter argument to both the "eww, I don't want to have to know JS or Java to use Clojure" concerns (not that I agree necessarily), well Clojure has over 20,000 of it's own libraries now, you don't have to, and then in reverse too, "Clojure is a small community", well we actually have the largest ecosystem in software development.