2015-07-03
| 01:59 | namra | ,(conj [] {:hello "world}) |
| 01:59 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading string> |
| 01:59 | namra | ,(conj [] {:hello "world"}) |
| 01:59 | clojurebot | [{:hello "world"}] |
| 01:59 | justin_smith | ,(conj {} [:hello "world"]) |
| 01:59 | clojurebot | {:hello "world"} |
| 02:11 | elvis4526 | Is there an easy way to mock a DB with jdbc ? |
| 02:11 | elvis4526 | (for testing) |
| 02:12 | justin_smith | elvis4526: one option is to use an in-memory h2 db |
| 02:12 | justin_smith | h2 is native jvm, so you can create it in your process, and then throw it away, without any external deps |
| 02:13 | elvis4526 | ahh that's nice thanks |
| 02:22 | amalloy | ddellacosta: if you can figure out an easy way from bash to find out whether lazybot has disconnected from irc, i can switch it to use the same auto-restart script 4clojure uses |
| 02:22 | amalloy | for the moment, lazybot is back |
| 02:23 | ddellacosta | gotcha. Thanks amalloy. :-) |
| 02:23 | amalloy | but we have no idea why he disconnects at random intervals and can't detect when it's happened |
| 02:23 | ddellacosta | d'oh. So it's a thing that happens sometimes, huh |
| 02:23 | amalloy | sometimes weeks in between restarts, sometimes hours |
| 02:23 | radens | Quick question, is clojure pure? Does it have monads? |
| 02:24 | ddellacosta | radens: clojure is not pure. |
| 02:24 | ddellacosta | radens: unless you enforce purity yourself, on a per-function basis, but it's not enforced on the language level |
| 02:25 | ddellacosta | radens: there are ways to create monads, but I generally find them pretty torturous compared to what Haskell gives you there. |
| 02:25 | radens | ddellacosta: thanks. Pragmatism for the win. |
| 02:25 | ddellacosta | radens: for example: https://github.com/clojure/core.typed/wiki/User-Guide#higher-kinded-variables |
| 02:26 | radens | ddellacosta: in that example is TFn like the tee command? |
| 02:27 | radens | Alas I don't clojure well enough to sort that out. |
| 02:27 | ddellacosta | radens: I believe TFn is a function type with type constraints? |
| 02:27 | ddellacosta | radens: sorry, a lot of that syntax is core.typed specific |
| 02:28 | ddellacosta | radens: in "basic" clojure it's a lot more challenging to build something that is a legitimate monad |
| 02:28 | radens | okay. Thanks! |
| 02:29 | ddellacosta | radens: sure thing! BTW, I found this post by Timothy Baldridge to be a good rationale for why not to use monads in Clojure: https://github.com/clojure/core.typed/wiki/User-Guide#higher-kinded-variables |
| 02:29 | ddellacosta | d'oh, not that |
| 02:29 | ddellacosta | https://groups.google.com/d/msg/clojure/wccacRJIXvg/tFAxZBuO0wMJ |
| 02:29 | ddellacosta | sorry radens ^ |
| 02:30 | ddellacosta | in general that thread has a lot of good comments relating to pros/cons of using monads or not in Clojure |
| 02:31 | ddellacosta | anyways, enjoy. :-) |
| 02:32 | radens | Thanks! |
| 04:26 | techplex | t |
| 05:34 | H4ns | is there a common name for a map variant that returns as many elements as the longest of the arguments? |
| 05:35 | H4ns | i.e. (map list '(1 2) '(3)) => ((1 3) (2 nil)) |
| 05:42 | H4ns | nm. |
| 05:51 | jack0 | Hi, when I try to run REPL I get the following error |
| 05:51 | jack0 | Could not find artifact thomasa:mranderson:jar:0.4.4-ambrosebs-SNAPSHOT in clojars (https://clojars.org/repo/) Could not find artifact thomasa:mranderson:jar:0.4.4-ambrosebs-SNAPSHOT in sonatype-oss-public (https://oss.sonatype.org/content/groups/public/) This could be due to a typo in :dependencies or network issues. If you are behind a proxy, try setting the 'http_proxy' environment variable. |
| 05:51 | jack0 | Any clue why it might be? |
| 05:58 | vas | it looks like there is a dependency in your dependencies list in your project.clj that is not playing nicely... |
| 05:58 | vas | did you try running lein deps |
| 06:08 | ddellacosta | jack0: you may need to add an entry to the :repositories entry for thomasa:mranderson:jar:0.4.4-ambrosebs-SNAPSHOT--where are you referencing that from? https://github.com/technomancy/leiningen/blob/aad0e7509d3b79f17e16fd40bad2f661ad7422ed/sample.project.clj#L78 |
| 06:09 | jack0 | I was able to fix it |
| 06:09 | ddellacosta | okay, great |
| 06:09 | jack0 | I setup lein again! |
| 06:09 | jack0 | :D |
| 06:09 | ddellacosta | huh, that seems dramatic, but whatever works. :-) |
| 06:10 | jack0 | Yeah, it is a bit dramatic, but I had set it up in early 2014. |
| 06:10 | jack0 | :) |
| 06:11 | jack0 | BTW, Does anybody know the people who are doing GSoC this year? |
| 08:15 | ghostghostghost | in a website/API situation, is there any reason why I wouldn't want do throw DB queries into futures when I need to perform a few at the same time? Given that the overhead of creating futures outweighs waiting for each individual query to finish before starting the next one? Dumb example like {:body :q1 @futere-one, :q2 @future-two, :q3 @future-three } |
| 08:19 | aztak | if you still need to wait for them, and the database-driver isn't asyncronous, I'd say it wouldn't make any difference. |
| 08:21 | ghostghostghost | if each one took 50ms, then doing three using futures might take 50-60ms, whereas without it would take 150ms, wouldnt it? |
| 08:24 | aztak | if the db can handle three queries on the same connection in parallell, yes. And if the db-driver is async so that you don't occupy three threads running the futures. |
| 08:25 | aztak | depends on if you need throughput or to scale out with concurrent requests I suppose? |
| 08:47 | magnars | If I create a new leiningen project, and run `lein deps :tree`, I see that I've got org.clojure/tools.nrepl "0.2.6" from somewhere. It overrides my "0.2.10" that I am explicitly including. Any idea where it comes from? (I've removed .lein/profiles.clj, so that's not it) |
| 08:51 | magnars | seems like it is actually coming from leiningen |
| 08:52 | magnars | this did the trick: ^:replace [org.clojure/tools.nrepl "0.2.10"] |
| 08:53 | magnars | thanks for the rubberducking! |
| 08:56 | oddcully | (inc rubberduck) |
| 08:56 | lazybot | ⇒ 2 |
| 11:33 | Bronsa | ambrosebs: I have some time now to help you with the issue you had yesterday, if you're here |
| 11:34 | ambrosebs | Bronsa: I'm here, I'll try and ping you in 20 minutes or s |
| 11:34 | ambrosebs | o |
| 11:34 | Bronsa | ok |
| 11:52 | ambrosebs | Bronsa: so I've spent too much time on the implementation for this paper, so I haven't narrowed it down. But my approach is, if I have a reflective interop call 1) attach the relevant :tag and :o-tag type hints based on the static types of the arguments, 2) run it through the analyzer again with this function |
| 11:52 | ambrosebs | https://github.com/typedclojure/core.typed/blob/rewrite-reflect-field2/module-check/src/main/clojure/clojure/core/typed/check.clj#L1425-L1428 |
| 11:53 | ambrosebs | this actually works, I get out an :instance-call from :host-interop |
| 11:53 | ambrosebs | but it seems doing the `emit-form` -> `eval` trick still thinks its reflective |
| 11:54 | Bronsa | ambrosebs: has the :instance-call :validated=>true? |
| 11:55 | Bronsa | ambrosebs: ah, wait. I know what's the issue |
| 11:55 | ambrosebs | yes it's validated |
| 11:55 | ambrosebs | :validated? = true |
| 11:56 | Bronsa | ambrosebs: emit-form will attach to the emitted form just the metadata of the original form |
| 11:56 | ambrosebs | ah |
| 11:56 | Bronsa | so if you add :tag to the AST, it will not be added to the argument when you emit it |
| 11:56 | ambrosebs | so I should add it to the :form too? |
| 11:57 | Bronsa | either that or tweak emit-form to attach :tag as meta |
| 11:57 | ambrosebs | ok I'll try it |
| 11:59 | Bronsa | ambrosebs: are you doing AST rewriting? |
| 11:59 | ambrosebs | do I attach the Class or a symbol to the :form? |
| 11:59 | ambrosebs | yes |
| 11:59 | Bronsa | ambrosebs: either should be fine |
| 11:59 | Bronsa | ambrosebs: you can use t.a.passes.jvm.emit-form/class->sym |
| 12:00 | Bronsa | ambrosebs: if you're trying to incorporate a rewrite pass in the t.a.jvm pipeline, be careful. AST rewriting is real tricky |
| 12:02 | Bronsa | you might end up accidentally not running a pass over some subnodes, probably arrdem remembers some of the issues he had |
| 12:02 | ambrosebs | ok. I'll keep that in mind if I ever try it. |
| 12:03 | ambrosebs | right now I'm just running the analyzer first in full and type checking it. |
| 12:08 | ambrosebs | Bronsa: didn't work, I think this narrows it down to something other than tools.analyzer. |
| 12:08 | ambrosebs | I'll ping you if I get stuck |
| 12:17 | ambrosebs | actually some cases are working now |
| 13:12 | sdegutis | Never mind. Turns out I was looking for partition-by, not group-by. |
| 13:12 | sdegutis | Thanks anyway. |
| 13:14 | justin_smith | amalloy_: regarding a bash command that tests if lazybot is connected, what about adding a "heartbeat" type endpoint to its http server (the one used to access logs currently) that checks whether lazybot can ping some host or user on IRC? Then the bash script could use curl. |
| 13:16 | sdegutis | Hi. |
| 13:18 | justin_smith | hello |
| 13:30 | sdegutis | How are you. |
| 13:31 | justin_smith | I'm well |
| 13:31 | justin_smith | long weekend! |
| 13:40 | sdegutis | Very glad for you. |
| 13:40 | sdegutis | I don't know whether I have Monday or today off. |
| 13:41 | sdegutis | And I don't feel like I've done a good enough job at work lately to ask. |
| 13:59 | sdegutis | I have a question, if that's alright? |
| 13:59 | ToxicFrog | Don't ask to ask, just ask |
| 13:59 | ToxicFrog | (also, re: if it was a compelling idea I would have written the code already: I've only had this idea for like two weeks, and I've spent a bunch of that talking design with people.) |
| 14:03 | sdegutis | ToxicFrog: that was the question |
| 14:03 | sdegutis | Okay let me try another one. |
| 14:06 | sdegutis | I've got a collection of Items, which each have a single :tag and :date. I want to partition-by them with :tag, but then sort them by :date, both within each group and order the groups by the overall :date. |
| 14:06 | sdegutis | What's the least idiotic way to do that last part, to reorder the groups by their contained Items' :date? |
| 14:10 | ToxicFrog | What's "overall date"? Highest? Lowest? Mean? |
| 14:12 | sdegutis | Yeah see I don't know that part. |
| 14:14 | ToxicFrog | sdegutis: so, I would say "the least idiotic way is some sort of map-by-key + reduce on each collection to get the overall date, and sort by that", although I don't know if that's the actual best way to do that, it's just what I thought of |
| 14:15 | ToxicFrog | But you need to figure out what you're actually sorting by first! |
| 14:17 | sdegutis | ToxicFrog: as for implementation is there a reason not to do partition-by and then sort-by? |
| 14:19 | madstap | Does anyone know if there's any way to use autoprefixer with lein? Or directly from garden? |
| 14:20 | ToBeReplaced | sdegutis: if you're going to sort it's gotta all be in memory anyway, right? what's wrong with (->> coll (group-by :tag) vals (map #(sort-by :date)) (sort-by (comp :date first))) |
| 14:21 | sdegutis | ToBeReplaced: oh good point, group-by and one sort-by essentially replaces partition-by and two sort-bys (outer and inner) |
| 14:21 | sdegutis | ToBeReplaced, ToxicFrog: thanks, I didn't get it at first but now I do |
| 14:21 | sdegutis | Another question: |
| 14:22 | sdegutis | Do the Fair Use copyright laws in USA allow distributing a small portion (30 to 90 seconds) of an 18 hour audiobook over the internet just for the sake of demonstrating to friends what it sounds like? |
| 14:23 | justin_smith | followup: would you ever get caught? |
| 14:25 | sdegutis | Yes. Certainly. |
| 14:25 | sdegutis | But probably not by anyone who owns the copyright or is motivated to do anything about it like reporting it. |
| 14:29 | kristof | That probably is not as good as you think. |
| 14:31 | kristof | sdegutis: There is no "length" limit for fair use. You are permitted to use as much of source as needed to prove your point, but no further. |
| 14:32 | sdegutis | Ahhh. |
| 14:32 | sdegutis | Thanks kristof and to an extent justin_smith. |
| 14:34 | kristof | sdegutis: You have to look at fair use in general and see if the uses are within your use case. Samples are probably okay :) |
| 14:34 | sdegutis | Excellent! |
| 14:34 | sdegutis | Good bye. |
| 17:00 | lasergoat | i'm looking for some quick guidance on using transients |
| 17:00 | lasergoat | i've boiled my confusion down a gist: https://gist.github.com/icambron/5d969958b2d51899ce42 |
| 17:00 | lasergoat | whose code doesn't seem to do what i expect |
| 17:01 | lasergoat | and i suspect i have some sort of fundamental misunderstanding of something |
| 17:08 | amalloy | lasergoat: transients *may* mutate themselves for efficiency; they do not promise to do so |
| 17:08 | amalloy | so you always have to use the return value from assoc! or whatever |
| 17:09 | lasergoat | ooohh |
| 17:09 | lasergoat | thanks, that makes good sense |
| 17:10 | lasergoat | i'll use `loop` then |
| 17:11 | amalloy | lasergoat: why are you doing this at the lowest possible level of abstraction? you probably don't need transients, and there's probably a library function that will do whatever it is you want in two lines |
| 17:11 | lasergoat | oh, i'm not really doing that at all |
| 17:12 | lasergoat | my actual use case is way more complicated, such that i decided it made sense to go that low-level |
| 17:12 | lasergoat | i was just able to boil down the problem to something this silly |
| 17:38 | lasergoat | cool. that worked like a charm. but now i'm curious: it looks like the implementation mutates if it will end up with the same number of keys and creates a new value otherwise. what's the motivation for that? |
| 17:52 | justin_smith | lasergoat: implementation detail of persistent data structures |
| 17:53 | justin_smith | lasergoat: if it doesn't need to create more arrays in the underlying tree, it's effectively an in-place update |
| 17:53 | lasergoat | ah, right |
| 17:53 | justin_smith | lasergoat: if it creates more underlying arrays, it doesn't promise to adjust the original |
| 17:54 | justin_smith | so you need to always use the return value, in case of the latter |
| 17:58 | lasergoat | well, it doesn't just not promise - it flatly doesn't. I was just asking from an implementation perspective. I guess there's no way to grow a java array, so it's the same to just create a new transient instance |
| 17:59 | lasergoat | so it makes sense to optimize the don't grow case and let the grow case just do its thing |
| 18:00 | sdegutis | Help. |
| 18:00 | lasergoat | (i'm one of those annoying "I need to know *why* that works like it does" people) |
| 18:01 | TEttinger | hey sdegutis |
| 18:01 | sdegutis | Hi. |
| 18:03 | lasergoat | opinions on data.csv vs clojure-csv? |
| 18:17 | sdegutis | How do you get the maximum of a list of dates? I thought max-key would allow it but it only works on numbers. |
| 18:17 | sdegutis | Do I have to convert the dates into some number? |
| 18:18 | TEttinger | you could do a map over the list to convert them to numbers with whatever API fn they have for that |
| 18:19 | sdegutis | I guess I could sort-by and then get first or last |
| 18:20 | justin_smith | sdegutis: .getTime gets a number from a Date, that will be larger for later dates |
| 18:20 | sdegutis | Seems legit. |
| 18:20 | sdegutis | Thanks Justin Smith. |
| 18:20 | sdegutis | Guys, look. How long are we going to keep doing this? |
| 18:21 | justin_smith | so something like (max-key #(.getTime %) dates) |
| 18:21 | sdegutis | It's been like, forever, since we all joined #clojure. And nothing's changing. Day in, day out, we write Clojure and come in here and chat. |
| 18:22 | justin_smith | sdegutis: I know a lot more about Clojure than I did when I first started hanging out here |
| 18:22 | sdegutis | That's excellent. |
| 18:22 | sdegutis | But what's the end goal of being the foremost expert on Clojure? |
| 18:23 | sdegutis | When will it end? When is enough enough? |
| 18:23 | justin_smith | I'm not foremost, but I have a higher paying Clojure job now. |
| 18:23 | sdegutis | You may not be yet, but at this rate you will be soon. |
| 18:24 | sdegutis | justin_smith: btw you need apply for that |
| 18:24 | sdegutis | (apply max-key foo dates) |
| 18:24 | justin_smith | ahh, I forgot that max-key took individual items |
| 18:24 | justin_smith | (doc max-key) |
| 18:24 | clojurebot | "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest." |
| 18:24 | sdegutis | Me too. Dash reminded me. |
| 18:26 | sdegutis | justin_smith: Well if a higher paying Clojure job is the end goal, at what point does a job pay well enough? At what point have you beaten life's end boss and make enough money so that you never have to learn any more Clojure? |
| 18:27 | oddcully | learning, if you are lucky, ends when you die |
| 18:27 | Travisty | oddcully: Or if you’re unlucky… depending on when you die |
| 18:28 | justin_smith | sdegutis: I was learning for a long time before I even worked as a dev (and I didn't think I would be doing development professionally). I'm sure I'll still be coding and learning after I retire (if I ever do) |
| 18:28 | sdegutis | oddcully: what is the benefit of such learning then? |
| 18:29 | sdegutis | justin_smith: I see. |
| 18:29 | justin_smith | it's a goal, not an ends to a goal |
| 18:29 | Travisty | sdegutis: I guess it’s one of those non-destination things that is more about the journey. Or something. |
| 18:30 | lasergoat | Eh, you might as well ask what the point of anything is. We do thinks because we enjoy them. |
| 18:30 | lasergoat | If I didn't get paid to program, I'd do it anyway. If I were the foremost expert on Clojure, I'd learn a new language |
| 18:30 | lasergoat | This stuff is supposed to be fun |
| 18:32 | sdegutis | lasergoat: I don't do things because I enjoy them. |
| 18:32 | sdegutis | lasergoat: I certainly don't work because I enjoy it, or change diapers because it's so fun. Seems to be a flaw in your theory. |
| 18:32 | sdegutis | Phew, just finished this story. |
| 18:33 | Bronsa | sdegutis: believe it or not, some of us actually enjoy writing clojure |
| 18:33 | sdegutis | Bronsa: I don't mind writing Clojure. But if I were choosing my activities by enjoyability, there's a list of other things I'd rather be doing. |
| 18:33 | lasergoat | But you had a kid because you thought you'd enjoy having one (I hope!) |
| 18:33 | sdegutis | lasergoat: haha |
| 18:33 | oddcully | sdegutis: what would be the benefit of not learning? |
| 18:34 | Bronsa | I can't help but think the guy's trolling every time he speaks. |
| 18:34 | Travisty | sdegutis: I think often we do things that we’re not too excited by to fulfill longer-term goals. Like having enough money to do the things you like, having a happy family, etc |
| 18:34 | Bronsa | Travisty: he left |
| 18:34 | Travisty | ffs |
| 18:35 | justin_smith | it's really weird to compare having to take care of a child to learning clojure |
| 18:35 | Travisty | Didn’t he make the closure-social channel private or something a few months ago in a similar fit? |
| 18:35 | oddcully | then i better get a beer... won't get any more philosophical than this |
| 18:35 | justin_smith | I mean nobody's gonna call me a monster if I just suddenly stop having anything to do with clojure (though it would be a foolish decision) |
| 18:36 | Bronsa | justin_smith: what are you talking about? sure I will. |
| 18:36 | lasergoat | "but who will answer all the questions on #clojure? think of the children!" |
| 18:36 | justin_smith | Bronsa: haha |
| 18:54 | holo | hi |
| 18:56 | amalloy | i will preemptively call justin_smith a monster if that will help |
| 18:56 | justin_smith | well, it's good to know I would be missed |
| 18:57 | TEttinger | (identity justin_smith) |
| 18:57 | lazybot | justin_smith has karma 268. |
| 18:57 | TEttinger | well, yes |
| 18:57 | TEttinger | (identity TEttinger) |
| 18:57 | lazybot | TEttinger has karma 57. |
| 18:57 | oddcully | (identity rubberduck) |
| 18:57 | lazybot | rubberduck has karma 2. |
| 18:58 | justin_smith | oddcully: obviously underappreciated |
| 18:58 | oddcully | totally |
| 19:02 | holo | I want to represent a json string in a dom property "foo" like this: <div foo='{ \"a\": [\"b\"] }'></div> I'm having trouble escaping the single quotes. any way to do that with(out) hiccup(s)? |
| 19:03 | lasergoat | i guess i don't see why need to escape the single quotes? |
| 19:03 | lasergoat | or do you mean escape single quotes that are embedded in, say "b" |
| 19:04 | justin_smith | holo: in clojure strings, single quotes are not escaped |
| 19:05 | holo | lasergoat, so like this?: <div foo="{ \"a\": [\"b\"] }"></div> hmm, i thought js needed to nest ' with ", and the other way around |
| 19:05 | justin_smith | wait, where does this involve clojure? |
| 19:05 | lasergoat | i'm more trying to clarify the question |
| 19:05 | lasergoat | like i'm trying to imagine the function you're trying to write, the inputs, the outputs, and where the escaping happens |
| 19:06 | holo | justin_smith, how would you encode that with hiccup? |
| 19:06 | lasergoat | most crucially: are you trying to escape strings in the _output_ so that, say, the browser has them escaped |
| 19:07 | lasergoat | or are you trying to make sure that the inputs to your function are properly escaped? (as justin_smith points out, this is unnecessary with single quotes) |
| 19:07 | holo | lasergoat, i'm trying to actually see that output when inspecting the page in the browser |
| 19:07 | justin_smith | [:div {:foo "{\"a\": [\"b\"]}"] |
| 19:07 | oddcully | holo: if you want to write just html, then the " are " |
| 19:09 | holo | I want to have the ' ', not " " |
| 19:09 | justin_smith | holo: alternatively [:div {:foo (cheshire/generate-string {:a [:b]})}] (letting the tool generate the json for you) |
| 19:09 | justin_smith | holo: ' versus " is js syntax, there is no js above, just a json literal |
| 19:10 | holo | justin_smith, the problem is that, wheather you manually create json, or let some clj lib generate for you, they will be clojure strings, thus wrapped with " ". and that's what will show in the browser |
| 19:11 | justin_smith | holo: are '' and "" different, other than how they handle the other quotation symbol? |
| 19:11 | oddcully | holo: e.g. with hiccup (sablono in cljs for me), this produces proper html `:data-json "{\"a\": \"1\"}"` |
| 19:11 | oddcully | would i want to generate json this way? no |
| 19:12 | oddcully | the attri='..' is just an html convinience. if you escape your " properly, there is no problem |
| 19:13 | lasergoat | fwiw, if you do get single quotes for the outer one, you don't need the escaped double quotes on the inner ones |
| 19:13 | lasergoat | which could be nice, depending on how you generated the json string |
| 19:13 | holo | justin_smith, the problem is that hiccup will create the html with " " inside enclosing the json string |
| 19:13 | justin_smith | lasergoat: well we are talking about hiccup, which is a clojure syntax, where '' does not create a string |
| 19:15 | oddcully | holo: do you experience this behaviour by seeing in your devtools of the browser are by actually looking at the generated html? |
| 19:15 | oddcully | holo: my firebug shows me `"` - but they are " in the source code |
| 19:16 | oddcully | !-2s/are/or/ |
| 19:17 | holo | oddcully, both. in the former, ' (or ') just render the first '. and even when i replace the " with ' after i have the html string, when the (set! (.innerHtml elem) html-str) is done, the ' ' are gone, which i find weird |
| 19:18 | lasergoat | justin_smith: right, i'm talking about the output. hiccup generates this: "<div foo=\"{"a": ["b"]}\"></div>". i'm guessing the problem here is that holo wants those inner quotes to be quote literals, which is why they want the outer quotes to be single quotes |
| 19:19 | lasergoat | but i also may just not understand the question |
| 19:19 | justin_smith | lasergoat: OK, right (I am actually trying hiccup in my repl now and see what you mean) |
| 19:20 | holo | lasergoat, i think so. i want those single quotes to be used in the dom (not sure if my terminology is correct here, sorry) |
| 19:22 | holo | i don't expect javascript to parse that literal well, if i have " " enclosing other " " |
| 19:23 | lasergoat | by javascript here, you mean that you're having some javascript pull out the attribute "foo" and then parse the value as json, right? |
| 19:23 | holo | lasergoat, yes |
| 19:24 | justin_smith | holo: yeah, I thought I knew how to do this, but I don't, and I'm starting to wonder if this is even a thing hiccup can do |
| 19:25 | holo | justin_smith, i already had given up about hiccup, so i tried to just replace the ' with " in the html string, which was fine. but the problem then occurs when i do (set! (innerHtml elem) html-str). then the ' are gone, and replaced with " again |
| 19:31 | oddcully | holo: maybe i have lost a line or two: where/how are you turning your foo attribute into "html" for your innerHTML? |
| 19:32 | oddcully | holo: just for the records, there also is #clojurescript |
| 19:40 | holo | oddcully, (-> (sel1 :#some-id) .innerHtml (set! "<div foo='{ \"a\": [\"b\"] }"></div>'")) ;DOM=> <div foo="{ "a": ["b"] }"></div> (using dommy here, and already using my str replace from the html output of hiccups) |
| 19:41 | holo | oddcully, sorry, i didn't answer your question. give me a sec |
| 19:46 | lasergoat | so, thinking about that a bit more |
| 19:46 | lasergoat | i don't the quotes are actually an issue |
| 19:47 | lasergoat | 1. You really do want html character entities, which will be turned into quotes in terms of the dom's "value" |
| 19:47 | holo | oddcully, after document ready, js generated by this cljs: (replace (html [:div {:foo "dummy"}]) #"\"dummy\"" "'{ \"a\": [\"b\"] }'") |
| 19:48 | lasergoat | 2. The dom doesn't doesn't know or care about what kind of quotes you used to make a piece of the dom; it's just attributes and values, and when it shows you them in html form, that's just how it's serializing them back to you |
| 19:48 | holo | replace is from clojure.string and html will produce html string from that hiccup syntax |
| 19:49 | lasergoat | 3. this works fine, using the regular output from hiccup: https://jsfiddle.net/naupc9r8/ |
| 19:51 | holo | oh right, a jsfiddle :) |
| 19:54 | holo | so you used the html entities for the characters inside the string! well, i didn't think about that :) |
| 19:54 | lasergoat | i didn't; that's what hiccup did! |
| 19:54 | holo | your justification makes totally sense with that example :) |
| 19:54 | lasergoat | but it's the right thing to do in any case (see point 1) |
| 19:55 | lasergoat | cool, glad it helps |
| 19:56 | holo | lasergoat, because i was trying in cljs, and i was seeing the print in the browser console, i didn't get that |
| 19:56 | lasergoat | ah, right, yeah |
| 19:56 | holo | lasergoat good idea to just try it with hiccup |
| 19:59 | holo | (inc lasergoat) |
| 19:59 | lazybot | ⇒ 2 |
| 19:59 | lasergoat | the take-home less (at least for me!) is to always remember that the dom itself isn't text; it's just something you modify by supplying text and examine by letting the browser serialize it to text for you |
| 19:59 | holo | (inc oddcully) |
| 19:59 | lazybot | ⇒ 11 |
| 19:59 | lasergoat | i missed that for the first whole bunch of time thinking about the problem |
| 19:59 | holo | (inc justin_smith) |
| 19:59 | lazybot | ⇒ 269 |
| 20:01 | holo | indeed |
| 20:01 | edw | I decided to try to modify my AWS S3 based app to support Google Cloud Storage. W. T. F. Has anyone found a good Clojure--or Java, for that matter--wrapper around the standard Google classes? Authenticating to GCS requires amazing hoop-jumping. |
| 20:03 | holo | edw, in cljs right? wont you have CORS issues? |
| 20:04 | holo | s/wont/will |
| 20:04 | edw | holo: No, server side. |
| 20:04 | holo | oh ok :) |
| 20:05 | edw | Basically, it's OAuth 2.0 hell. Get the JacksonJsonReaderFactory, import twenty more classes, write fifty lines of code... |
| 20:06 | holo | my xp with oauth 2.0 was through oauth.io. did you consider that or similar? |
| 20:06 | edw | Googling, it seems like everyone starts an exploratory project and a day later says, "Fuck this shit!" |
| 20:06 | holo | haha |
| 20:08 | lasergoat | i'd be pretty tempted to just hit the api directly |
| 20:08 | holo | lasergoat, btw, thanks a lot! Also, oddcully and justin_smith: thanks! :) |
| 20:09 | lasergoat | np |
| 20:09 | lasergoat | edw: i recently wrote my own code to deal with google oauth2, and it wasn't much work |
| 20:09 | holo | IIRC, i also said frack this sh?t myself, and just used oauth.io :s |
| 20:09 | oddcully | yw... tried to reproduce the problem locally... but my preexistint arity error did not help ;) |
| 20:11 | holo | hehe :) thanks |
| 20:12 | lasergoat | edw: the api itself looks a little onerous, but probably easier than trying to wrap some complicated client library |
| 20:12 | edw | I'm been deeply spoiled by the Cloure AWS S3 wrapper. |
| 21:09 | afrobee | Any example of how efficiently low many resources with core async at once? |
| 21:10 | afrobee | low = load |
| 21:10 | lasergoat | what do you mean by loading resources? |
| 21:37 | justin_smith | *lowing |
| 21:38 | justin_smith | in all seriouisness, core.async actually isn't good for blocking stuff like synchronous IO, and if your resources are sharing the same pipe or file system, async access can as easily slow things down as speed them up |
| 21:56 | lasergoat | i kinda disagree. go blocks aren't good for synchronous io, but using core.async to manage concurrency for blocking io with threads and channels seems to work pretty well |
| 22:09 | amalloy | if you already have threads core.async isn't buying you that much, but it's not totally useless |
| 22:41 | aaronm04 | how different is clojurescript (aside from Java interop)? |
| 22:44 | ambrosebs | most code can be ported without changes |
| 22:44 | aaronm04 | awesome :D |