workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
clojurians | clojure | break it apart at the seams where you'd test (the initial OAuth call, the second call) | 2017-11-14T17:50:43.000024 | Guillermo |
clojurians | clojure | I will often rewrite code with multiple exits as explicit cps | 2017-11-14T17:50:46.000171 | Rebeca |
clojurians | clojure | Explicit cps? | 2017-11-14T17:51:02.000051 | Earlie |
clojurians | clojure | often you can have control flow diverge down two paths, and then you need to join the control flow | 2017-11-14T17:51:39.000234 | Rebeca |
clojurians | clojure | that control flow join is the divergent control flow having the same continuation | 2017-11-14T17:52:10.000150 | Rebeca |
clojurians | clojure | so you just create a function that represents all actions after the join point, and pass it in to each branch | 2017-11-14T17:52:45.000254 | Rebeca |
clojurians | clojure | Oh, I'm following now. So you'd have a default-response defined at the beginning which calls the redirect to /login? | 2017-11-14T17:53:26.000288 | Earlie |
clojurians | clojure | sure, something like that | 2017-11-14T17:54:21.000536 | Rebeca |
clojurians | clojure | That makes sense.
Is this a specifically defined pattern? Link? | 2017-11-14T17:54:45.000008 | Earlie |
clojurians | clojure | I dunno, it is just sort of I think of code after fiddling with compilers for a while | 2017-11-14T17:55:57.000314 | Rebeca |
clojurians | clojure | I think this is what I was looking for: <https://en.wikipedia.org/wiki/Continuation-passing_style> | 2017-11-14T17:56:20.000182 | Earlie |
clojurians | clojure | oh yeah, cps is a thing, and has lots of applications, a lot of which are sort of tangential to the relatively simple "hey, I have this repeated bit of code for different control flow branches, why not make it a function and reuse it on both branches" | 2017-11-14T17:58:25.000014 | Rebeca |
clojurians | clojure | :thumbsup: Thanks | 2017-11-14T17:58:49.000458 | Earlie |
clojurians | clojure | Hi!
I’m trying to receive an AWS SNS message in pedestal but I’m facing a small problem. When pedestal receives a message with content-type application/json it automatically convert the body to keywords.
But aws sns sends its message with content-type text/plain and pedestal does not convert the message so I can extract the data I need.
Is there a way to convert the entire message? I’m trying to create an interceptor to convert the requests but It’s not working problem:
```(defn- parse-string-to-map-keys
[string-to-convert]
(walk/keywordize-keys string-to-convert))```
```(defn- parse-stream-to-map-keys
[stream-to-convert]
(json/read-str (slurp (<http://clojure.java.io/reader|clojure.java.io/reader> stream-to-convert)) :key-fn keyword))```
```(def parse-sns-message-to-json
(interceptor/interceptor
{:name ::parse-sns-message-to-json
:enter
(fn [{:keys [request] :as context}]
(let [ headers (try
(parse-string-to-map-keys (:headers request))
(catch Exception _))
body (try
(parse-stream-to-map-keys (:body request))
(catch Exception _))]
(if (and headers body)
(do
(assoc context :request (-> request
(assoc :headers headers)
(assoc :json-params body))))
(-> context
terminate))))}))``` | 2017-11-14T18:22:48.000291 | Audie |
clojurians | clojure | I’m using ```[clojure.data.json :as json]``` as well | 2017-11-14T18:23:09.000110 | Audie |
clojurians | clojure | The body of the message stays like this:
```:body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x9344f6 "HttpInputOverHTTP@9344f6[c=1804,q=0,[0]=null,s=EOF]"], :scheme :http, :request-method :post}``` | 2017-11-14T18:23:55.000017 | Audie |
clojurians | clojure | can you make an interceptor that just changes the content-type for sns messages? | 2017-11-14T18:23:56.000348 | Rebeca |
clojurians | clojure | I could try this, but I don’t know the order of the functions
would pedestal try to convert the message before or after my interceptor? | 2017-11-14T18:25:29.000195 | Audie |
clojurians | clojure | I dunno, I've never used pedestal interceptors, my understanding is they form something like a pipeline, so there must be some way to influence the order things flow through the pipeline | 2017-11-14T18:26:34.000246 | Rebeca |
clojurians | clojure | hm, I see
I’ll try to do what you’ve said
I’ll send the result in a minute | 2017-11-14T18:27:53.000089 | Audie |
clojurians | clojure | <http://pedestal.io/reference/default-interceptors#_modifying_the_default_stack> | 2017-11-14T18:27:58.000094 | Rebeca |
clojurians | clojure | Hey is it possible to use leiningen from the REPL instead of from the commandline? | 2017-11-15T00:49:51.000158 | Alix |
clojurians | clojure | <https://stackoverflow.com/questions/47309604/dynamic-variables-in-clojure-libraries> | 2017-11-15T09:13:13.000418 | Ernesto |
clojurians | clojure | guess i'll do the same next time i have questions, post them on SO and then link them here. as a newcomer it is very hard to find answers to some questions others might already had | 2017-11-15T09:19:26.000396 | Ahmad |
clojurians | clojure | <@Ahmad> Yes. SO is better in SEO and UX that slack logs. :wink: | 2017-11-15T09:23:11.000129 | Ernesto |
clojurians | clojure | that's what i had in mind | 2017-11-15T09:24:11.000407 | Ahmad |
clojurians | clojure | Is this a good pattern for libraries?
```
(def ^{:dynamic true} *var*)
(defn my-fn [{:keys [var]}]
(do-smth (or var *var*)))
``` | 2017-11-15T09:32:26.000532 | Ernesto |
clojurians | clojure | <@Ernesto> sometimes, such global variables might be useful. Say, cls-http stores default middlewares in such a global vector. And there is a macro `(with-middlewares...)` that substitutes them temporary with `binding` | 2017-11-15T09:49:05.000529 | Verna |
clojurians | clojure | but as long as you can avoid using them, please do. | 2017-11-15T09:49:45.000128 | Verna |
clojurians | clojure | <@Verna> Thank you. | 2017-11-15T10:00:37.000039 | Ernesto |
clojurians | clojure | Nice answer from Joost Diepenmaat on SO: “In my experience, having dynamic arguments /almost/ always causes more trouble than it saves down the line. You need a pretty compelling reason to have them and in this case I would definitely just make `*var*` a non-dynamic `default-var`. Note that clojure.java.jdbc (like the example in the docs) used to have a dynamic default db argument but that was removed ages ago. | 2017-11-15T10:50:36.000270 | Ernesto |
clojurians | clojure | Does anyone here have some strong thoughts on what a simultanuous `put` and `take` on the same channel (via `alts`) should do? In IRC someone brought up the following:
```
(let [c (async/chan)]
(async/alts!! [c [c 42]]))
```
First thought is deadlock, but it actually executes both operations, and returns either `[42 c]` (the result of the `take`) or `[true c]` (the result of the `put`). This feels wrong, as the documentation clearly states it should execute at most one operation. | 2017-11-15T11:11:00.000114 | Basil |
clojurians | clojure | yes, you can for example launch a clojure repl from the leiningen jar, or include leiningen as a dep of your project. But if you aren’t making a tool that is meant to be used as a leiningen plugin or extension you might be on the wrong track here. leiningen is meant to be a build tool, ideally it and its libraries don’t exist on a production server | 2017-11-15T11:59:44.000325 | Margaret |
clojurians | clojure | <@Basil> This is a weird one -- I'm not saying it's not surprising, but let me offer an explanation of what's going on:
alts will attempt its requested ops in a random order. For each op it checks: Did it work immediately? If so return, if not try the next one.
In this specific example, one of the ops is selected and attempted (doesn't matter which), and because the channel is unbuffered, that op is enqueued (aka doesn't succeed immediately). alts moves on to the next/other op, and tries it. This op will succeed immediately because the originally attempted op is the complement. Technically, alts is upholding its contract of exactly one op succeeding, _but it's the succeeding op that unblocks and runs the other op, not alts itself_. | 2017-11-15T12:04:00.000483 | Guillermo |
clojurians | clojure | (I'm one of the committers to that project.) | 2017-11-15T12:04:44.000225 | Guillermo |
clojurians | clojure | Just to put it on the record, it would be unusual to see this puzzler in the wild (as well as bidirectional usage of a channel within the same function) | 2017-11-15T12:09:39.000455 | Guillermo |
clojurians | clojure | (I lament that Slack history disappears) | 2017-11-15T12:18:19.000297 | Guillermo |
clojurians | clojure | It does not, it just gets hidden since no one pays for this slack organization | 2017-11-15T12:43:03.000166 | Cecilia |
clojurians | clojure | The second someone pays the whole history will be there | 2017-11-15T12:43:24.000592 | Cecilia |
clojurians | clojure | Feel free to discuss that in <#C0CB40N8K|community-development> (but we have 11,000 members and no one is going to fund this at $57,000 per month). | 2017-11-15T12:55:06.000314 | Daniell |
clojurians | clojure | "effectively disappears" :smiley: | 2017-11-15T12:55:40.000726 | Guillermo |
clojurians | clojure | isn’t there some off-site archive? I think I’ve found things on it via google before | 2017-11-15T13:24:49.000281 | Shamika |
clojurians | clojure | it's discontinuous | 2017-11-15T13:26:20.000190 | Guillermo |
clojurians | clojure | you can get around it to some degree if you use the irc gate. have an irc bot connected constantly and have it save logs. | 2017-11-15T13:32:52.000132 | Eufemia |
clojurians | clojure | doesnt do well with the advent of threads though since those messages appear inline | 2017-11-15T13:33:33.000722 | Eufemia |
clojurians | clojure | What does Rich mean when Lisp is ‘tangible’. I’ve looked up the word tangible and I found ‘substantially real’. which doesn’t really make it any clearer. | 2017-11-15T14:07:54.000405 | Johana |
clojurians | clojure | <https://clojurians-log.clojureverse.org> | 2017-11-15T14:11:36.000001 | Brande |
clojurians | clojure | Like something you can touch, feel, mold | 2017-11-15T14:11:57.000545 | Marnie |
clojurians | clojure | data is directly readable without going through an interface, your runtime state is always manipulable, even your tooling is often changeable on the fly | 2017-11-15T14:12:46.000462 | Sonny |
clojurians | clojure | or at least that’s what it means to me | 2017-11-15T14:13:20.000007 | Sonny |
clojurians | clojure | hmm, doesn't seem up to date though, something wrong with logbot | 2017-11-15T14:13:41.000647 | Brande |
clojurians | clojure | yeah it's discontinuous | 2017-11-15T14:14:48.000523 | Guillermo |
clojurians | clojure | I’d add to that that the things that make up your program state are concrete and explicit (reified as data), not ephemeral “fictions” that are enforced by a compiler but missing in the runtime data itself | 2017-11-15T14:14:49.000622 | Margaret |
clojurians | clojure | ah that makes sense yes. when I’m programming in a more static / less interactive language, you can’t really play around with it, you’re not as close to the data. All you can do is watch the program unfold, unless you explicitly build hooks and monitoring into it | 2017-11-15T14:15:42.000211 | Johana |
clojurians | clojure | even just the fact that you can take an arbitrary piece of data, and say “what type is this?” or print it and expect a reasonable result | 2017-11-15T14:17:03.000797 | Margaret |
clojurians | clojure | right, thanks | 2017-11-15T14:17:36.000115 | Johana |
clojurians | clojure | :sadpanda: | 2017-11-15T14:17:39.000002 | Brande |
clojurians | clojure | For me “tangible” means a REPL that is the whole thing of what a REPL means, coupled with homoiconicity. | 2017-11-15T17:17:20.000353 | Peter |
clojurians | clojure | For a contrasting example with Python. Python occasionally spits out results in its REPL that’s homoiconic. Or almost homoiconic. I once implemented a bunch of classes’ `__repr__` magic functions with a string that was that type’s call to its constructor. This, when used in a REPL, made my Python custom *classes* behave in a homoiconic way. | 2017-11-15T17:20:15.000352 | Peter |
clojurians | clojure | But don’t be fooled. If python were made to be fully homoiconic _by default_ yet because of the language, you’d have to implement it without the parenthesis, not many would ever use this feature because macros would be so much harder to write because of the grammar rules being so complicated. | 2017-11-15T17:22:22.000157 | Peter |
clojurians | clojure | I think this is what Rich was getting at. | 2017-11-15T17:23:16.000571 | Peter |
clojurians | clojure | Does that make any sense? | 2017-11-15T17:23:24.000028 | Peter |
clojurians | clojure | how do i figure out out which version clojure has decided to call when doing interop. I'm trying to understand why I have to typehint the executor as `java.util.concurrent.ExecutorService` and the function as a `Callable`? What's the strategy used? i.e. is typehinting `Callable` not enough? | 2017-11-15T18:34:04.000179 | Danielle |
clojurians | clojure | it depends, if the compiler can figure out that you are invoking the method on an Executor service, type hinting Callable is enough | 2017-11-15T18:41:18.000307 | Rebeca |
clojurians | clojure | if you use interop to construct an ExecutorService and bind it to a local and use that, the compiler can figure it out, if you create it as a global (via def) then it can't, but you can type hint the var if you want | 2017-11-15T18:42:22.000020 | Rebeca |
clojurians | clojure | what's really weird is we were trying the same JVM version inside docker and outside docker and we got different results w/ the same code | 2017-11-15T18:42:24.000358 | Danielle |
clojurians | clojure | sure | 2017-11-15T18:42:31.000141 | Rebeca |
clojurians | clojure | I would not be surprised at that | 2017-11-15T18:43:07.000217 | Rebeca |
clojurians | clojure | mind if i ask you to pick you brain to explain why you aren't surprised? :wink: | 2017-11-15T18:43:28.000015 | Danielle |
clojurians | clojure | the executor issue is tricky because the class of the thing you are passing in, introduces more ambiguity instead of narrowing the scope | 2017-11-15T18:43:36.000332 | Rebeca |
clojurians | clojure | functions implement both Callable and Runnable, so it could be either | 2017-11-15T18:44:01.000163 | Rebeca |
clojurians | clojure | aye, I think what we're going to do to reduce ambiguity is to reify a Callable | 2017-11-15T18:44:49.000191 | Danielle |
clojurians | clojure | I think it is a little odd that you would get differences with just inside and outside of docker, but I am perfectly happy to hand wave that away as you also introducing some other difference | 2017-11-15T18:45:16.000193 | Rebeca |
clojurians | clojure | yeah it's really weird, we've gotten inconsistencies in other ways as well (trying tests in this order):
- ran our test using lein test (on 2.7.2) and the right version of `.submit` was used
- ran our test using lein test (on 2.8.1) and the the wrong version of `.submit` was used
- ran our test using lein test (on 2.7.2) and the the wrong version of `.submit` was used <-- freaky | 2017-11-15T18:46:42.000218 | Danielle |
clojurians | clojure | the version of lein has nothing to do with it | 2017-11-15T18:47:06.000310 | Rebeca |
clojurians | clojure | (well, has less to do with it then you might think) | 2017-11-15T18:47:20.000147 | Rebeca |
clojurians | clojure | the important thing would be the build of the jvm (version and os) and the clojure version (which lein version might effect) | 2017-11-15T18:47:51.000229 | Rebeca |
clojurians | clojure | e.g. if you are locally running on the jvm on osx, and comparing it to the jvm on linux in docker, many (not often noticeable) things will be different | 2017-11-15T18:49:10.000097 | Rebeca |
clojurians | clojure | fair | 2017-11-15T18:50:30.000156 | Danielle |
clojurians | clojure | <https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java#L47> | 2017-11-15T18:51:04.000280 | Rebeca |
clojurians | clojure | oo thanks for sharing haha | 2017-11-15T18:51:29.000114 | Danielle |
clojurians | clojure | I had a colleague years ago who spent a lot of time tracking down some flapping tests for a date parser that turned out to be due to the osx and the linux build of the same jdk treating dates that claim to be in dst, but being for a month that dst is in effect for differently | 2017-11-15T18:55:38.000231 | Rebeca |
clojurians | clojure | thanks, would I be able to avoid this ambiguiety by setting *warn-on-reflection* to `true`? | 2017-11-15T18:59:48.000071 | Danielle |
clojurians | clojure | yes | 2017-11-15T19:00:00.000333 | Rebeca |
clojurians | clojure | this will help me sleep better at night :smile: thanks for the explanations! | 2017-11-15T19:00:22.000072 | Danielle |
clojurians | clojure | Is there a way to show “simpler” java objects: | 2017-11-15T19:39:37.000210 | Ernesto |
clojurians | clojure | `[#object[edu.stanford.nlp.ling.TaggedWord 0x6a16b1ef "Short/JJ"]]`
-> | 2017-11-15T19:40:01.000323 | Ernesto |
clojurians | clojure | `[#<TaggedWord Short/JJ>]` | 2017-11-15T19:40:43.000166 | Ernesto |
clojurians | clojure | <https://clojuredocs.org/clojure.core/print-method> | 2017-11-15T19:51:02.000320 | Jonas |
clojurians | clojure | are you talking about how java objects are printed? | 2017-11-15T19:51:15.000270 | Jonas |
clojurians | clojure | <@Jonas> I tought I could get this construct `[#<TaggedWord Short/JJ>]` from/instead of this construct `[#object[edu.stanford.nlp.ling.TaggedWord 0x6a16b1ef "Short/JJ"]]` in the repl. | 2017-11-15T20:11:00.000179 | Ernesto |
clojurians | clojure | Using prn doesn’t seem to change anything | 2017-11-15T20:11:30.000331 | Ernesto |
clojurians | clojure | I think if you can change how it’s printed by overriding the print-method | 2017-11-15T20:11:59.000110 | Jonas |
clojurians | clojure | ```(defmethod print-method edu.stanford.nlp.ling.TaggedWord [v ^java.io.Writer w]
(print-method "[#<TaggedWord Short/JJ>]" w))``` | 2017-11-15T20:13:16.000077 | Jonas |
clojurians | clojure | <@Jonas> wow! Thanks! Works like a charm! | 2017-11-15T21:11:29.000298 | Ernesto |
clojurians | clojure | oh wait | 2017-11-15T21:11:52.000018 | Ernesto |
clojurians | clojure | would need to make dynamic this part: `Short/JJ` | 2017-11-15T21:13:10.000106 | Ernesto |
clojurians | clojure | <@Jonas> this does it:
```
(defmethod clojure.core/print-method edu.stanford.nlp.ling.TaggedWord
[piece writer]
(.write writer (str “#<TaggedWord ” (.toString piece) “>”)))
``` | 2017-11-15T21:37:43.000197 | Ernesto |
clojurians | clojure | Thanks again! | 2017-11-15T21:38:23.000088 | Ernesto |
clojurians | clojure | Is this a good practice? | 2017-11-15T22:20:44.000068 | Ernesto |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.