This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-25
Channels
- # beginners (26)
- # boot (1)
- # cider (21)
- # cljdoc (26)
- # cljs-dev (7)
- # clojure (99)
- # clojure-gamedev (6)
- # clojure-italy (5)
- # clojure-nl (4)
- # clojure-russia (1)
- # clojure-spec (5)
- # clojure-uk (59)
- # clojurescript (49)
- # clojutre (6)
- # component (13)
- # core-async (2)
- # cursive (30)
- # data-science (2)
- # datomic (29)
- # emacs (9)
- # fulcro (100)
- # hyperfiddle (1)
- # jobs (2)
- # luminus (4)
- # lumo (23)
- # off-topic (22)
- # other-languages (37)
- # parinfer (1)
- # re-frame (2)
- # reagent (5)
- # reitit (12)
- # ring (12)
- # rum (3)
- # shadow-cljs (168)
- # slack-help (1)
- # spacemacs (7)
- # specter (2)
- # tools-deps (8)
- # vim (11)
- # yada (3)
I need a "infinite loop" that every "5" seconds fetch a API and insert data in a channel In some situations, I wanna be allowed to stop this service and start it again. Should I use thread, async/go, future-call? There is many options and I cant decide.
Do you want the responses to be in the channel in the same sequence as the requests that made them?
@dominicm i think the framing is wrong: the question isn’t whether they are constants but whether they are globals. there is (some) value to calling attention to that.
@henrik We use Compojure mostly at work, with Bidi on one of our apps. We may use Bidi more in future since it separates routes from handlers better (and allows for bidirectional route naming).
@lee.justin.m Globals as opposed to... local bindings? Do they need separate naming conventions? Surely you can see a local binding on the same screen as the code that uses it? (or else you should probably refactor your function into smaller functions)
Would you argue "global" functions should have a different naming convention to local bindings of functions?
Any symbol that isn't obviously and visibly a local binding (or argument) must be global by definition, right? I'm having a hard time accepting that different naming conventions are needed for that...
I find it particularly helpful in communicating that “this is an arbitrary parameter” like 200ms of delay or something like that.
Commas in English text have semantic meaning so, yes, that are necessary.
Commas can't just be randomly added and taken away. They're not about readability.
Compare: "Let's eat, grandma!" vs. "Let's eat grandma!"
hey guys, I want to read from stdin as it is written to by another program, doing (slurp *in*)
works, but only if i've received EOF. What I want instead is to know about more data and be able to react to that as it comes in (similar to epoll/select in C). It seems like there may be a way of doing that with channels, but I'm not really familiar enough with them to put it together yet. If anybody has some tips it would be helpful 🙂
@U36FXS8SD you may create a BufferedReader and read from it - e.g. line by line:
(let [rdr ( *in*)]
(.readLine rdr))
Seems to work. I ended up having to do
(let [rdr ( *in*)]
(doseq [line (line-seq rdr)] ... ))
but you got me pointed in the right direction, thanks!line-seq calls .readline with lazy-seq if I remember correctly. Doseq goes all the way around to realize the sequence. You should just call .readLine directly
Indeed but as far as i know . Notation uses reflection either way.That can slow production code. Just
` (set! *warn-on-reflection* true)
`on the repl and see it for yourself. @U36FXS8SD is it possible to inline predicates in a spec? Assume that I am checking maps with three keys :foos
:bars
and :op
where :foos
and :bars
are always vectors - but the structure of their elements is dependent upon the value of :op
. Assuming that :op
could be be 1
or 2
- Is there a way of achieving something like
(s/def ::check-op-1 (s/keys :req-un [[::op op-1?] [::foos foo-1-pred?] [::bars bar-1-pred?]]))
(s/def ::check-op-2 (s/keys :req-un [[::op op-2?] [::foos foo-2-pred?] [::bars bar-2-pred?]]))
(s/def ::valid-data (or ::check-op-1 ::check-op-2)))
@henrik I can never remember the bidi syntax, so i still use compojure for simple stuff, and bidi for everything else
is there any tool that helps with replacing all the :refer :all
in namespace declarations with :as something
and then prefixing all the vars accordingly?
I would like to clean up a project that uses that all over the place without having to do it manually since it would take ages
Take a look at https://presumably.de/search-and-replace-with-git-using-git-xargs-and-rpl.html
that's quite nice actually but I can do similar things with Emacs and projectile probably
it's more important to have enough knowledge about the project like refactor-nrepl has to really do it in one go maybe
I wonder how hard would it be to write a program that does it, using the Clojure reader. But I’d probably use sed or something similar…
well it's not so easy/possible with sed since it would have to find where something comes from
assuming there are many :refer :all
per namespace
if there is only one it could be doable but you would still have to know which symbols to replace
and well probably need to do something ad hoc, I thought maybe Cursive or something else was able to do that
@andrea.crotti clj-refactor for emacs has some tools for that. For instance https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-stop-referring
ah nice. it's failling on this project now but I can try that in other projects as well
Take a look at https://presumably.de/search-and-replace-with-git-using-git-xargs-and-rpl.html
is the etaoin library for webdriver based testing still in vogue as A Good Thing or has it been surpassed by another library/methodology?
Hi. Is a single spit
into a file atomical? I want to make sure that either the old content is left in or all the new data is written.
If there’s a power failure or something, it might not be. The safe way is 1) write new data to a file with a tmp name, 2) rename the old file to file.bak
, 3) rename the new file to the correct file name. That way you’re as sure as you can be that your old data is there until the new data is fully written.
Right, or use some 3rd party solution. I was just hoping that maybe it's a built-in feature for the single write.
Hello all! Quick question? I’ve noticed when I used either pmap
or Thread/sleep 100
(don’t know if it’s one, the other, or both) causes my Clojure program to require 30 seconds before exiting, as if waiting for a thread to be killed.
I seem to recall there was a Clojure call that “kills/cleans-up all threads” so the program can exit quickly/cleanly — can anyone point me in the right direction? Thank you, as always!
Yes! Thanks so much, @the2bears! Iit was one of those things I just put up with (just hit Control-C), but part of me really wanted to figure out how to actually fix it. 🙂
I am using bidi make-handler for routing but it seems / is required. "something" something-handler
doesn't work when called like ...com/something/ - any idea how I can make non / redirect to /. Should I really create a redirection for every route?!
With deps.edn, is there a good way to have several projects in a single repository which share a single set of pinned dependencies? I’d like to have something akin to a versions.edn
which just pins versions for dependencies, which deps.edn
files can reference.
default-deps is a nod in this direction and something we want to enable, but not really practically useful yet. Needs a bit more work
something like a parent pom, a project that is just there for common deps, could be a thing
Hah no worries Ghadi, I’m currently trying to replace a fairly involved set of lein projects with something that’s at least Mostly Data (TM) mainly for classpath caching and simplified impact analysis.
Looks like the “easiest” thing to do is a custom runner which uses the deps machinery under the hood, and comparable bash script to $ which clojure
that can handle the cache check/hit logic.
Since really what I want is effectively middleware - of which deps has none because exposing arbitrary middleware defeats most caching 😕
there are at least 2 parts. 1. specifying commons deps in one place and 2. ensuring all projects are using a specified version of certain deps
#2 seems like the biggest bang for the buck, just some tool to scan deps.edn files and throw an error if the expanded deps map uses a different version of a dep, and then make it part of your test suite
Untested; You could also use a top-level deps.edn only, and aliases to mix in the correct versions, along with the :default-deps
key @arrdem
> :default-deps
provides a set of default coordinate versions to use if no coordinate is specified. The default deps can be used across a set of shared projects to act as a dependency management system:
https://clojure.org/reference/deps_and_cli
We would definitely like to have a clean path to do this. It is In Scope. :)
Hum yeah it doesn’t look like there’s a way to bolt on another source of deps data atm beyond the “$PWD/deps”, CLI args and the config, and I’d like to avoid making my coworkers install user level configs.
arrdem for now I think you'd have to put everything in the top-level deps edn:
{:deps {whatever...}
:aliases {
:versions {:default-deps ....}
:subdir1 {...}
:subdir2 {...}}}
Yeah that’d definitely work Ghadi, and wiring CI up to run that would be pretty straightforwards.
the version alias would have :default-deps, all other aliases could be free form (mostly extra-deps / extra-paths)
I recently used tea-time for that stuff. If you care about dates and not just time also consier tick
I’ve also used Chime (https://github.com/jarohen/chime) for a couple years in production and it works just fine.
On AWS, I use Cloudwatch