workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
clojurians | clojure | definitely not a terminal thing | 2017-10-26T17:03:45.000149 | Margaret |
clojurians | clojure | ok | 2017-10-26T17:03:52.000366 | Shaunda |
clojurians | clojure | it’s a known thing in reply | 2017-10-26T17:03:56.000462 | Margaret |
clojurians | clojure | oh really? | 2017-10-26T17:04:24.000650 | Shaunda |
clojurians | clojure | (unless coincidentally something else is causing the same error) | 2017-10-26T17:04:33.000226 | Margaret |
clojurians | clojure | is it this issue? <https://github.com/trptcolin/reply/issues/168> | 2017-10-26T17:05:22.000288 | Shaunda |
clojurians | clojure | I’m not certain, but it certainly looks like the issue, yes | 2017-10-26T17:06:02.000178 | Margaret |
clojurians | clojure | and for anyone following along it looks like the real issue isn't in reply, but actually one more dependency level down in sjacket: <https://github.com/cgrand/sjacket/issues/25> | 2017-10-26T17:14:47.000409 | Shaunda |
clojurians | clojure | Is there a way to simplify:
```
(and (map? x)
(get x [:rewrite :on-click]))
```
There is no guarantee that x is a map. | 2017-10-26T18:15:52.000087 | Berry |
clojurians | clojure | so that means you want false instead of nil? | 2017-10-26T18:24:38.000395 | Margaret |
clojurians | clojure | ```user=> (get "pretty much anything" [:rewrite :on-click])
nil``` | 2017-10-26T18:31:37.000175 | Margaret |
clojurians | clojure | I've run into an interesting bug at work with an Apache Storm topology in Clojure.
One of the bolts takes, as a :param, some seed data from a dB. This data, consisting of two queries, is done inside a pvalues expression, returning a map with two key/value pairs - one for each query essentially.
Now, pvalues is implemented as a future if I'm not mistaken, and as such will cache its value for subsequent derefencing. The behavior I'm seeing is that upon a Storm restart we're getting old, stale data from this pvalues. It seems to be under circumstances when the topology is restarted round-robin with individual nodes restarted in a rolling fashion (hence the topology is never 100% off). So, could the pvalues 'state' be passed from a supervisor to another one?
Curious if anyone else has run into a similar issue. We have a work-around, consisting of a complete take down of Storm and then a restart but... I guess that's SOP :slightly_smiling_face: | 2017-10-26T18:39:16.000140 | Bibi |
clojurians | clojure | it uses zookeeper, zookeeper is for sharing small values between processes for IPC | 2017-10-26T18:48:48.000062 | Margaret |
clojurians | clojure | typically one will create “ephemeral nodes” that disappear if nobody is using them | 2017-10-26T18:49:08.000038 | Margaret |
clojurians | clojure | there’s a program called `zkCli` that lets you explore the data in zookeeper as if it were a file system | 2017-10-26T18:49:44.000213 | Margaret |
clojurians | clojure | <https://www.tutorialspoint.com/apache_storm/apache_storm_cluster_architecture.htm> | 2017-10-26T18:50:14.000042 | Margaret |
clojurians | clojure | <@Margaret> thanks, I'll check that out. It's easy enough to reproduce :slightly_smiling_face: | 2017-10-26T18:51:21.000177 | Bibi |
clojurians | clojure | I wouldn’t be surprised if there was a command of workflow to clean-slate the Storm state | 2017-10-26T18:54:59.000380 | Margaret |
clojurians | clojure | can I print the address of a variable, or something which I can easily use to compare it with another instance later? | 2017-10-26T19:31:09.000279 | Dannette |
clojurians | clojure | <@Dannette> if you var quote an argument, it’s the container and not the thing in the container. This only works for vars (usually owned by namespaces) and does not work for local bindings, which are immutable | 2017-10-26T19:42:49.000301 | Margaret |
clojurians | clojure | `+` is the function bound to `clojure.core/+`, `#'+` is the var that currently holds that value | 2017-10-26T19:45:45.000006 | Margaret |
clojurians | clojure | a convenient thing is that if you call a var, the var looks up it’s own contents and calls that for you; for values that aren’t being called you can use `deref`, the shorthand `@`, or `var-get` | 2017-10-26T19:47:02.000350 | Margaret |
clojurians | clojure | you can also look up a var by symbol via `resolve`, or look it up using the bindings set up in a specific namespace with `ns-resolve` - a tricky point is that ns-resolve doesn’t look up a var in a specific ns, it looks up a var using the rules that would be used in that ns, which includes bindings created by require, refer, use, etc. | 2017-10-26T19:49:11.000137 | Margaret |
clojurians | clojure | thanks! | 2017-10-26T19:52:29.000009 | Dannette |
clojurians | clojure | any sha1/sha256 lib recommendation? | 2017-10-26T19:53:07.000277 | Geneva |
clojurians | clojure | it’s like 3 lines of interop, max, you don’t need a lib | 2017-10-26T19:53:25.000130 | Margaret |
clojurians | clojure | ya, this is our sha1 framework:
```
(DigestUtils/sha1Hex
(str "classic_"
pcoll-name
"_"
(pr-str key-obj)))
``` | 2017-10-26T19:54:22.000086 | Aldo |
clojurians | clojure | <https://gist.github.com/kubek2k/8446062> | 2017-10-26T19:54:22.000192 | Margaret |
clojurians | clojure | I see, thanks | 2017-10-26T19:54:47.000154 | Geneva |
clojurians | clojure | (assuming you're in a project that already pulls in apache commons for one of the million reasons that you might) | 2017-10-26T19:55:01.000303 | Aldo |
clojurians | clojure | No, I don’t use apache common | 2017-10-26T19:55:16.000077 | Geneva |
clojurians | clojure | well, that would be an option! | 2017-10-26T19:55:25.000309 | Aldo |
clojurians | clojure | yeah - that github gist works if you aren’t using commons, but most apps probably have commons already | 2017-10-26T19:55:27.000080 | Margaret |
clojurians | clojure | it has loooots of really useful stuff if you don't care about jar size, and it's well maintained | 2017-10-26T19:55:47.000085 | Aldo |
clojurians | clojure | Hello, How do I write a function/macro where I can call another function (not mine) with a quoted structure as an argument. For example:
```
(another-fun '[:someconfig :val :anotherkey :constkey :myvalue :dynamicvalue])
```
Where I get the value for `:myvalue` through some var. I have to construct this quoted expression with most of them as is, but one value evaluated. | 2017-10-26T22:46:37.000045 | Ray |
clojurians | clojure | I tried something like:
```
(defn my-fn [mval] (another-fun `[:someconfig :val :anotherkey :constkey :myvalue ~mval]))
```
but the syntax quote qualifies those keywords! | 2017-10-26T22:51:39.000174 | Ray |
clojurians | clojure | <@Ray> Why does `another-fun` need a _quoted_ value and not just a regular value? | 2017-10-26T22:53:39.000106 | Daniell |
clojurians | clojure | <@Daniell> it is what the function takes as argument | 2017-10-26T22:54:27.000121 | Ray |
clojurians | clojure | Are you _sure_? | 2017-10-26T22:54:33.000130 | Daniell |
clojurians | clojure | A quoted vector evaluates to just the vector so this ought to work: ```(defn my-fn [mval] (another-fun [:someconfig :val :anotherkey :constkey :myvalue mval]))``` | 2017-10-26T22:55:06.000056 | Daniell |
clojurians | clojure | Unless `another-fun` is doing something _very weird and non-idiomatic_...? | 2017-10-26T22:55:34.000005 | Daniell |
clojurians | clojure | <@Daniell> hmm, I never thought of checking without the quotes.. I will try it and see how it goes | 2017-10-26T22:57:02.000051 | Ray |
clojurians | clojure | ```boot.user=> (defn another-fun [v] (reduce + 0 v))
#'boot.user/another-fun
boot.user=> (another-fun [1 2 3 4])
10
boot.user=> (another-fun '[1 2 3 4])
10
boot.user=> (defn my-fun [my-val] (another-fun [1 2 3 my-val]))
#'boot.user/my-fun
boot.user=> (my-fun 4)
10
boot.user=> (my-fun '4)
10
``` | 2017-10-26T22:58:40.000074 | Daniell |
clojurians | clojure | See how `'4` evaluates to just `4` and how quoting the vector (in the second call) makes no difference. | 2017-10-26T22:59:27.000117 | Daniell |
clojurians | clojure | On the other hand, you _do_ need a quote for a _list_ but you can construct it dynamically with `list`: ```boot.user=> (another-fun (1 2 3 4))
java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
boot.user=> (another-fun '(1 2 3 4))
10
boot.user=> (defn my-fun [my-val] (another-fun (list 1 2 3 my-val)))
#'boot.user/my-fun
boot.user=> (my-fun 4)
10
boot.user=> (my-fun '4)
10
``` | 2017-10-26T23:01:33.000007 | Daniell |
clojurians | clojure | Hope that helps <@Ray> | 2017-10-26T23:01:54.000186 | Daniell |
clojurians | clojure | <@Daniell> actually using it directly did not work. let me try to write an actual similar function. I think I may be approaching the problem in wrong way! | 2017-10-26T23:03:50.000092 | Ray |
clojurians | clojure | I am writing a small function which can query datomic db for entities using various attributes | 2017-10-26T23:05:21.000103 | Ray |
clojurians | clojure | ```
(defn find-user-by[conn attrkw value]
(let [user (d/q '[:find ?e
:in $ ?attr
:where [?e attrkw ?attr]]
(d/db conn) value)]
(touch conn user)))
``` | 2017-10-26T23:05:23.000169 | Ray |
clojurians | clojure | <@Daniell> my function looks something like above | 2017-10-26T23:05:59.000045 | Ray |
clojurians | clojure | Instead of writing a different function for querying user entity using `:user/first-name` or `:email` etc, I thought of writing one and passing `:user/first-name` dynamically to the datomic `q` function | 2017-10-26T23:07:25.000086 | Ray |
clojurians | clojure | Ah, and you need the `?e` to not resolve, right? | 2017-10-26T23:08:35.000042 | Daniell |
clojurians | clojure | yes | 2017-10-26T23:08:42.000136 | Ray |
clojurians | clojure | ```(defn find-user-by[conn attrkw value]
(let [user (d/q [:find '?e
:in '$ '?attr
:where ['?e attrkw '?attr]]
(d/db conn) value)]
(touch conn user)))``` | 2017-10-26T23:09:00.000175 | Daniell |
clojurians | clojure | Quote the symbols you don't want evaluated instead of the whole vector. | 2017-10-26T23:09:18.000209 | Daniell |
clojurians | clojure | Thanks let me try it :slightly_smiling_face: | 2017-10-26T23:09:56.000045 | Ray |
clojurians | clojure | <@Daniell> Thanks a lot, it worked! I was trying it wrong :stuck_out_tongue: Instead of quoting the ones that should be quoted, I was tyring to quote the whole thing and unquote only the attrkw | 2017-10-26T23:11:48.000021 | Ray |
clojurians | clojure | If it gets too frustrating, to keep quoting bits of it, remember that you can do stuff like ```
(conj '[:find ?e
:in $ ?attr
:where] (assoc '[?e _ ?attr] 1 attrkw))``` | 2017-10-26T23:12:48.000116 | Daniell |
clojurians | clojure | (a vector is associative on its indices so you can just swap in a new value for the `_`) | 2017-10-26T23:14:05.000096 | Daniell |
clojurians | clojure | Awesome, I was wondering if I can construct expressions like this. I was not sure if it works when I need everything quoted | 2017-10-26T23:15:21.000112 | Ray |
clojurians | clojure | "It's just data" :slightly_smiling_face: | 2017-10-26T23:15:45.000131 | Daniell |
clojurians | clojure | Thanks again <@Daniell> I am calling it a day now | 2017-10-26T23:16:46.000009 | Ray |
clojurians | clojure | ```boot.user=> (let [query '[:find ?e
#_=> :in $ ?attr
#_=> :where [?e _ ?attr]]]
#_=> (assoc-in query [(dec (count query)) 1] :user/name))
[:find ?e :in $ ?attr :where [?e :user/name ?attr]]
``` ^ <@Ray> | 2017-10-26T23:17:10.000067 | Daniell |
clojurians | clojure | (although that's a bit horrible really) | 2017-10-26T23:17:23.000117 | Daniell |
clojurians | clojure | Are there any known issues with `clojure.string/replace` acting funny? | 2017-10-27T00:21:57.000165 | Isabelle |
clojurians | clojure | You'll need to be a bit more specific, otherwise the answer will just be "no"... | 2017-10-27T00:24:03.000095 | Daniell |
clojurians | clojure | Do you have an example of it "acting funny" <@Isabelle>? | 2017-10-27T00:24:40.000068 | Daniell |
clojurians | clojure | Sorry.... shot in the dark. Have gotten some null pointer exceptions randomly when I'm definitely just feeding it a string and the function is working just fine in the repl. `(clojure.string/replace "123-456-asdf" #"[^0-9]+" "")` | 2017-10-27T00:28:28.000029 | Isabelle |
clojurians | clojure | I think you'll only get NPEs from it if you pass it a `nil` as the string argument... | 2017-10-27T00:32:16.000033 | Daniell |
clojurians | clojure | Thanks <@Daniell> I just can't seem to replicate that so thought i'd check in the remote chance there was some known issue. There never is but it makes me hopeful none the less. | 2017-10-27T00:50:22.000137 | Isabelle |
clojurians | clojure | <@Isabelle> I bet if you add an assert on the value you're passing to `replace` you'll get an assertion failure | 2017-10-27T00:51:36.000074 | Daniell |
clojurians | clojure | If you're on Clojure 1.9, you could `spec` (with `s/fdef`) the function that calls `replace` and `instrument` it and see if you can trap the `nil` value going in... | 2017-10-27T00:52:46.000178 | Daniell |
clojurians | clojure | Yes, thx! think I will try that | 2017-10-27T00:53:48.000137 | Isabelle |
clojurians | clojure | i see clojure.java.time has used ztellman's import vars macro from potemkin so you don't have to remember all of the sub namespaces | 2017-10-27T02:03:09.000036 | Willow |
clojurians | clojure | also a single segment namespace, terrible | 2017-10-27T02:05:24.000187 | Rebeca |
clojurians | clojure | why don't you like that. i haven't run into any pain from that so i'm wondering what to be on the lookout for | 2017-10-27T02:06:17.000162 | Willow |
clojurians | clojure | alex had a nice comment on a github issue I saw recently, but I don't recall were | 2017-10-27T02:07:19.000088 | Rebeca |
clojurians | clojure | ah i'd like to see it. he's a thoughtful commenter | 2017-10-27T02:08:06.000055 | Willow |
clojurians | clojure | it is bad technically because then the aot compiled clojure code would end up in the default package, and it is unneighborly because you are inviting name clashes | 2017-10-27T02:08:24.000130 | Rebeca |
clojurians | clojure | <https://github.com/bbatsov/clojure-style-guide/pull/100> | 2017-10-27T02:10:32.000052 | Rebeca |
clojurians | clojure | unsurpisingly, the people with "contributor" and "owner" badges for that style guide are in the wrong | 2017-10-27T02:12:33.000017 | Rebeca |
clojurians | clojure | awesome. thanks for digging it up | 2017-10-27T02:12:42.000051 | Willow |
clojurians | clojure | was it you that sent the PR with the bruce lee replacement? | 2017-10-27T02:13:16.000250 | Willow |
clojurians | clojure | yes | 2017-10-27T02:13:22.000048 | Rebeca |
clojurians | clojure | haha that was great. oh well. i just learned something from the discussion there | 2017-10-27T02:13:59.000072 | Willow |
clojurians | clojure | thanks for bringing it up | 2017-10-27T02:14:06.000102 | Willow |
clojurians | clojure | Hi, I've got some core.logic question, i've posted it in core.logic chan but no responses, so I'm trying here:
i'm doing something wrong here but cannot find what:
```
(defn zipwitho [rel l1 l2 l3]
(conde
[(== () l1) (== () l2) (== () l3) l/succeed]
[(fresh [fl1 rl1 fl2 rl2 fl3 rl3]
(l/conso fl1 rl1 l1)
(l/conso fl2 rl2 l2)
(l/conso fl3 rl3 l3)
(rel fl1 fl2 fl3)
(zipwitho rel rl1 rl2 rl3))]))
(run 1000 [q]
(fresh [a b]
(== q [a b])
(zipwitho
(fn [x y z]
(l/all
(fd/in x y z (fd/interval 10))
(fd/+ x y z)))
a
b
[10 10])))
;=>
([(0 0) (10 10)]
[(1 0) (9 10)]
[(2 0) (8 10)]
[(3 0) (7 10)]
[(4 0) (6 10)]
[(5 0) (5 10)]
[(6 0) (4 10)]
[(7 0) (3 10)]
[(8 0) (2 10)]
[(9 0) (1 10)]
[(10 0) (0 10)])
``` | 2017-10-27T03:53:25.000134 | Isabell |
clojurians | clojure | with java interop when instantiating a templated java class is it necessary to pass the template type? | 2017-10-27T09:43:10.000400 | Dannette |
clojurians | clojure | no | 2017-10-27T09:43:41.000559 | Sonny |
clojurians | clojure | Java erases generics at the JVM level to raw collection types and that’s what you’re using via Clojure’s java interop | 2017-10-27T09:44:08.000094 | Sonny |
clojurians | clojure | so I end up with the following error then which I cannot interpret:
```
java.lang.NoSuchMethodError: com.badlogic.gdx.graphics.g2d.Animation.getKeyFrame(FZ)Lcom/badlogic/gdx/graphics/g2d/TextureRegion;
at play_clj.g2d$animation__GT_texture.invoke(g2d.clj:257)
```
With libgdx 1.9.4 this code worked. With 1.9.5 change it no longer does and the API change was:
> - API Change: g2d.Animation is now generic so it can support Drawables, PolygonRegions, NinePatches, etc. To fix existing code, specify the TextureRegion type in animation declarations (and instantiations in Java 6), i.e. Animation<TextureRegion> myAnimation = new Animation<TextureRegion>(...);
That API I believe changed from `TextureRegion getKeyFrame(float x, b boolean)` to `T getKeyFrame(float x, b boolean)` so its not clear what is causing this error. | 2017-10-27T09:45:29.000417 | Dannette |
clojurians | clojure | why "unsurprisingly"? Generally I've found the style guide to be a good rough description of Clojure idiom. | 2017-10-27T09:45:51.000110 | Milissa |
clojurians | clojure | that generic is on the return type, which is not even used when selecting an arity for interop (that’s all on the arguments) | 2017-10-27T10:06:46.000316 | Sonny |
clojurians | clojure | what is the call you’re making? | 2017-10-27T10:07:03.000183 | Sonny |
clojurians | clojure | <https://github.com/oakes/play-clj/blob/master/src/play_clj/g2d.clj#L257> | 2017-10-27T10:07:26.000227 | Dannette |
clojurians | clojure | I filed the stack trace here if that helps.
<https://github.com/oakes/play-clj/issues/112> | 2017-10-27T10:09:17.000211 | Dannette |
clojurians | clojure | I don’t understand why anything there is different or shouldn’t work | 2017-10-27T10:13:42.000479 | Sonny |
clojurians | clojure | well the difference is that the signature is now `getKeyFramw(FZ)Ljava/lang/Object` | 2017-10-27T10:14:27.000045 | Kareen |
clojurians | clojure | so AOT code will not link with new versions | 2017-10-27T10:14:35.000597 | Kareen |
clojurians | clojure | yeah, it doesn’t make sense to me why it’s looking for the old one - didn’t look like play-clj was aot’ed | 2017-10-27T10:14:51.000151 | Sonny |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.