#clojure log - Jun 29 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

2:10 visof_: hi guys

2:11 is there anybody using enlive for parsing html?

2:11 how can i extract text after some html attributes?

2:14 https://www.refheap.com/104548 that's the html page

2:15 how can i extract "only there is nothing here." text from this page using enlive?

2:15 can anybody help in this?

3:02 mmeix: just learning, when NOT to use reduce (4clojure #132) ...

6:12 H4ns: is there a way to determine the current namespace in a function call or macroexpansion? i would like to infer a resource path from the namespace of a test.

6:16 kwladyka: H4ns, http://clojuredocs.org/clojure.core/*ns* ?

6:17 H4ns: kwladyka: thanks!

6:21 ayia: Hi... Somehow google did not help me... How can I extract position-based group from regex? (actually I need it for clojurescript, but the answer i guess should be the same)

6:29 ups... understood that "groups" comes in the result of re-find (and others) after the actual match.... somehow it was not clear to me, unless I played with it:) Thanks!

8:03 J_A_Work: https://twitter.com/J_Arcane/status/615489455340826624

8:35 liuchong: hehe

9:04 H4ns: when will *ns* be bound at all? it seems that it is bound at read time, but not so much at macroexpansion, compile or run time.

9:05 which kind of makes sense, but it also makes it less useful for the purpose that i wanted to use it for (test resource directory determination)

9:05 gfredericks: H4ns: it is at macroexpansion time

9:05 H4ns: this is a dev tool?

9:06 H4ns: gfredericks: it is just tests

9:06 gfredericks: like it's some utility function called by your tests?

9:06 H4ns: gfredericks: some of my tests require external resources, and i would like to avoid spelling out full resource paths. rather, i want a directory hierachy in dev-resources that mirrors my tests.

9:06 gfredericks: yes, a macro, and it does not work. hence my question.

9:07 gfredericks: oh with the macro you have to be careful to use *ns* at expansion time

9:07 not just emit code that uses it

9:07 H4ns: fair point!

9:07 thanks :)

9:07 gfredericks: just unquoting it usually works

9:07 ,(defmacro my-ns-as-str [] `(str ~*ns*))

9:07 clojurebot: #'sandbox/my-ns-as-str

9:07 gfredericks: ,(my-ns-as-str)

9:07 clojurebot: #error {\n :cause "EvalReader not allowed when *read-eval* is false."\n :via\n [{:type java.lang.ExceptionInInitializerError\n :message nil\n :at [sun.reflect.NativeConstructorAccessorImpl newInstance0 "NativeConstructorAccessorImpl.java" -2]}\n {:type java.lang.RuntimeException\n :message "EvalReader not allowed when *read-eval* is false."\n :at [clojure.lang.Util runtimeException "Util....

9:08 gfredericks: don't pay that no mind it should still work :)

9:08 H4ns: gfredericks: now that you said it, it is quite obvious what went wrong. thank you so much :)

9:08 gfredericks: np

10:08 sharms: In 'lein repl' I am doing a (:require '[datomic.api :as d]) but I cant actually use d/ anything

10:09 dstockton: sharms: call require as a function

10:09 not a keyword :require

10:09 (require '[datomic.api :as d])

10:09 sharms: dstockton - haha ok it works now

10:09 thank you for entertaining my simple mind

10:10 dstockton: no problem, glad to help

10:12 yh: what's the difference between a transducer and any other function? given that functions are composable

10:14 ambrosebs: yh: composing transducers eliminates intermediate data structures

10:16 yh: (comp #(map inc %) #(map dec %)) builds up 2 data structures, (comp (map dec) (map inc)) just builds one.

10:23 yh: thanks ambrosebs

10:40 irctc: philosophical question i guess... why is the interface for map different from doseq? Both apply a function to a collection yet doseq gives you all these other options (when/let features) also, doseq iterates over the entire collection join (is that how you say that?) while map does one from each at a time

10:41 Chousuke_: map is just a function. doseq is meant for side-effects

10:41 chouser: 'doseq' is more like 'for' than 'map'

10:45 Chousuke_: map is also pretty much the same across functional languages. People might riot if you had a map function that didn't work at all like it usually does.

10:53 ambrosebs: any experience reports on repackaging dependencies by embedding them in your project, via something like mranderson or dolly?

10:53 it's getting kind of ridiculous with the amount of tooling that depends on clojure contrib that it seems necessary

11:30 irctc: hm, i guess i see the historical angle of it. makes snese.

11:33 csd_: Does anyone know how to work around this cider error: error in process filter: End of buffer ?

11:34 Received when running tests

11:35 schmir: I'd try a different version unless cider's bug tracker gives you some hints

11:39 csd_: yeah thats what i figured

11:40 Shayanjm: If anyone is interested in browser security, I just wrote about how chrome stores its remembered user credentials as plaintext

11:41 would love any upvotes I can get if you like the content :) https://news.ycombinator.com/newest -> "We can do better - Please fix plaintext credential storage in Chrome"

11:44 hellofunk: Shayanjm: "When you sign in to Chrome and enable sync, Chrome uses your Google Account to encrypt your synced passwords."

11:44 Shayanjm: hellofunk: It's encrypted on Google's servers

11:44 but stored in plaintext locally

11:48 hellofunk: Shayanjm: and i take it Safari encrypts them?

11:48 Shayanjm: hellofunk: I believe safari uses keychain by default

11:48 which is a far more secure implementation

11:49 hellofunk: well +1 apple then

11:49 Shayanjm: Yeah no kidding

11:49 hellofunk: the 1Password app is good too

11:49 but then no one ever accused google of being good on security. i've read for years you should never use chrome to store sensitive data.

11:50 csd_: how might i set a default protocol? is that even possible?

11:50 i just want to move type checking into either the protocol or a multimethod etc

11:51 justin_smith: csd_: you can extend the protocol for Object ?

11:51 csd_: so if you are java Thingie, execute normal function, else, execute function that throws an error

11:51 justin_smith: i can, but im more interested in how to control things that arent Object

11:52 justin_smith: csd_: everything inherits from Object, so it's a default. You can explicitly extend the other classes you care about of course.

11:52 csd_: oh i follow you. i thought you were speaking in the broader sense of the word

11:53 is this actually good practice though? what would be the best way to make sure my function only operates on Thingie?

11:54 justin_smith: if you only want to operate on one specific class, why make a protocol?

11:55 csd_: it doesn't have to be. it just seemed like one option that might work well

11:56 worst case i can just stick in an instance? check but it just seems like there is probably a better way

11:56 justin_smith: the odd thing to me here is that the point of a protocol is to allow multiple classes to implement a standard set of methods. If you only want one class, what does a protocol gain you?

11:57 csd_: hypothetically the ability to redirect ever other class

12:02 i guess i can just make it an precondition assert

12:27 irctc_: Hello, I am trying to do a node.js / clojure interrop scenario. I am feeling like I'm getting lost, although I was able to make a few helper functions. Where should I start ?

12:30 oddcully: irctc_: just to have it mentioned: there is also #clojurescript

12:31 irctc_: thanks, but it's not the idea here (I don't decide that, but the end idea is to make the heavy lifting in Clojure)

12:36 I already have put sessions in Redis from node, and I have functions that can read those and validate them (these are signed cookies)

12:40 but the basic friend example I found doesn't show how to control how cookies are made

12:41 If I implement the ring middleware SessionStore protocol, should I do the validation there also ?

12:52 digiorgi: hi, i want in seesaw to put in a frame of 500x500 some widget that doesn't get resized to take the whole frame size

12:53 how can i do that?

13:34 kryft: Hmm, I can't seem to get a library under checkouts/ included in my uberjar

13:34 (Or anything else for that matter)

13:34 TimMc: kryft: Is it in your :dependencies vector?

13:35 kryft: TimMc: Yes; I've been using the library (clj-pdf) for a while, and now I'm trying to add a feature, so I forked and cloned the repository and added a symlink to it under checkouts in the root folder of my project

13:35 TimMc: So much for the most common mistake. :-)

13:36 kryft: The version of the dependency in my project.clj matches the version number in my local clj-pdf's project.clj

13:36 TimMc: Certainly worth checking :)

13:39 justin_smith: kryft: checkouts require lein install (with the proper version number) before they work, right? Maybe they also require lein install before uberjar?

13:40 kryft: justin_smith: What do you mean by 'with the proper version number'? And do I need to lein install both in my project's folder and the clj-pdf folder (symlink) under checkouts?

13:40 justin_smith: kryft: lein install in the lib's folder

13:41 kryft: the version number used by your project.clj must have been installed via lein install (or exist externally) before checkouts work

13:43 kryft: justin_smith: So if I have [clj-pdf "2.0.4"] in my project's :dependencies, and "2.0.4" at the top of the project.clj in the folder under checkouts, it should be ok?

13:44 justin_smith: kryft: yes, but you probably need to run lein-install inside the folder inside checkouts

13:44 unless uberjar and checkouts are fully integrated, I'm not certain they are

13:45 kryft: justin_smith: Right. Well, I did run lein install in the lib folder, but it still doesn't seem to work. :/

13:45 justin_smith: kryft: what error do you get on uberjar?

13:46 kryft: justin_smith: No error at all; I think it's still using the dependency that it's downloaded previously (I was using clj-pdf installed by lein before I tried to include it via checkouts)

13:46 As far as I can tell, it's ignoring the checkouts folder completely

13:48 justin_smith: kryft: if you ran lein install in the checked out lib, it doesn't need the checkout lib, and the installed version would be overwriting the version you previously downloaded

13:48 so either you have a version number mismatch or you didn't actually use lein install in the checked out lib

13:50 kryft: but the saner thing, to me, would be to update the version string in a way that made the checked out in-development version unique (such that you would get an error if it were not made available, instead of silently using the old version)

13:50 Empperi: cfleming: sorry, haven't found time for that minimal reproduction project quite yet

13:52 kryft: justin_smith: Yay, that worked. :) They were both "2.0.4" previously (the latest clj-pdf master), and now I changed both of them to "2.0.4-FOO", and that did the trick

13:52 justin_smith: kryft: cool

13:54 kryft: to be honest I avoid using checkout deps because they add some complexity with their convenience in my experience (but then again, my coworkers basically consider me a caveman because I am so suspicious of convenient tooling)

13:54 "auto reload? auto namespace loading? doc string popups? I distrust this sorcery, for it must be a sign of evil"

13:54 kryft: :)

13:55 I've never used it before either, but it seemed like the best choice here

14:03 digiorgi: hi, anyway to align a widget vertically and horizontally in seesaw?

14:27 gfredericks: ,(def ⒡ identity)

14:27 clojurebot: #'sandbox/⒡

14:27 gfredericks: ,(⒡ 42)

14:27 clojurebot: 42

14:27 gfredericks: ^ #protip

14:30 justin_smith: gfredericks: I seem to have misplaced my elisp code that outputs every pair of unicode chars that are defined as opening and closing delimiters

14:32 gfredericks: oh that'd be interesting

14:46 justin_smith: gfredericks: some magic with (char-table) that I am now forgetting - that's where all symbols are categorized

14:47 s/symbols/codepoints

15:16 gfredericks: I briefly knew how unicode worked while building that regex->string-gen thing

16:44 jdotleonard: hi, can anyone in here help with a typed clojure question?

16:44 gfredericks: ~anyone

16:44 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

16:44 ordnungswidrig: jdotleonard: simply ask and you will se

16:45 jdotleonard: it’s a bit long so I have posted the question here: https://groups.google.com/forum/#!topic/clojure-core-typed/NSTmqKLGtiY

16:46 essentially the ‘.’ invocation of a java method entails reflection and typed clojure gets confused about what could be meant (although in my case there is only one possibility)

16:47 and there’s no way i can find to annotate the method/member in a way that typed clojure is satisfied with. any attempt at runtime assertion of the type of the member is itself a violation

16:50 ordnungswidrig: jdotleonard: at least post a gist so we can reproduce :)

16:52 jdotleonard: here ya go: https://gist.github.com/johanatan/4be9045bad40abd17f83

16:52 [2 files]. Let me know if you’d like to see the project.clj (or anything else)

16:54 ordnungswidrig: jdotleonard: the actual error message would be nice.

16:56 jdotleonard: it’s in the group posting. did you look at it?

16:56 Type Error (adapters/cassandra.clj:32:7) Unresolved host interop: conn

16:56 Add type hints to resolve the host call.

16:56 Suggested fields:

16:56 adapters.cassandra.CassandraEventConsumer

16:56 \

16:56 public final java.lang.Object conn

16:58 oddcully: jdotleonard: please watch out when pasting many code lines. irc's flood protection will kick in and you out. better use a refheap/pastebin/gist/younameit/...

16:58 jdotleonard: ahh, ok. thx

17:16 seangrove: If I set the version of clojurescript to 3308, but the warnings during compilation tell me it's using 2411, what am I likely overlooking? I don't see any references to it in lein deps :tree, and if I delete that specific jar, it's immediately re-downloaded

17:17 justin_smith: seangrove: plugin or profile issues?

17:17 seangrove: justin_smith: I'll check both...

17:22 Ugh, I don't see any references to it anywhere..

17:22 ordnungswidrig: jdotleonard: not sure, did you try to use regular type annotations? (^CassandraEventconsumer this)

17:22 seangrove: The only plugin I have is lein-cljsbuild 1.0.6

17:23 ordnungswidrig: seangrove: maybe that depends on this clojurescript version? try to exclude the dependencies from lein-cljsbuild

17:24 seangrove: I have [lein-cljsbuild "1.0.6" :exclusions [org.clojure/clojurescript]]

17:24 * seangrove sighs

17:25 jdotleonard: @ordnungswidrig: mmm, nope didn’t try that but I verified that typed.clojure already knows that ‘this’ is of that type from the vim plugin (also the error message hint that it gives indicates that it already knows what ‘this’ is)

17:26 @ordnungswidrig: oooh! that worked!

17:27 @ordnungswidrig: thx!

17:27 ordnungswidrig: jdotleonard: no problem, just guessing. I seldomly used core.types :-P

17:27 core.typed

17:27 jdotleonard: ya, i didn’t even know about that notation. not sure where it is covered in the docs (didn’t see it anywhere)

17:28 there’s a lot of little gaps i’ve had to piece together along the way like that

17:29 btobolaski: Its not part of core.typed, its a type hint. Type hints are used to avoid reflection http://clojure.org/java_interop#Java%20Interop-Type%20Hints

17:30 oddcully: (inc ordnungswidrig)

17:30 lazy bots...

17:39 seangrove: Is there any way to search for all dependencies on clojurescript-0.0-2411 so I can get some way of tracking down where in the world this is coming from?

17:42 cfleming: Empperi: No problem, I have plenty to do

17:44 csd_: Is there something similar to tools.ns that will load all project files into the REPL in correct order? Tools.ns seems more pertaining to reloading.

17:44 seangrove: This is my entire project.clj file https://www.refheap.com/104569

17:44 profiles.clj is just `{}`

17:45 It only retrieves clojurescript-0.0-2411 when running cljsbuild, so that might be a clue...

17:46 Hrm, it does show up in the example/support projects https://github.com/emezeske/lein-cljsbuild/search?utf8=%E2%9C%93&q=2411

17:46 justin_smith: csd_: simply requiring your primary ns should suffice for that

17:47 csd_: justin_smith: i normally use cider-load-buffer.. maybe that's why i have to load each ns manually

17:48 justin_smith: csd_: on first load, require is all you need. After that you are looking at reload, which is what c.t.ns is for

17:49 jdotleonard: @btobolaski: ahh, i see. that makes sense. thx!

17:49 @btobolaski: why would java method access involve reflection to begin with?

17:50 @btobolaski: nevermind. i suppose it is because clojure being dynamically typed wouldn’t know what ‘this’ was at that point in the logic without the hint?

21:01 xeqi: seangrove: I'm fairly certain that is being added by the cljsbuild attempt to have a recent cljs https://github.com/emezeske/lein-cljsbuild/blob/master/plugin/src/leiningen/cljsbuild/subproject.clj

21:01 the plugin modifies the deps and adds it

21:02 seangrove: I have a .cljc file that actually works without problem when compiling from the commandline, and I can eval in the buffer/file just fine, but on save the figwheel process complains: "java.io.FileNotFoundException : Could not locate mana/schemata__init.class or mana/schemata.clj on classpath."

21:03 xeqi: maven's dep model says that :classifier :aot is not the same as w/o classifier

21:03 seangrove: xeqi: Yeah, was going to point to https://twitter.com/swannodette/status/615651691237646336

21:03 xeqi: so it ignores that you have one declared

21:03 seangrove: Ah, ok

21:03 That kind of makes sense

21:04 But it doesn't warn about it at all, which it usually does if the declaration is missing altogether

21:07 $seen bhauman

Logging service provided by n01se.net