This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-20
Channels
- # aleph (19)
- # aws-lambda (8)
- # bangalore-clj (1)
- # beginners (13)
- # boot (179)
- # cljs-dev (12)
- # cljsjs (2)
- # cljsrn (6)
- # clojure (174)
- # clojure-italy (14)
- # clojure-nl (2)
- # clojure-russia (172)
- # clojure-spec (29)
- # clojure-uk (22)
- # clojurebridge (10)
- # clojureremote (1)
- # clojurescript (79)
- # cursive (46)
- # data-science (1)
- # datascript (8)
- # datomic (18)
- # defnpodcast (2)
- # emacs (9)
- # events (6)
- # hoplon (11)
- # klipse (13)
- # lein-figwheel (1)
- # leiningen (1)
- # luminus (1)
- # lumo (88)
- # numerical-computing (1)
- # off-topic (24)
- # om (33)
- # onyx (58)
- # protorepl (8)
- # re-frame (10)
- # reagent (26)
- # ring (8)
- # ring-swagger (7)
- # rum (22)
- # spacemacs (25)
- # specter (5)
- # uncomplicate (37)
- # untangled (75)
- # vim (17)
- # yada (3)
General workflow question for you guys. Is anyone developing locally, but running/testing remotely on a server? I’ve maxed out the available RAM on my laptop and can no longer run a Client + Server + Datomic locally. I’m using Intellij + Cursive for development. If you’ve found an ideal workflow please share! Right now I’m setting up an Ubuntu server and am planning on rsyncing on save + using a remote repl.
@seantempesta : not sure how helpful this is: with emacs + dirac (instead of cider), it should be easy to run stuff remotely
@qqq: I did emacs back in the day (and liked it), but once I started using IDE’s I can’t go back. Thanks though.
@seantempesta: unless the ide has builtin remote dev support, rsync is probably the best approach
actually, sshfs / fuse may work where you directly mount the remote fs as a local directory
yeah, I’m looking into that now. Rsync seems a little inefficient in that it won’t know which files have changed so it’ll have to rescan on every save.
Welcome @davidtpriest! What brought you to clojure?
Yeah…that’s a good point. I was thinking about my .git directory, but then again there’s no need to replicate it.
this is unnecessary, but as an overuse of tech, you could probably use inotify or boot/watch to monitor when files change, and then remote copy them 🙂
@seantempesta a app I develop needs late amounts of memory. Doing remote nrepl with cursive is actually really nice
I'm not sure how it works but there's some amount of file syncing being done with Cursive. So you edit, tell cursive to reload a file in a repl and it sends your local copy over
That plus git works pretty well.
@tbaldridge @seantempesta Cursive does that based on changes in your local FS
So when you send a file, it’ll work out the dependent files which have changed since the last time you sent them, and send those before sending the file you actually told it to.
@tbaldridge @cfleming: Oh? Rad! That’ll make things easier.
does anyone here have experience with the reducers library? i'm have a function where the bulk of the work is done by map
where the number of function calls grow exponentially and the output doesn't need to be ordered so am benchmarking it with pmap
r/map
and a hand-rolled core.async version of map, but r/map
is just returning some object code when i swap it out. do i need to use it differently somehow?
@seantempesta so you don't have to look it up, on the remote machine it's as easy as lein repl :headless :host 0.0.0.0 :port 4242
oh, answering my own question...it seems i need to wrap it in into
, r/reduce
, or r/fold
. but in this case, i'm actually running it for side effects...i wonder if doall
would work?
seems to be another case where parallelism is magnitudes slower...i think i underestimated how much i could tune the sequential version. it's at ~1µs now with pretty serious input so no way can i beat that with multithreading
@sophiago how long does each task in the map
take?
I probably wouldn't try to make it parallel unless I can do it in batches of 10ms or so. 100-1000ms would be best.
the tasks themselves are very fast. there's just many of them. presumably if each were much more intensive it would be an ideal case for r/map
they also increase exponentially with the input. one of the parameters determines the number of calls to map
. so i figured one of the upsides of reducers is i believe they fall back to the sequential version when appropriate?
anyway, it's just so fast right now running totally sequentially. i'm actually quite floored. i originally thought i made a mistake in benchmarking it when it was 100x this sequentially. and i still haven't tried some further optimizations
one thing i found odd related to optimization is that it's not running any faster if i use (vector-of :short ...)
. nearly identical time
and i made care to not box them anywhere so unless i'm missing that i can't explain why that wouldn't be faster
Is there a simple solution to get my lein run output to support ansi colors in the text, in a windows console?
I'm suddenly getting weird errors trying to start my repl. java.lang.NoClassDefFoundError
that seems to point to clj-time
internals. I've ran lein do clean, compile, repl
multiple times, used git clean
multiple times, and even deleted my .m2
folder. When I don't require clj-time
into the failing namespace, the error occurs elsewhere. Anyone have any tips for me?
When you don't require clj_time , is it the same error that occurs elsewhere? (about clj_time.core.DateTimeProtocol) .. if not, what's the error then?
Yeah, iirc. I'll try again in a sec. I killed all java processes and am trying to start the repl now
if that doesn't work, I'll try a reboot. Which probably should've been one of the first things I try 😄
Earlier I checked the md5 hash of the clj-time version that I have and compared it with a team mate, no difference there
y-modulo being based on the modulus of x-count seems counter intuitive, which is already a modulus itself
glad it got worked out - I don't think I'd have figured it out that easily. Still too noob at this.
I’m working with mount
/`defstate` and cprop
to load environment variables. I'm rather new to this set up (via luminus). I’m missing something because I get the following error when trying to access an env var:
mount.core.DerefableState cannot be cast to clojure.lang.IFn
I found this, but I’m having a hard time making sense of it: https://github.com/yogthos/clojure-error-message-catalog/blob/master/lib/mount/derefablestate-cannot-be-cast-to-ifn.md@mruzekw The place you're trying to access an env var needs to be wrapped in a function.
Could you give an example? This is akin to my current code:
(def auth (AuthAPI. (env :domain))
Why is the result 1 and not 1.5?
@danielgrosse >;; (quot m n) is the value of m/n, rounded towards 0 to the nearest integer.
Ah okay.
if you want a float out the end though make sure you pass a float in or coerce to one.
@alexanderjamesking but not quite.
does anyone know what might be wrong with this jtds connection object for jdbc?
(def conn {:subprotocol "jtds:sqlserver"
:classname "net.sourceforge.jtds.jdbc.Driver"
:subname "//server/database;user=user;password=password"})
i'm a .NET guy so i'm not exactly sure how the jtds connection strings should be formatted
@alexanderjamesking int
casts the number to an integer (a simple Java (Integer) x
) behind the scene so like, @poooogles says everything after the .
is dropped (the number is truncated)
Hi. I like to build a macro called defhandler
which instead of def’ing a var, registers the data/code in another way. Each handler has a name. Would you specify the name as symbol or keyword? I mean (defhandler foo …)
or (defhandler :foo …)
? I like to go the keyword route because it doesn’t def a var. It’s like in spec. Is this the right way?
@akiel If you want to go the keyword way, you don’t necessarily need a macro but can probably (and should) do way with a function
But that depends on the implementation details of said functionality, you can still have a macro for convenience’s sake 🙂
You would need some kind of registry in which to save the handlers by keyword tho, maybe a simple hashmap could suffice
@quartz The macro implementation currently builds a defmethod
but customizes the code given.
For the user defhandler
looks a lot like defn
except for the keyword instead of symbol.
I see, I would personally go a more data-oriented way. Easier to reason about and mess with at runtime. Then I could write a macro with the semantics you’re looking for that would use the (hopefully) side-effect free functions under the hood
If you already have everything based on dynamic dispatch (defmethod) then it would require a bit of work to refactor, and maybe your current solution is fine for what you need 🙂
I have not implemented much now. What I’m trying to do is to define handlers (business logic) together with middleware to apply and some other spec like data. Each handler can be presented as a map with one function in it. So it’s not pure data in the edn sense. What the macro currently does, it to generate a defmethod
with the middleware already applied in code. I also could call the middleware at runtime from the data. You would go this route? Registering all the maps in an atom and running from there at runtime?
You don’t need to go pure data if you don’t intend to send it somewhere else, using functions as objects is pretty fine
But yes, I would try to aggregate all the info you need in a single hashmap probably and keep the functions as pure as possible
Then you could maybe define some helper functions around an atom for convenience’s sake
You can get some inspiration from existing projects like pedestal: http://pedestal.io/reference/interceptors
yes my middleware is modeled after ring, except that I like to be able to define the usage of middleware right at the handlers. With ring, you usually have other places to put your middleware stack.
Reason is that my handlers need special middleware each - so it’s not really the common middleware for many handlers
Yes, because everything in pedestal is an interceptor and interceptors take a context map with a :request and :response keys associated with it
I currently read the docs. It’s very nice that an interceptor can change the call stack!
Technically this wouldn’t make much sense, because handlers in pedestal are functions that take the request as the first argument and are expected to return the response
@quartz @akiel interceptors are pretty much the closest thing you can get to a "reified stack" in Clojure.
@tbaldridge that’s a very nice way to put it 😊
Where I define "reified stack" as: "taking the call stack and turning it into a value that you can manipulate and pass around like any other value"
@tbaldridge Yes that is very powerful.
and yeah, its super powerful, since you can pause execution (for async operations), modify the stack, and at all times debugging is much easier since you have a clear picture of what has been, and what will be executed.
I thought pedestal interceptors would only add async on top of ring middleware, but that reified call stack thing is not bad.
That's why I don't like middleware-esque approaches anymore. I get really tired of getting exceptions inside a few functions that were comp'd together. Everything is opaque in that case.
Indeed, have you checked Arachne @tbaldridge?
Yeah...I'm not a big fan of frameworks, or module systems though.
@akiel yep, I know of some people who have used it with other things, like distributed queues, or other message-like things.
@seantempesta Thanks! Career change mostly. Wanted to get into web dev, started with python, was introduced to Clojure by a few developers. Was amazed. Went all in with Clojure and not looking back! 😀
@quartz @tbaldridge Thanks for the pedestal pointer. I’ll try it in my use case.
clumsily
either split-with
and post-process that, or write it custom if you don't want to walk the sequence twice
I bet a utility library or two has it
I'd name it take-while+1
🙂 Well actually I don’t need anything but the one … so I guess drop-while
together with (take 1)
will suffice
or first
Is there a clearer way to express "if :selection
key is in map, then it should be less than the length of :matching
collection than
(fn [s]
(or (not (contains? s :selection))
(< (:selection s) (count (:matching s)))))
?looks optimal
only thing you could do is use desturcutring
(fn [{:keys [selection matching]}] (or (not selection) (< selection (count matching))))
I’m running (tools.nrepl/start-server :port <port>))
on a remote server, and it appears to start however I’m unable to connect with lein repl :connect <host>:<port>
. Moreover when I check to which ports are open with netstat -lptu
my chosen port isn’t there. Any ideas what might be going on?
how does it appear to start? are you sure you are starting it on the right host? if you are starting it from a repl to a process running inside a docker container for example, the process will be listening in the docker container, not the host
For the sake of sanity checking, I do see my nrepl server listed when I run that command:
tcp6 0 0 [::]:7888 [::]:* LISTEN 28446/java
I'm guessing you need to bind to "0.0.0.0" to expose the port to connections from non-loopback interfaces, are you aware of that?
(plus it's probably best not to do that and instead use an ssh tunnel)
yikes
it's localhost by default
fairly recent change though 🙂 https://github.com/clojure/tools.nrepl/commit/db9125c566f0ada9284cbc6ea01fd59edfcd2ad3
@pesterhazy I was not aware of that. it looks like it defaults to “localhost”. let me try
wall of text 🙂
@pesterhazy darn. was hoping that would work, but it’s still not showing up on netstat
@pesterhazy NVM! You are the winner!
netstat doesn’t show me what I thought it was showing me. and now lein repl :connect ...
works !
@pesterhazy thanks a ton
Sure thing