workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
i accidentally had written a lot of actually working code before realizing this issue, because i had `def`ed a channel with the same name as i was using inside go blocks
2017-12-27T21:02:39.000093
Linn
clojurians
clojure
ok well what the crap
2017-12-27T21:02:46.000032
Linn
clojurians
clojure
what core.async version are you using?
2017-12-27T21:02:57.000155
Margaret
clojurians
clojure
0.3.465
2017-12-27T21:03:20.000002
Linn
clojurians
clojure
i tried a lot of releases
2017-12-27T21:03:27.000062
Linn
clojurians
clojure
that's the version I was using
2017-12-27T21:03:37.000068
Margaret
clojurians
clojure
this is straight up clojure + core.async running from a custom uberjar (project here <https://github.com/noisesmith/bench> - I just run lein uberjar then make the jar an executable)
2017-12-27T21:04:34.000034
Margaret
clojurians
clojure
```option-bot.core&gt; (require '[clojure.core.async :as &gt; :refer [go chan &lt;!]]) nil option-bot.core&gt; (let [c (chan)] (go (prn (&lt;! c)))) ExceptionInfo Could not resolve var: c clojure.core/ex-info (core.clj:4739)```
2017-12-27T21:04:52.000117
Linn
clojurians
clojure
are you using leiningen? if so try using lein clean then starting a new repl
2017-12-27T21:05:32.000083
Margaret
clojurians
clojure
sometimes things can get wonky with core.async and lein caches when versions of things change, in my experience
2017-12-27T21:05:53.000149
Margaret
clojurians
clojure
same deal :disappointed:
2017-12-27T21:07:04.000119
Linn
clojurians
clojure
are you using any weird plugins? is there a chance that `lein deps :tree` shows a version conflict that would give you the wrong version of core.async?
2017-12-27T21:07:50.000071
Margaret
clojurians
clojure
nah, it’s pretty simple
2017-12-27T21:08:20.000023
Linn
clojurians
clojure
``` [clojure-complete "0.2.4" :exclusions [[org.clojure/clojure]]] [org.clojure/clojure "1.9.0"] [org.clojure/core.specs.alpha "0.1.24"] [org.clojure/spec.alpha "0.1.143"] [org.clojure/core.async "0.3.465"] [org.clojure/tools.analyzer.jvm "0.7.0"] [org.clojure/core.memoize "0.5.9"] [org.clojure/core.cache "0.6.5"] [org.clojure/data.priority-map "0.0.7"] [org.clojure/tools.analyzer "0.6.9"] [org.clojure/tools.reader "1.0.0-beta4"] [org.ow2.asm/asm-all "4.2"] [org.clojure/tools.nrepl "0.2.12" :exclusions [[org.clojure/clojure]]] [self/ib "9.73.01-SNAPSHOT"]```
2017-12-27T21:08:23.000029
Linn
clojurians
clojure
i mean, there is one custom java api library, but that shouldn’t do anything like this, i wouldn’t think
2017-12-27T21:08:46.000134
Linn
clojurians
clojure
I'm going to see if a project with those deps gives me the same issue
2017-12-27T21:08:54.000007
Margaret
clojurians
clojure
(ignoring self/lib that is)
2017-12-27T21:09:11.000036
Margaret
clojurians
clojure
well, hm
2017-12-27T21:09:31.000156
Linn
clojurians
clojure
i just did `lein repl` and that works
2017-12-27T21:09:44.000049
Linn
clojurians
clojure
so it’s just cider that’s the problem
2017-12-27T21:09:47.000176
Linn
clojurians
clojure
cider is clearly doing something goofy
2017-12-27T21:10:11.000056
Margaret
clojurians
clojure
thanks for figuring it out before I had to do more work heh
2017-12-27T21:10:28.000004
Margaret
clojurians
clojure
:slightly_smiling_face:
2017-12-27T21:10:33.000074
Linn
clojurians
clojure
so I guess the answer to "are you using any weird plugins" is "we didn't realize how weird cider is"
2017-12-27T21:11:02.000045
Margaret
clojurians
clojure
guess i’ll try updating that
2017-12-27T21:11:02.000053
Linn
clojurians
clojure
haha, yeah
2017-12-27T21:11:06.000120
Linn
clojurians
clojure
Tooling, the cause of, and solution to, every problem we have when programming clojure.
2017-12-27T21:11:31.000114
Margaret
clojurians
clojure
(to paraphrase homer simpson)
2017-12-27T21:11:52.000132
Margaret
clojurians
clojure
and i thought every issue i had with it had been fixed now that cider could pass its plugin versions into lein
2017-12-27T21:12:04.000155
Linn
clojurians
clojure
I stopped trying to figure that magic out a long time ago ¯\_(ツ)_/¯
2017-12-27T21:12:33.000085
Margaret
clojurians
clojure
updated cider, it all appears to work
2017-12-27T21:13:37.000011
Linn
clojurians
clojure
lost my awesome scratch buffer
2017-12-27T21:13:41.000023
Linn
clojurians
clojure
oh well
2017-12-27T21:13:42.000090
Linn
clojurians
clojure
thanks for being a sanity check
2017-12-27T21:15:02.000170
Linn
clojurians
clojure
i was like “there’s no way this has actually been broken for the last three years, right?”
2017-12-27T21:15:16.000122
Linn
clojurians
clojure
so here’s a more general question
2017-12-27T21:22:11.000095
Linn
clojurians
clojure
what’s a good way to represent a record that requires multiple api calls (and callbacks) to be fully realized?
2017-12-27T21:22:40.000066
Linn
clojurians
clojure
like, i have a representation of a stock
2017-12-27T21:22:48.000093
Linn
clojurians
clojure
and there’s a bunch of static info about it that’s just intrinsic to it
2017-12-27T21:23:11.000117
Linn
clojurians
clojure
but then also it kind of has a price, right? but to get the price, that’s the result of some other call
2017-12-27T21:23:42.000116
Linn
clojurians
clojure
so i have been putting that behind a `future`
2017-12-27T21:24:07.000152
Linn
clojurians
clojure
a good functional technique is to put the price and the time in there together, and make sure all price queries are explicit about time windows they accept
2017-12-27T21:24:16.000072
Margaret
clojurians
clojure
and sure, you can put a future in, you could also have a function that returns a future that returns a new instance of your record (with a newer time stamp) when realized
2017-12-27T21:24:51.000066
Margaret
clojurians
clojure
that ensures the parts of the record are all in sync
2017-12-27T21:24:59.000095
Margaret
clojurians
clojure
oh and then i’d have some fn `get-price` (or maybe use `conform`) and it’d get me the price that was cached if it was fresh enough
2017-12-27T21:25:35.000122
Linn
clojurians
clojure
or go get a new one
2017-12-27T21:25:39.000031
Linn
clojurians
clojure
also, you could use a TTL cache (clojure core.cache provides this) and retrieve the price from the cache
2017-12-27T21:25:44.000040
Margaret
clojurians
clojure
if the record is created recently enough, it's returned, otherwise queried
2017-12-27T21:25:55.000106
Margaret
clojurians
clojure
ooh
2017-12-27T21:26:31.000014
Linn
clojurians
clojure
the nice thing with core.cache is that it doesn't force a specific storage - it just takes a hash-map and returns a new one, and you can put this in a local that propagates via recur, or put it in a ref, or an atom, or even a proper db if you serialize it right - it should just work
2017-12-27T21:26:56.000047
Margaret
clojurians
clojure
(as long as you always use the new hash-map it returns of course)
2017-12-27T21:27:13.000200
Margaret
clojurians
clojure
that’s super handy
2017-12-27T21:27:30.000065
Linn
clojurians
clojure
<https://github.com/clojure/core.cache>
2017-12-27T21:27:46.000079
Margaret
clojurians
clojure
because yeah i’m making a lot of wasteful API calls
2017-12-27T21:27:47.000084
Linn
clojurians
clojure
<https://docs.oracle.com/javase/7/docs/api/java/io/DataInputStream.html#readFully(byte[])> &lt;-- where is this readFully contract definedd ?
2017-12-27T21:27:59.000005
Berry
clojurians
clojure
i basically just hacked together some bullshit that worked for now with promises/futures
2017-12-27T21:28:08.000151
Linn
clojurians
clojure
I'm trying to read 10k bytes from a file, and I don't wnat to loop; I want to make on3 call and have java read it for me
2017-12-27T21:28:11.000007
Berry
clojurians
clojure
I use core.cache in front of mongo documents encoded via transit
2017-12-27T21:28:13.000111
Margaret
clojurians
clojure
now i’m trying to go back and use core.async channels to model the continuous updates
2017-12-27T21:28:24.000146
Linn
clojurians
clojure
the core.cache protocols do all the cache ttl logic, and transit handles the serialization, and mongo the storage
2017-12-27T21:28:34.000051
Margaret
clojurians
clojure
regarding mongo - I wouldn't necessarily recommend for a new project, it was inherited as part of the team expertise if that makes any sense
2017-12-27T21:30:25.000098
Margaret
clojurians
clojure
yeah i haven’t even begun to think about a persistence layer
2017-12-27T21:30:40.000150
Linn
clojurians
clojure
i’m doing like super elementary algorithmic trading
2017-12-27T21:30:50.000210
Linn
clojurians
clojure
mostly because i want to stop having to wake up at like 4am to catch market opens
2017-12-27T21:31:03.000156
Linn
clojurians
clojure
so far clojure’s concurrency stuff has been as good as i expected for this
2017-12-27T21:31:36.000030
Linn
clojurians
clojure
yeah, core.cache also does simple in-memory cache with ttl which is what I'm sure you actually want - for those mongo caches I'm measuring the ttl in days not minutes
2017-12-27T21:31:38.000003
Margaret
clojurians
clojure
haha, yup
2017-12-27T21:31:45.000097
Linn
clojurians
clojure
it’d be like seconds
2017-12-27T21:31:48.000098
Linn
clojurians
clojure
but there are some other queries that i might want to store for longer
2017-12-27T21:32:10.000059
Linn
clojurians
clojure
like, price data, seconds, but the actual existence of the contracts i’m interested in
2017-12-27T21:32:26.000088
Linn
clojurians
clojure
that can be cached for a long time
2017-12-27T21:32:36.000037
Linn
clojurians
clojure
also the simplest solution would be to use an atom for your cache, but if you start to hit contention slowdowns you could use multiple refs instead of an atom with multiple keys in it
2017-12-27T21:32:36.000083
Margaret
clojurians
clojure
i am also thinking like
2017-12-27T21:32:53.000087
Linn
clojurians
clojure
oh, instead of handing out refs like candy and then trying to update them in place
2017-12-27T21:33:10.000027
Linn
clojurians
clojure
i guess i should make a function that is like `get-contract` and then have that access the cache or synthesize a new contract info object
2017-12-27T21:33:39.000003
Linn
clojurians
clojure
using lots of refs does work (and performs better under heavy write load) it's just a more complex design than a hash-map in an atom with a key for each "thing"
2017-12-27T21:33:58.000020
Margaret
clojurians
clojure
i have been thinking it would be kind of neat to have an agent for every contract i’m keeping track of
2017-12-27T21:34:01.000049
Linn
clojurians
clojure
and then just deref the contract for the current state
2017-12-27T21:34:22.000033
Linn
clojurians
clojure
but maybe using an explicit cache would be much better
2017-12-27T21:34:39.000076
Linn
clojurians
clojure
oh, that’s what you were saying, though
2017-12-27T21:35:02.000023
Linn
clojurians
clojure
a ref for every cache entry?
2017-12-27T21:35:07.000149
Linn
clojurians
clojure
caching logic is notoriously tricky to get right, and core.cache helps a lot with that; I was surprised - I did a big cache with a lot of features built on core.cache and it worked without a hitch after the trivial data bugs were fixed
2017-12-27T21:35:34.000035
Margaret
clojurians
clojure
<@Linn> I'm trying to work out what this would require - it's a lot simpler to add keys on demand to an atom, but you could also hypothetically manage multiple refs but then you have the question of what tracks these on-demand refs and then I'm like "refs inside an atom" and no that is insanity
2017-12-27T21:37:09.000089
Margaret
clojurians
clojure
lol
2017-12-27T21:37:21.000064
Linn
clojurians
clojure
that’s where i went too
2017-12-27T21:37:26.000155
Linn
clojurians
clojure
it was like aaaaa
2017-12-27T21:37:29.000008
Linn
clojurians
clojure
because the idea of a record that magically updates itself
2017-12-27T21:37:45.000019
Linn
clojurians
clojure
i guess for right now, it’s not a big deal, i can just have a single atom with a map
2017-12-27T21:38:19.000061
Linn
clojurians
clojure
if you know it's always 10k bytes or less why not pass a 10k byte-array to the read method?
2017-12-27T21:38:39.000061
Margaret
clojurians
clojure
here's DataInput readFully <https://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#readFully(byte[])>
2017-12-27T21:40:03.000070
Margaret
clojurians
clojure
it's saying "look at the method foo on class bar" - it's just phrasing it kind of weird
2017-12-27T21:40:20.000127
Margaret
clojurians
clojure
wow, that caching lib is great, just implementing a really naive caching layer in my calls was enough to massively reduce the number of API roundtrips
2017-12-27T22:22:05.000145
Linn
clojurians
clojure
is there a way of writing call (.readInt ...) on this data-input-stream 10 times that is better than loop-recur ? (note that .readInt changes the 'pointer' in the file buffer, so we need to be careful with regards to laziness
2017-12-28T03:13:29.000125
Berry
clojurians
clojure
Hi everyone. I’m using a `chestnut` template and I have this simple route ``` (defn home-routes [endpoint] (routes (POST "/api/get-name" _ get-name) (resources "/") (not-found "&lt;h1&gt;Page hello&lt;/h1&gt;"))) ``` whenever I try to post to this route from FE (cljs / re-frame), it sends `OPTIONS` type request first and it fails straight away with `404` and then the `POST` is not being sent afterwards. When I manually add ``` (OPTIONS "/api/get-name" _ get-name) (POST "/api/get-name" _ get-name)``` it returns with `200` but then `POST` is not being sent afterwards
2017-12-28T06:20:23.000135
Tameka
clojurians
clojure
Your browser is sending OPTION request to make sure the planned POST request is acceptable. This may help you understand option request: <https://developer.mozilla.org/de/docs/Web/HTTP/Methods/OPTIONS> Check the network/console log of your browser to see which headers/methods/origins in the options request are asked for and then make sure your OPTIONS endpoint in your backend sends a valid option response. I think for most cases there are ring-middlewares to do this
2017-12-28T07:53:25.000033
Lucretia
clojurians
clojure
Hi all. I have a spec question. I think I know the answer, but I want to confirm. If I'm spec'ing a map, and the keyword is :fooBar, then the spec must have the same name, correct? Actually, it would be namespaces, so ::fooBar, correct? I need to know if I can remap a keyword to a spec with a different name, or if that defeats the purpose of readability.
2017-12-28T10:44:50.000240
Ira
clojurians
clojure
you can spec un-namespaced keys with :req-un and :opt-un <https://clojure.org/guides/spec>
2017-12-28T10:50:11.000072
Margaret
clojurians
clojure
but there are good reasons to use namespaced keys
2017-12-28T10:50:33.000226
Margaret
clojurians
clojure
Well, it’s not actually the namespacing. I’m fine with that part. I’m asking if I could have a `::foo-bar` spec for the `:fooBar` key
2017-12-28T10:52:55.000059
Ira
clojurians
clojure
Or, suppose you have 2 different API returns in the same domain, but that have the same keyword. Such as `:results` but where the spec for each of those is different.
2017-12-28T11:05:12.000055
Ira