2013-03-23
| 00:09 | egghead | holy cow technomancy this looks amazing |
| 00:15 | technomancy | heh; thanks |
| 00:33 | nonuby | technomacy, minor suggestion, click to enlarge pics to hover to enlarge pics, I cant make out whats going on |
| 00:41 | technomancy | thanks, but the point isn't really what's in the pictures; it's that they're the same on both screens |
| 00:49 | nonuby | okay found the 'About' |
| 00:53 | seangrove | technomancy: Definitely looks slick! |
| 00:58 | technomancy | yeah, kinda looking for more ways to make it obvious |
| 06:07 | borkdude | hyPiRion ivaraasen nice, I see gnuplot works okay with org-babel |
| 08:27 | Glenjamin | is there a better way of turning a vector into a map of key => nil than this? |
| 08:27 | Glenjamin | &(reduce #(assoc %1 %2 nil) {} [1 2 3]) |
| 08:27 | lazybot | ⇒ {3 nil, 2 nil, 1 nil} |
| 08:30 | ejackson | &(zipmap [1 2 3] (repeat nil)) |
| 08:30 | lazybot | ⇒ {3 nil, 2 nil, 1 nil} |
| 08:30 | Glenjamin | ah, much nicers |
| 08:30 | Glenjamin | thanks |
| 08:30 | ejackson | plsr |
| 09:37 | maio | is there some way to check if there are new versions my project's dependencies? |
| 09:38 | hyPiRion | $latest leiningen-core |
| 09:38 | lazybot | [leiningen-core "2.1.1"] -- https://clojars.org/leiningen-core |
| 09:39 | hyPiRion | Not sure if there's a way to do that with Leiningen though, perhaps check out the plugins page? |
| 09:40 | maio | hyPiRion: thanks :) lein-outdated List newer available versions of dependencies |
| 09:42 | hyPiRion | You're welcome |
| 12:19 | TimMc | muhoo: OK, cool. |
| 12:25 | racycle | I have a very basic question: I don't understand this clojure idiom: (def my-fun (fn [] (println "test") :done)), i don't understand how :done works ? |
| 12:28 | p_l | it works by returning itself? |
| 12:28 | p_l | ,(fn [] (println "test") :done) |
| 12:28 | clojurebot | #<sandbox$eval35$fn__36 sandbox$eval35$fn__36@188dff6> |
| 12:29 | p_l | it gives you a function, as visible above |
| 12:29 | p_l | ,:done |
| 12:29 | clojurebot | :done |
| 12:29 | p_l | and as you see, :done returns itself |
| 12:30 | racycle | by returning itself ? that's interesting |
| 12:30 | p_l | racycle: self-evaluating element, in this case keyword symbol |
| 12:30 | p_l | basically, whatever is the "last" is the return value of the function in lisps |
| 12:30 | p_l | you could have any other literal there to return said literal, too |
| 12:31 | racycle | i see, so is (fn [] (println "test") a hash map that :done is the key for ? am i too far off |
| 12:32 | p_l | too far off |
| 12:32 | racycle | oh, the whole thing is a list |
| 12:32 | racycle | and the last element is returned. ok |
| 12:32 | p_l | it's a function defined in weird way |
| 12:33 | p_l | fn creates anonymous function, iirc, def will bind it to symbol my-fun |
| 12:34 | p_l | I don't usually use clojure, using CL instead, but the CL equivalent would be (setf (symbol-function 'my-fun) (lambda () (print "test") :done)), or so it seems to me |
| 12:34 | racycle | ok, that helps. I'll try to wrap my head around this construct a little |
| 12:35 | racycle | i find these a little confusing about Clojure compared to scheme/Racket |
| 12:35 | racycle | thanks again |
| 12:36 | p_l | in scheme... |
| 12:36 | p_l | that would have been (define my-fun (lambda () (print "test") :done)) ; Something like that? |
| 12:41 | racycle | i don't recall exactly, but the :done is not very familiar to me. |
| 12:41 | borkdude | racycle :done is just a value |
| 12:41 | borkdude | racycle not some special language construct |
| 12:42 | borkdude | ,:foo |
| 12:42 | clojurebot | :foo |
| 12:42 | borkdude | ,:done |
| 12:42 | clojurebot | :done |
| 12:42 | racycle | you're right, for some reason, i'm always thinking that it's a key for some map etc.. |
| 12:42 | borkdude | yogthos I see you're writing a book, cool http://yogthos.net/blog/42?utm_source=dlvr.it&utm_medium=twitter |
| 12:43 | borkdude | racycle you can use any value as a key in a map, but keywords are most common |
| 12:43 | borkdude | ,{nil 1, "foo" 2, :done 3} |
| 12:43 | clojurebot | {nil 1, "foo" 2, :done 3} |
| 12:43 | jtoy_ | so if i want to add testing code to clojure, is midje the way to go? |
| 12:44 | racycle | ok thanks |
| 12:45 | ravster | hey all |
| 12:53 | ravster | how do I get a number from a string (Egs. 123.456) that does not necessarily have the ".456" part? |
| 12:55 | arrdem | ravster: well depends on the type of number you think you're trying to read. |
| 12:55 | bbloom | ,(Double/parseDouble "123.456") |
| 12:55 | clojurebot | 123.456 |
| 12:55 | bbloom | ,(int (Double/parseDouble "123.456")) |
| 12:55 | clojurebot | 123 |
| 12:56 | arrdem | bbloom beat me to i |
| 12:56 | arrdem | *it |
| 12:56 | arrdem | one could also &(read-string "123.456") |
| 12:57 | arrdem | in which case you will get Integer, Long or Double as the Clojure reader sees fit |
| 12:57 | bbloom | arrdem: i didn't suggest that b/c when parsing numbers like this, it tends to be from config files & the like, which read-string isn't secure enough for :-P |
| 12:57 | bbloom | but i guess now we have clojure.edn/read-string |
| 12:57 | arrdem | bbloom: where did I say it was a good idea XP |
| 12:58 | ravster | arrdem: I'm hopingto get routing in a compojure route with a number in it. The problem is that I can't just do :latitude since compojure splits on '/' and '.' |
| 12:59 | arrdem | ravster: can't you just require that a client urlencode those characters? |
| 12:59 | arrdem | . and / should both be taken care of by that.. |
| 12:59 | xumingmingv | Raynes: I'am planning to host a chinese version of http://tryclj.com, is that OK? |
| 13:00 | ravster | arrdem: huh. didn't think of that option. Good idea. thanks. |
| 13:02 | ravster | aarrghh . '.' is an unreserved character |
| 13:03 | ravster | oh nvm. I don't know what I'm talking about. |
| 13:03 | arrdem | lulz |
| 13:04 | arrdem | $version |
| 13:04 | arrdem | $source |
| 13:04 | lazybot | Source not found. |
| 13:05 | arrdem | !source |
| 13:05 | ravster | now I need to figure out how compojure does urlencoding. |
| 13:06 | arrdem | ravster: I believe that it splits as you were saying, then un-urlencodes the split substrings |
| 13:06 | hyPiRion | what are you trying to do arrdem? |
| 13:06 | hyPiRion | ,*clojure-version* ;? |
| 13:06 | clojurebot | {:major 1, :minor 5, :incremental 0, :qualifier "RC6"} |
| 13:06 | hyPiRion | $google clojurebot |
| 13:06 | lazybot | [hiredman/clojurebot · GitHub] https://github.com/hiredman/clojurebot |
| 13:06 | arrdem | hyPiRion: just trying to figure out which clojurebot github repo I need to be patching for thanks messages |
| 13:07 | hyPiRion | ah |
| 13:07 | arrdem | looks like hiredman's is the only active one tho |
| 13:07 | hyPiRion | yeah, that's the one |
| 13:13 | ryankask | hi. i'm trying to set up a test fixture that wraps the test function in a jdbc transaction and rolls it back after executing the test function. how can I do the roll back without raising an exception? the exception causes the tests not to run |
| 13:20 | llambda | hi all, i have a question about sharing functions between namespaces...is it all right to ask here? |
| 13:20 | tgoossens | I need some help |
| 13:20 | tgoossens | * |
| 13:20 | rodnaph_ | does anyone have any experience with storage/query for n-dimensional datasets? (not exactly clojure related i know but i couldn't think of another place to ask!) |
| 13:20 | tgoossens | (sorry accidently hit enter :)) |
| 13:20 | arrdem | !anyone |
| 13:21 | hyPiRion | ~anyone |
| 13:21 | 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 ..." |
| 13:21 | arrdem | (inc hyPiRion) |
| 13:21 | lazybot | ⇒ 13 |
| 13:21 | squidz | does anybody know how I can pass my sequence of nodes created by enfocus has html to my compojure routes? |
| 13:21 | tgoossens | i need some help with a presentation on "why clojure". http://lanyrd.com/2013/belgiumclj/scdtkk/ |
| 13:21 | arrdem | llambda: this is #clojure so I'd hope that clojure questions are welcome.. |
| 13:22 | tgoossens | Any tips advice on what i should tell |
| 13:22 | tgoossens | in what order, how detailed |
| 13:22 | llambda | arrdem: :) |
| 13:22 | llambda | i would like to share a set of functions between two separate namespaces. i'm having trouble articulating exactly what i'm trying to do i think, so i put together a simple gist: https://gist.github.com/maxcountryman/5228259 |
| 13:22 | tgoossens | its not a talk about "why you should use clojure" |
| 13:22 | tgoossens | but rather a "why it was created" |
| 13:23 | tgoossens | i need some starting point :p |
| 13:23 | rodnaph_ | squidz: i assume u just want to post the data, right? u can just .innerHTML of the topmost node maybe? |
| 13:23 | arrdem | tgoossens: start whith why java sucks and go from there..? |
| 13:23 | arrdem | or start with Lisp's awesome and sprinkle Java libraries on top? |
| 13:24 | llambda | basically what i want is to require the namespace where the functions are defined, in that example, baz.clj, and then have these functions be accessible in foo.clj when foo is required in a program, like: (require '[testing.foo :as foo]) ... => (foo/qux "test") |
| 13:24 | tgoossens | arrdem: no :p |
| 13:24 | tgoossens | i was going to start with |
| 13:24 | tgoossens | "complexity |
| 13:24 | arrdem | llambda: yeah hang on there's a toolkit for this |
| 13:24 | tgoossens | from my perspective |
| 13:24 | llambda | thanks arrdem :) |
| 13:24 | tgoossens | almost all decisions in clojure are made based on "complexity" |
| 13:24 | arrdem | AHAH I remember what codebase it was in.. |
| 13:25 | llambda | i'm surprised this isn't a more common issue, so maybe i'm approaching DRY the wrong way here? |
| 13:25 | arrdem | llambda: https://github.com/ztellman/potemkin |
| 13:25 | arrdem | gimme karma XP |
| 13:26 | squidz | rodnaph_: okay, but im not sure how I can combine clojurescript with the normal clojure in my compojure code |
| 13:26 | rodnaph_ | i think you've lost me sorry squidz... clojurescript is in the browser, and clojure on the server, right? |
| 13:27 | squidz | rodnaph_: yes correct |
| 13:27 | SegFaultAX | You guys should watch "Whence Complexity?" by Michael Nygard from Conj 2012. It has absolutely nothing to do with Clojure but it's fantastically interesting. |
| 13:27 | rodnaph_ | so u need to pass some data (some HTML by the sounds of it) from the client to the server? |
| 13:27 | squidz | and my i'm trying to figure out how I can use clojurescript to render different html pages when all the javascript is thrown into one file |
| 13:27 | llambda | arrdem: so there's no way to do this in vanilla clojure? i'll need to pull in this library it seems like? |
| 13:28 | arrdem | llambda: I don't know enough about how Clojure handles namespaces to really answer that question.. some code in clojure.core actually calls the "load" fuction to eval other code in the current namespace, but that seems to be a really shitty idea |
| 13:28 | llambda | yeah heh |
| 13:28 | squidz | rodnaph_: yeah I just dont know how to make multiple pages with clojurescript |
| 13:29 | llambda | i was going to try load but that seems like a hack |
| 13:29 | arrdem | llambda: yeah that's my sense too |
| 13:29 | llambda | in python this would "just work" as it were |
| 13:29 | squidz | rodnaph_: do you know what I mean? |
| 13:29 | llambda | so my expectations might be off |
| 13:29 | arrdem | you sure about that? |
| 13:29 | llambda | i may be doing it wrong |
| 13:29 | arrdem | I don't think you can pull that shit in Python |
| 13:29 | rodnaph_ | i think i do yes. enfocus seems to allow you to specify templates via remote data sources. |
| 13:30 | llambda | arrdem: if you import a module, it's accessible from that module, yeah |
| 13:30 | llambda | i mean, from the module you import it into |
| 13:30 | llambda | so if a library imports some other library, then you can access that other library from the first library directly |
| 13:31 | arrdem | okay sure... but if you have (in-ns a (import b)), (in-ns c (import b) (b/cc/foo)) |
| 13:31 | rodnaph_ | so you can (deftemplate some-tpl "templates/file.html" [] etc...) and the HTML will just get served from your app/server |
| 13:31 | rodnaph_ | i've not actually used this though, just looking at the docs. |
| 13:31 | rodnaph_ | so apologies if you've already been over this. |
| 13:32 | llambda | arrdem: i'm not sure how that translates to python |
| 13:32 | arrdem | llambda: it isn't valid clojure, but it's the same example you gave with different names. |
| 13:32 | squidz | rodnaph_: no, Im also not very sure. So ill try to make the html available on a route and see if it renders with enlive |
| 13:33 | arrdem | hyPiRion: thoughs here? how to refer symbols from required namespace into the current namespaces such that they are accessible by any user of the current namespace |
| 13:34 | rodnaph_ | squidz: it'll be easier to make the HTML available via a static resource (compojure.route.source "/templates") |
| 13:34 | llambda | arrdem: i think something like this in python would work --> https://gist.github.com/maxcountryman/5228620 |
| 13:34 | rodnaph_ | s/source/resources/ |
| 13:34 | stuartsierra | arrdem: Clojure does not support this directly. |
| 13:34 | arrdem | stuartsierra: that's what I suspected |
| 13:34 | arrdem | stuartsierra: but you should be able to hack it.. |
| 13:34 | llambda | hm so what's the idiomatic way of sharing functions like this? |
| 13:34 | stuartsierra | You can write a function that calls `refer` to get the symbols you want, and call that at the top of the namespace that needs them. |
| 13:35 | squidz | rodnaph_: yeah I have them available, I just havent tried it yet |
| 13:35 | llambda | is that considered a hack? |
| 13:35 | arrdem | stuartsierra, llambda hang on here I have a macro idea |
| 13:35 | stuartsierra | llambda: I do not consider calling `refer` to be a hack. Any other approach, such as re-def'ing vars in the target namespace, IS a hack. |
| 13:36 | llambda | yeah i do not want to re-def |
| 13:36 | llambda | that just looks ugly and seems unnecessary |
| 13:36 | arrdem | llambda: well that's the best you're gonna get |
| 13:36 | arrdem | and that's what Python is doing under the covers I suspect |
| 13:36 | stuartsierra | Namespaces are not "modules" in the Python sense. They're flat. |
| 13:37 | borkdude | hmm, some code that used to work in clojure 1.4 now gives me an clojure.lang.Numbers.throwIntOverflow - is this a known thing? |
| 13:39 | TimMc | muhoo: Should the return type be last? |
| 13:39 | borkdude | I didn't say anything (same result in 1.3, 1.4) |
| 13:40 | TimMc | muhoo: e.g. "pub st toOctalString : long -> String" |
| 13:41 | llambda | stuartsierra: what would that refer function look like for the simple example i posted? |
| 13:41 | arrdem | llambda: almost have one working hang on |
| 13:41 | clojurebot | excusez-moi |
| 13:41 | stuartsierra | llambda: Just define a function that calls `refer`. |
| 13:42 | llambda | i think i did that |
| 13:42 | stuartsierra | Then call it. |
| 13:42 | llambda | but it doesn't seem to expose the vars like i'm expecting |
| 13:42 | llambda | (foo/qux) doesn't work |
| 13:43 | borkdude | (using +' instead of + worked) |
| 13:46 | stuartsierra | llambda: If you want prefixed symbols then use `alias` instead of `refer`. |
| 13:46 | stuartsierra | But really, all this is just making extra work for yourself. |
| 13:47 | stuartsierra | Just `:require` the other namespace where you want to use it. |
| 13:47 | llambda | :require what exactly? i want to :require foo and then have access to everything foo in turns require, ideally |
| 13:48 | stuartsierra | You can't have that. :) |
| 13:48 | llambda | :( |
| 13:48 | danlarkin | not only can't you have it, you don't actually want that |
| 13:48 | llambda | i want to share a common set of functions |
| 13:48 | llambda | as if they were written twice |
| 13:48 | llambda | without writing them twice |
| 13:48 | stuartsierra | Why? |
| 13:48 | clojurebot | why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone |
| 13:48 | llambda | this seems like DRY 101 :) |
| 13:48 | danlarkin | so put them in myproject.utils? |
| 13:48 | llambda | because the functions are identical |
| 13:49 | tgoossens | does someone know a lisp that is OO? |
| 13:49 | llambda | but they're needed in two separate namesapces |
| 13:49 | danlarkin | so require myproject.utils from two namespaces |
| 13:49 | arrdem | (inc danlarkin) |
| 13:49 | lazybot | ⇒ 1 |
| 13:49 | llambda | okay but then they aren't exposed for programs requiring myproject.foo |
| 13:50 | stuartsierra | That's a feature. :) |
| 13:50 | arrdem | yeah so? |
| 13:50 | arrdem | make someone else require foo.util too |
| 13:50 | arrdem | nbd |
| 13:50 | danlarkin | this is literally the purpose of namespaces |
| 13:50 | danlarkin | ... to namespace functions |
| 13:50 | llambda | that's not ideal for how i've written this api... |
| 13:50 | jtoy_ | can anyine tell me why this error wouldnt be caught? https://www.refheap.com/paste/12864 |
| 13:50 | jtoy_ | im sure its something simple, but i dont see what im missing |
| 13:50 | llambda | i'd like to have client-a and client-b and then have the caller use them like this: (client-a/post ...) |
| 13:51 | llambda | (cleint-b/post ...) |
| 13:51 | jtoy_ | do i need to do something special with java exceptions? as opposed to clojure exceptions? |
| 13:51 | arrdem | jtoy_: no |
| 13:52 | jtoy_ | am i doing something wrong? |
| 13:52 | llambda | the client-a and client-b namespaces define a function "request" that differs, but the wrappers for that function, get, post, ... are identical |
| 13:53 | tgoossens | in the clojure rationale, what is meant with "heterogeneous collections" ? |
| 13:53 | arrdem | jtoy_: weird.. you seem to be doing it right |
| 13:53 | headshot | tgoossens: contains different things |
| 13:53 | tgoossens | ok |
| 13:54 | tgoossens | thanks |
| 13:54 | tgoossens | in contrast with List<Type> then |
| 13:54 | stuartsierra | jtoy_: Try catching Throwable instead of Exception. |
| 13:54 | headshot | yes |
| 13:54 | tgoossens | great thanks :) |
| 13:55 | jtoy_ | weird, that doesnt work either |
| 13:58 | jtoy_ | that was ther error, Throwable, never heard of this before |
| 13:58 | yogthos | borkdude: yeah pretty excited about that :) |
| 13:59 | danlarkin | jtoy_: it means you're getting an Error, not an Exception |
| 14:00 | yogthos | danlarkin: hey so looks like html escaping is in? :) |
| 14:00 | jtoy_ | uh, ok |
| 14:00 | yogthos | danlarkin: as a feature I mean :) |
| 14:00 | danlarkin | yogthos: I'm working on it yeah |
| 14:00 | yogthos | danlarkin: awesome! :) |
| 14:00 | yogthos | danlarkin: sorry my version was halfassed :) |
| 14:01 | yogthos | danlarkin: I think using maps instead of strings will definitely be nice though, that way you can pass around all kinds of metadata |
| 14:01 | jtoy_ | must be a java thing? |
| 14:02 | arrdem | jtoy_: in the worst case I suppose you could catch Object XP |
| 14:02 | danlarkin | jtoy_: http://stackoverflow.com/questions/912334/differences-betweeen-exception-and-error |
| 14:02 | Glenjamin | llambda: in myproject.utils, define a macro that creates the get/post/etc |
| 14:02 | Glenjamin | and then call that macro in client-a and client-b |
| 14:03 | Glenjamin | or juggle it around so its (app/post client-a …) |
| 14:04 | jtoy_ | will Throwable also catch Exception? |
| 14:04 | gfredericks | yes |
| 14:04 | gfredericks | because Exception implements Throwable |
| 14:04 | danlarkin | jtoy_: yes, but you almost certainly shouldn't be catching Throwable |
| 14:04 | danlarkin | something is probably going wrong somewhere |
| 14:04 | bbloom | ,(instance? Throwable (Exception.)) |
| 14:04 | danlarkin | json parsing shouldn't throw an Error |
| 14:04 | clojurebot | true |
| 14:04 | jtoy_ | i just want to print out my message and rethrow it |
| 14:05 | llambda | Glenjamin: first option sounds pretty good :) |
| 14:05 | Glenjamin | mm, thats probably how i'd do it |
| 14:06 | arrdem | llambda: https://www.refheap.com/paste/12865 challenge completed. should work but not general and it's the redef hack. |
| 14:06 | gfredericks | oh throwable is a class |
| 14:13 | TimMc | muhoo: I'll do some doc work (changelog, etc.) and I can get a release out today, I think. |
| 14:14 | TimMc | Signed, too! |
| 14:14 | dsabanin | hi guys |
| 14:14 | dsabanin | how do I import leningen 2 project into eclipse? |
| 14:14 | dsabanin | since lein-eclipse is deprecated, what's the official way? |
| 14:15 | llambda | arrdem: thanks, i'll play around with this |
| 14:18 | arrdem | llambda: seriously tho, please rethink your API rather than use that piece of garbage. I think that Glenjamin's #2 where he proposed that clien1 and client2 be configurations for a more general client is much more elegant than anything you could get with that hack. |
| 14:18 | arrdem | that said your code not mine. |
| 14:18 | xeqi | dsabanin: there might be something in https://code.google.com/p/counterclockwise/ that could help |
| 14:19 | Glenjamin | (using client1 (api/get …) (api/post …)) might be a decent approach too |
| 14:24 | llambda | because i'm wrapping clj-http it'd be nice to retain the client/get client/post api |
| 15:04 | Raynes | arrdem: https://www.refheap.com/paste/12865 |
| 15:04 | Raynes | Is this some kind of alias thing? |
| 15:04 | Raynes | This is horrifying. |
| 15:06 | gfredericks | Raynes: do you periodically check /pastes just in case something is horrifying? |
| 15:06 | Raynes | Yes. |
| 15:07 | gfredericks | now I see why you made refheap |
| 15:08 | arrdem | lol |
| 15:08 | arrdem | yes it's horifying |
| 15:08 | arrdem | llambda didn't seem to understand that |
| 15:13 | arrdem | Raynes: I told llambda to use potemkin but apparently libraries are hard. |
| 15:14 | bbloom | this python __all__ style topic seems to come up regularly :-P |
| 15:14 | Raynes | Ugh, potemkin. |
| 15:14 | arrdem | Raynes: although now that I'm reading it potemkin does this more metadata |
| 15:14 | callenbot | danlarkin: I love you. |
| 15:15 | bbloom | generally, i've managed to talk myself out of a lot of bad ideas that i've gotten stuck into my brain from past languages, but i regularly find myself wanting to decompose namespaces while preserving usage interfaces |
| 15:15 | jtoy_ | if i have a method that just reads a file and returns its content, how should I define it in terms of with def/defonce,? I use def now and when I use load it takes too long because it seems to laod the file, i want the file loading to only happen once when the method is called |
| 15:15 | jtoy_ | is there a way to achieve this? |
| 15:15 | bbloom | jtoy_: try a delay |
| 15:16 | bbloom | ,@(delay 5) |
| 15:16 | clojurebot | 5 |
| 15:16 | llambda | i think i'm just going to rewrite this so there's a single "client" namespace defining these functions which you then pass a service into, like Glenjamin's suggestion |
| 15:17 | llambda | it means you'll have to require two namespaces, at least, but maybe that's not terrible |
| 15:17 | jtoy_ | bbloom: ok, ill try that,is the file supposed to be read though? |
| 15:17 | jtoy_ | in the first place i mean? |
| 15:18 | bbloom | jtoy_: i'm not 100% sure what you're saying you're doing, but it sounds fishy to me :-P |
| 15:18 | bbloom | jtoy_: generally, you should avoid doing heavy duty work on startup or file load |
| 15:18 | clojurebot | profiles in clj-http is https://gist.github.com/1846759 an example of the profiles feature in Leiningen 2 |
| 15:18 | arrdem | llambda: ^ |
| 15:18 | bbloom | jtoy_: instead, parameterize with arguments & make loading of config files etc explicit during setup |
| 15:19 | jtoy_ | bbloom: i have a bunch of these kinds of definitions: https://www.refheap.com/paste/12869 my code is much slower with these definitions in code |
| 15:19 | bbloom | jtoy_: quick fix: wrap the with-open call in a delay call |
| 15:19 | bbloom | jtoy_: then add @ at each reference |
| 15:19 | llambda | i'm not sure what you're pointing to, arrdem :) |
| 15:19 | bbloom | jtoy_: but better yet: stop doing this :-P |
| 15:20 | bbloom | jtoy_: make that into a load-males function & then use explicit arguments where males is needed |
| 15:20 | jtoy_ | bbloom: ok, what is the better way to do this? I have tons of files I need to read in to build my models |
| 15:20 | bbloom | jtoy_: you can aggregate all these files into a map |
| 15:21 | bbloom | (defn thing-that-uses-lots-of-files [file-map] ...) |
| 15:21 | bbloom | and file-map can be {:males [...] :females [...]} etc |
| 15:22 | jtoy_ | bbloom: ok, im going to test this |
| 15:26 | arrdem | llambda: clojurebot's clj-http profiles comment |
| 15:27 | llambda | what about it? |
| 15:29 | whilo | cemeric__: ping |
| 15:29 | arrdem | if you define a (with) form and your client1/client2 values, then profiles may be the minimum thing for you to wrap for your api |
| 15:29 | cemerick | man, what a mangling |
| 15:29 | cemerick | whilo: what's up? |
| 15:31 | whilo | cemerick: if i add the piggieback dependency to the basic c2-demo (not actually using it) i get a weird compiler backtrace |
| 15:31 | whilo | take the hello-bars sample from here https://github.com/lynaghk/c2-demos |
| 15:31 | whilo | add the piggieback dependency like this: http://pastebin.com/eW6NUR6B |
| 15:32 | whilo | clojure.lang.ExceptionInfo: Assert failed: :as alias must be unique; offending spec: [cljs.repl :as repl] |
| 15:32 | whilo | (not (contains? (alias-type (clojure.core/deref aliases)) alias)) at line 1 src/cljs/hello_bars/core.cljs |
| 15:33 | whilo | not sure what it is, maybe my fault, it still takes me time to wrap my head around clojurescript compilation problems |
| 15:36 | powr-toc | Hey, has anyone managed to get penumbra/opengl going with a recent clojure? 1.4/1.5? |
| 15:38 | arrdem | so yesterday I banged out multimethod +, -, / and * just for grins, and now I'm contemplating how extending them could go wrong. Is this expected for multimethods and protocols? |
| 15:52 | arrdem | herm... at what point is it "kosher" to use core. for a library? |
| 15:53 | amalloy | arrdem: when rich tells you to |
| 15:53 | arrdem | amalloy: yep, sounds about right |
| 15:57 | whilo | cemerick: can u reproduce? |
| 15:58 | jasonjckn | powr-toc: no |
| 15:59 | jasonjckn | powr-toc: it's no longer maintained, too bad, the author is siad he's working on cljs opengl lib |
| 15:59 | cemerick | whilo: are you in irc via SMS or something? :-P |
| 15:59 | cemerick | whilo: the src/cljs/hello_bars/core.cljs has two repl aliases |
| 16:01 | ztellman | powr-toc: no, but patches/new ownership welcome |
| 16:01 | ztellman | also, the webgl/cljs thing is probably not going to happen in the short term |
| 16:02 | danlarkin | you've got too many projects as-is :) |
| 16:08 | whilo | cemerick: why via SMS? right, but the sample works without the dependency. i can also push my playground project, which doesn't have this core.cljs file with two repl definitions |
| 16:08 | cemerick | whilo: was just giving you a hard time about the 'u' :-) |
| 16:09 | tieTYT2 | i have a map of maps, and I want to get the value of one of the nested keys. What's an idomatic way of doing this in clojure? |
| 16:09 | whilo | oh, ok. :-) |
| 16:09 | tieTYT2 | nested keys = nested maps |
| 16:09 | cemerick | whilo: *does* the core.cljs file have two repl aliases? |
| 16:11 | arrdem | ,(-> {:foo {:bar {: baz 3 }}} :foo :bar :baz) |
| 16:11 | clojurebot | #<RuntimeException java.lang.RuntimeException: Invalid token: :> |
| 16:11 | arrdem | what the |
| 16:12 | xeqi | the space between : and baz |
| 16:12 | arrdem | thankx xe |
| 16:12 | arrdem | ,(-> {:foo {:bar {:baz 3 }}} :foo :bar :baz) |
| 16:12 | clojurebot | 3 |
| 16:12 | tieTYT2 | nice, that's pretty cool |
| 16:12 | arrdem | hah. tieTYT2 that or get-in |
| 16:13 | arrdem | ,(get-in {:foo {:bar {:baz 3 }}} [:foo :bar :baz]) |
| 16:13 | clojurebot | 3 |
| 16:13 | tieTYT2 | nice |
| 16:13 | tieTYT2 | i like the latter becaus I can understand the documentation of it better :P |
| 16:14 | arrdem | yeah... get-in is a little clearer here. |
| 16:14 | tieTYT2 | thanks for the help |
| 16:14 | arrdem | but -> is for badasses so XP |
| 16:14 | tieTYT2 | when i learn clojure better i'll start using it |
| 16:15 | hyPiRion | get-in is preferable. |
| 16:15 | tieTYT2 | i'm glad I asked because I was doing this with deconstruction: (defn post-map-to-string [{{{post-link :href} :attr} :post-link, image-links :image-links} post-map] ... |
| 16:15 | Okasu | ,(get-in {:foo {:bar {:baz 3 }}} '(:foo :bar :baz)[]) |
| 16:15 | clojurebot | 3 |
| 16:15 | xeqi | * destructuring |
| 16:15 | tieTYT2 | my mistake |
| 16:16 | hyPiRion | ,(-> {:a {:b {:c 10}}} (assoc-in [:a :d] 10) (update-in [:a :b :c] * 2)) |
| 16:16 | clojurebot | {:a {:d 10, :b {:c 20}}} |
| 16:17 | Okasu | ,(get-in {:foo {:bar {:baz 3 }}} ,'(,:foo ,:bar, ,:baz,)[]) |
| 16:17 | clojurebot | 3 |
| 16:19 | bbloom | i disagree that get-in is preferable... i think it's only preferable when the key path is a parameter |
| 16:19 | bbloom | otherwise, -> allows for easier injection of function calls and debug print statements |
| 16:20 | hyPiRion | ,(get-in [[:a :b] [:c [:d :e]]] [1 1 0]) |
| 16:20 | clojurebot | :d |
| 16:20 | hyPiRion | ,(-> [[:a :b] [:c [:d :e]]] 1 1 0) |
| 16:20 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 16:20 | hyPiRion | get-in should be used to lookup data, not modify it |
| 16:20 | arrdem | aaand this is why I lurk #clojure. That and yall answer some stupid questions for me XP |
| 16:21 | amalloy | can't we all just get along? let's use -> and get-in both |
| 16:21 | amalloy | (-> m (get-in [1 1 0])) |
| 16:22 | bbloom | amalloy: surely you need an eval or two in there |
| 16:22 | arrdem | amalloy: I'd suggest partial but then you need two more parens |
| 16:23 | amalloy | seriously though, that's the way i use -> most often: when functions' argument order is inconvenient. eg, suppose that m were some non-trivial expression here: (get-in (fsdokfjsfklne eif#ef #*ernfe(earf#r#t) [1 1 0]), and by the time you get to the second arg you've forgotten you're in the middle of get-in |
| 16:23 | oskarth | 'lein new pedestal-service foo' gives error java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil. Using lein2. Ideas? |
| 16:26 | whilo | cemerick: nope. this is the actual code i have problem with piggieback in: https://github.com/ghubber/example/blob/master/src-cljs/konvex/hello.cljs |
| 16:26 | whilo | see the comment at the top, either i take unify out or piggieback dependency from project.clj and it will build |
| 16:29 | cemerick | whilo: not sure what to say; the error message is talking about a src/cljs/hello_bars/core.cljs file |
| 16:30 | cemerick | I don't know how piggieback would affect that at all... |
| 16:30 | whilo | i tried to reproduce with the hello_bars example, but if this is a mistake in the original example code (having repl defined twice), then it is probably a different problem |
| 16:33 | whilo | i didn't want to push my messy code for it, but this where c2 and piggieback make my build explode with a compilation error like this: http://pastebin.com/nhUSDzJb |
| 16:35 | whilo | can i do something else to help pin it down? |
| 16:35 | arrdem | any comment on why core.matrix doesn't use multimethod +, -, * and /? https://github.com/mikera/matrix-api/blob/master/src/main/clojure/clojure/core/matrix/operators.clj |
| 16:35 | oskarth | Nevermind my earlier question - my lein profile defaulted to the wrong version of clojure :) |
| 16:36 | whilo | cemerick: me neither but excluding piggieback from project.clj fixes the error. maybe it is a bug in c2 |
| 16:36 | amalloy | multimethods are slow, and i imagine core.matrix is performance-oriented |
| 16:37 | arrdem | amalloy: really? for type dispatch? |
| 16:40 | hyPiRion | arrdem: yes, use protocols instead |
| 16:42 | tomoj | seems like if you're calling generic + in an inner loop in some matrix stuff, you already lost? |
| 16:42 | cemerick | whilo: sorry, I'm not set up to dig into this at the moment. Maybe post to the clojurescript list? |
| 16:42 | whilo | ok |
| 16:43 | whilo | thx anyway! |
| 16:56 | sshack | There aren't any libraries for receiving email, are there? (I can find plenty for sending it, but I'd like my app to be able to receive and process it) |
| 16:57 | arrdem | sshack: you'll need to find a java smtp servlet probably.. not sure if one exists |
| 16:57 | arrdem | I'd be amazed if a Clojure one does |
| 16:57 | sshack | What about reading mailbox files or mailspool? |
| 16:57 | TimMc | sshack: https://github.com/timmc/hashflash This shitty little thing I wrote receives email and also sends. |
| 16:58 | sshack | TimMc: ahh. Cool. |
| 16:59 | arrdem | (inc TimMc) ;; a little bit impressed |
| 16:59 | lazybot | ⇒ 35 |
| 16:59 | arrdem | $karma technomancy |
| 16:59 | lazybot | technomancy has karma 48. |
| 17:00 | TimMc | arrdem: You won't be impressed once you've read the source. |
| 17:00 | arrdem | TimMc: java wrapper? |
| 17:00 | arrdem | or just a mess |
| 17:01 | TimMc | Well... it's very specific to GMail, there's no rate-limiting, and it's just generally not very robust. |
| 17:01 | akhudek | This is very cool: http://javolution.org/core-java/target/apidocs/javolution/text/Text.html |
| 17:01 | arrdem | closeenough.jpg |
| 17:01 | tomoj | it geocodes your email and sends you a geohash as in geohash.org? |
| 17:02 | arrdem | tomoj: wat |
| 17:02 | TimMc | tomoj: No, geohashing, the sport. |
| 17:02 | tomoj | ah, makes more sense :) |
| 17:03 | TimMc | You tell it a location and date and it tells you the coordinates. It's an email autoresponder, but you can text it if your cell provider has an SMS<->email gateway. |
| 17:03 | arrdem | tomoj: that's cool, didn't know ascii-printable geohashing was a thing. |
| 17:06 | tomoj | arrdem: http://geohash.gofreerange.com/ is better to look at than geohash.org if you don't already know geohash |
| 17:07 | arrdem | tomoj: ascii of the bitwise merge of the two doubles? |
| 17:11 | tomoj | yeah |
| 17:11 | tomoj | in base 32 so you have 3+2 or 2+3 bits per char |
| 17:23 | ed_g | given a function (defn foo [a &rest [b]] (let [b (or b 'default-b)] (list a b))) is there a cleaner way to give b an default argument similar to the CL (defun foo (a &optional (b 'default-b)) (list a b)) |
| 17:24 | arrdem | blergh. make foo vardic with the missing argument case recursive |
| 17:24 | arrdem | (defn foo ([ x y ] (+ x y)) ([x] (foo x 1))) |
| 17:25 | arrdem | ed_g: does that make sense? |
| 17:25 | ed_g | arrdem: thanks! :-) that's what I'm doing now, just wasn't sure if there was another idiom |
| 17:28 | jtoy_ | can I create methods that generate def methods that all bind to root? so i call my_method that does "def foo.." "def bar..." ? |
| 17:28 | ed_g | jtoy_: create a fn and then give it a name using intern |
| 17:30 | jtoy_ | I have to know the namespace? or can it know to bind to the current namespace? |
| 17:31 | arrdem | jtoy_: erm.. not sure how to get the invocation namespace but if you use a macro rather than a fn then all interns are local by default. |
| 17:34 | jjttjj | what are people's opinion on laser vs enlive these days |
| 17:37 | jtoy_ | arrdem: *ns* i think |
| 17:38 | arrdem | jtoy_: probably.. I'm not very familiar with the global earmuf values |
| 17:39 | edw | jjttjj: Given that it takes like thirty seconds to grok laser and…I do not know how long to grok enlive, I'd vote for laser. |
| 17:40 | edw | I mean, enlive seems to require consistent and heavy Kool-aid drinking to sustain proficiency. It's like D3.js that way. |
| 17:42 | tomoj | hmm, when I upgrade clojure to 1.6.0-master-SNAPSHOT, swank explodes, but 1.5.1 works fine |
| 17:42 | tomoj | even though there are no changes in 1.6.0-master-SNAPSHOT |
| 17:43 | danneu | what's the #1 intended usecase for enlive/laser? i've used hiccup to generate html and enlive for scraping. but their READMEs just mention "html transformation". |
| 17:43 | jjttjj | danneu: html templating |
| 17:49 | tomoj | guess something was stale |
| 17:56 | devn | tomoj: Whoa, so swank-clojure works with 1.5.1 now? |
| 17:56 | devn | tomoj: That wasn't the case a few months back. |
| 17:57 | tomoj | lein-swank 1.4.5, released 26 Dec, fixed the 1.5 problems I think |
| 17:57 | devn | tomoj: nice. I like nrepl, but swank is still way more complete |
| 17:58 | arrdem | does defrecord not support vardics? this doesn't seem to be working for me... https://www.refheap.com/paste/12873 |
| 18:02 | bbloom | arrdem: protocols don't support variadics at all |
| 18:02 | bbloom | arrdem: you're creating an argument with the name '& |
| 18:03 | bbloom | arrdem: the common pattern is to define protocol names like -foo with the leading dash to suggest that it's an implementation detail, then you define a corresponding foo fn that calls -foo |
| 18:03 | bbloom | arrdem: in this case, you can write (defprotocol IAddable (-add [this]) (-add [this x])) |
| 18:03 | bbloom | arrdem: and then you can define the variadic version generally, so that anything IAddable will get it for free |
| 18:04 | bbloom | otherwise, every implementer of IAddable would need to implement it the same each time |
| 18:04 | bbloom | side note: (. self val) can be (.val self) |
| 18:04 | arrdem | bbloom: hum... okay thanks for the info. |
| 18:05 | arrdem | and the (. self val) thing was deliberate for the record XP |
| 18:05 | bbloom | ,(macroexpand-1 '(.foo x)) |
| 18:05 | clojurebot | (. x foo) |
| 18:06 | bbloom | arrdem: they are equiv |
| 18:06 | arrdem | bbloom: so you would only define -add in the protocol and provide a general (add) which simply invokes the appropriate protocol fn recursively. |
| 18:06 | bbloom | yes |
| 18:06 | edw | danneu: You can read in an HTML template (as "plain old HTML") and modify it based on your model. So your designer or whoever can give you HTML and you don't need to modify it or teach them how to put {{things}} <%=in%> it. |
| 18:07 | bbloom | limit protocol usage for when you need fast, type-based, open dispatch |
| 18:07 | bbloom | however, you'll quickly find that single dispatch is insufficient for numeric applications, but i'll leave you to learn that one on your own :-) |
| 18:08 | arrdem | bbloom: single dispatch? |
| 18:08 | callenbot | danlarkin: <3 |
| 18:08 | arrdem | bbloom: I know that this is gonna be shit slow but I don't know what you mean by that. |
| 18:09 | danneu | edw: oh, i see. yeah, feeding in html makes sense to me when scraping but that makes sense now too |
| 18:10 | bbloom | arrdem: read the docs on multi-methods |
| 18:10 | arrdem | bbloom: oh. global map lookup. |
| 18:11 | bbloom | arrdem: ugh, not sure what you mean by that. but numerics are *hard*, bordering on impossible to model with protocols |
| 18:11 | bbloom | actually, maybe not even bordering |
| 18:11 | dnolen | arrdem: the issue is you really want it to be open, you have the problem that the other argument may not be one you know how to handle. Can maybe get around that with a coercion protoocl. |
| 18:11 | edw | It's nice, because you can have HTML that has representative content in it that simply gets replaced by your Clojure code. So you can have "<span class=price>$19.95</span>" instead of "<span class=price><%=(:price product)%></span>" in there. |
| 18:14 | arrdem | dnolen: yeah that's what I'm running into... the ENumber is existing code I already had but I want to wind up with an ISymbolic that is also IAddable and that's gonna be a mess. |
| 18:18 | bbloom | arrdem: you've discovered the Expression Problem :-) |
| 18:18 | bbloom | arrdem: http://en.wikipedia.org/wiki/Expression_problem |
| 18:19 | hiredman | I've played a little with generating something like Numbers.java from a database of information about the types, but it still isn't really open to extension |
| 18:20 | hiredman | https://github.com/hiredman/Archimedes/blob/master/src/Archimedes/bar.clj#L164 it is kind of neat |
| 18:20 | jtoy_ | if I only have the name of a function in a string, how do I eval it with args? this doesnt seem to work: (eval (read-string "+") 3 4) |
| 18:21 | jtoy_ | nor do i expect it to, but im not sure how to do it |
| 18:22 | Bronsa | ((resolve (read-string "+")) 3 4) |
| 18:23 | bbloom | or, more generally: @(resolve ...) |
| 18:23 | bbloom | however, this is a dubious thing to do.... |
| 18:24 | jtoy_ | thx |
| 18:24 | jtoy_ | bbloom: im implementing what we spoke about earlier |
| 18:25 | bbloom | jtoy_: i'm not sure how that involves symbol resolution.... |
| 18:26 | jtoy_ | bbloom: its always a little more complicated :) but specifically im reading in a bunch of files and some of them are parsed differently, so based of the filename i know which parser to use |
| 18:27 | jtoy_ | i hardcoded it before, but know i do it dynamically |
| 18:27 | tomoj | hiredman: why output java? |
| 18:27 | bbloom | jtoy_: a map of special-name-parts to functions will be 1) safer 2) simpler 3) more flexible |
| 18:28 | jtoy_ | bbloom: ok, let me try yours, i didnt think of it like that |
| 18:29 | jtoy_ | although you said that earlier |
| 18:29 | tomoj | oh, I guess using clojure instead of Numbers.java would be a c-in-c problem? |
| 18:31 | jtoy_ | bbloom: how do i pass the function around to be used? |
| 18:32 | bbloom | ,{"clj-parser" `read-string} |
| 18:32 | clojurebot | {"clj-parser" clojure.core/read-string} |
| 18:32 | bbloom | er rather without the ` |
| 18:34 | jtoy_ | bbloom: so calling it is the same way from earlier using @ or resolve? |
| 18:49 | TimMc | muhoo: https://clojars.org/org.timmc/handy/versions/1.5.0 :-D |
| 18:50 | TimMc | I can't push to github yet, though. |
| 18:50 | bbloom | jtoy_: ##((get {"add" +} "add") 5 10) |
| 18:50 | lazybot | ⇒ 15 |
| 18:51 | TimMc | Why would someone DDoS github? |
| 18:51 | TimMc | Like, what do they hope to gain? |
| 18:52 | bbloom | TimMc: might be DDosing someone hosted on github |
| 18:52 | bbloom | TimMc: or they could just be dicks. |
| 18:52 | bbloom | TimMc: a lot of people are just not very nice and have a crappy sense of humor |
| 18:54 | nightfly | So thats whats going on... thought it was shitty airport wifi |
| 18:58 | jtoy_ | such a shitty error for file doesnt exist: IllegalArgumentException No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil clojure.core/-cache-protocol-fn (core_deftype.clj:495) |
| 19:01 | ryanf | anyone have opinions about pedestal? |
| 19:01 | ryanf | is it polished enough to be worth trying to use for a clojure noob? |
| 19:06 | bttf | dont have much to say about pedestal but i thought the mobile versin of their website rocked |
| 19:07 | callenbot | ryanf: Clojure noobs should not be using Pedestal. |
| 19:07 | callenbot | ryanf: I would look into Luminus. |
| 19:08 | ryanf | callenbot: thanks |
| 19:09 | ryanf | oh um |
| 19:09 | ryanf | this blog post about luminus starts with "Since the retirement of Noir..." |
| 19:09 | ryanf | I didn't see anything on noir's website that made it look retired |
| 19:09 | callenbot | ryanf: Noir was retired. |
| 19:09 | callenbot | ryanf: Granger is very busy and hasn't had time to update the Noir site. |
| 19:09 | callenbot | ryanf: do not use Noir. |
| 19:09 | maio | jtoy_: (: I got that same error few hours ago ... yes it sucks hard |
| 19:09 | callenbot | ibdknox: please update/redirect the webnoir site. |
| 19:09 | ryanf | callenbot: thank you |
| 19:09 | callenbot | ibdknox: it's confusing noobs. |
| 19:10 | ryanf | callenbot: you are a very sophisticated bot btw. I'm impressed |
| 19:10 | callenbot | ryanf: yogthos is the brain trust behind Luminus, but I've hacked on it and use it from time to time. It has some good defaults for common-case stuff websites need. |
| 19:10 | ryanf | cool |
| 19:11 | callenbot | ryanf: pedestal has some cool stuff I might go ghoul on and rip out, but I'm not at present recommending it to anybody. I don't think it was made by people that actually have to hack up/on websites on a regular basis. |
| 19:12 | Raynes | All I can see about pedestal is that there is a pretty website with no information on it. |
| 19:13 | Raynes | *shrug* |
| 19:13 | Raynes | I'd rather see a README with sense making. |
| 19:13 | callenbot | Raynes: I was rummaging through the guts. Stinky offal. |
| 19:13 | callenbot | Raynes: lots of do-nothing silliness for hippies. |
| 19:14 | jtoy_ | bbloom: weird, your example works, but I cant get it to work in my code |
| 19:14 | bbloom | jtoy_: distill a minimal repo |
| 19:16 | Glenjamin | the noir deprecated thing caught me out two |
| 19:17 | Glenjamin | spent two evenings reading docs before i came across the announcement blog post |
| 19:23 | jtoy_ | bbloom: I tink this is my issue: ( (get {"fn" (read-string "+")} "fn" ) 5 10) what is wrong here? |
| 19:23 | bbloom | jtoy_: ##(class (read-string "+")) |
| 19:23 | lazybot | ⇒ clojure.lang.Symbol |
| 19:24 | jtoy_ | what should it be? it should return function? im not quite sure why its different from your example |
| 19:25 | bbloom | symbols implement IFn, so they are "callable", but they are not necessarily functions. you want the function that resides in the var with the symbol 'clojure.core/+ |
| 19:25 | bbloom | 'clojure.core/+ is a symbol |
| 19:25 | bbloom | #'clojure.core/+ is a var |
| 19:25 | bbloom | ,(resolve 'clojure.core/+) |
| 19:25 | clojurebot | #'clojure.core/+ |
| 19:25 | bbloom | ,(deref #'clojure.core/+) |
| 19:25 | clojurebot | #<core$_PLUS_ clojure.core$_PLUS_@131f3e1> |
| 19:26 | bbloom | deref == @ btw, |
| 19:26 | bbloom | ,@#'clojure.core/+ |
| 19:26 | clojurebot | #<core$_PLUS_ clojure.core$_PLUS_@131f3e1> |
| 19:26 | Glenjamin | so #' is the opposite of @? |
| 19:26 | bbloom | a symbol is a name, a var is a named place |
| 19:26 | bbloom | Glenjamin: no |
| 19:27 | bbloom | @ means deref, which means "get the current value at a given place" |
| 19:27 | bbloom | think of it like dereferencing a pointer in C, only it's a more powerful pointer that can implement arbitrary dereferencing logic |
| 19:27 | bbloom | vars are references, but so are delays, promises, atoms, agents, etc |
| 19:28 | Glenjamin | i see |
| 19:30 | kmicu | it turns blue |
| 19:40 | bosie_ | anyone got an idea how to calculate the 2 points where the radius of two center points are crossing? |
| 19:44 | amalloy | wikipedia, or http://math.stackexchange.com/ |
| 19:45 | danneu | bosie_: if you have equation of two circles, you equate them to eachother and find the values of the variables that make the expressions equivalent |
| 19:46 | bosie_ | amalloy: thought the intellectual crowd in here might know ;) |
| 19:46 | danneu | oh nevermind, you arent asking the 7th grade geometry question i thought you were |
| 19:46 | danneu | damn, thought i could finally answer a question in this channel |
| 19:46 | bosie_ | danneu: haha. dont give up quite yet ;) |
| 19:47 | ivan | http://mathworld.wolfram.com/Circle-CircleIntersection.html |
| 19:47 | bosie_ | ivan: ah, intersection. no wonder i didn't find anything |
| 19:48 | danneu | is this idiomatic clojure indentation https://gist.github.com/danneu/5154e5ef758a9eef2180 |
| 19:48 | bosie_ | thx ivan |
| 19:48 | danneu | "conventional" rather |
| 19:50 | powr-toc | danneu: looks ok to me |
| 19:50 | powr-toc | danneu: at least that's how emacs indents it :-) |
| 19:55 | bosie_ | ivan: that is a really neat trick. thx |
| 19:56 | ivan | np |
| 19:57 | tieTYT2 | i think i'm doing something wrong here: (defn post-map-to-html [{post-link :post-link image-links :image-links} post-map] (map #(post-and-image-to-html-link post-link %) image-links)) |
| 19:57 | tieTYT2 | when I call that function it says ArityException Wrong number of args (1) passed to: core$post-map-to-html clojure.lang.AFn.throwArity (AFn.java:437) |
| 19:57 | tieTYT2 | but i thought i'm defining a function here with one parameter that's a map and it gets destructured |
| 20:02 | amalloy | that function takes two args, and destructures the first |
| 20:02 | tieTYT2 | so I need to remove the post-map keyword? |
| 20:02 | tieTYT2 | err symbol |
| 20:03 | danneu | yeah |
| 20:03 | tieTYT2 | ok |
| 20:03 | tieTYT2 | i'm really confused because all the examples I see here seem to do what I did: http://blog.jayfields.com/2010/07/clojure-destructuring.html |
| 20:03 | tieTYT2 | oh right... he's using a let |
| 20:03 | tieTYT2 | ok I get it now, thanks |
| 20:04 | danneu | tieTYT2: btw shortcut for {a :a b :b} is {:keys [a b]} |
| 20:04 | tieTYT2 | ok thanks |
| 20:07 | tieTYT2 | how do I define a symbol to be the value of a function evaluation so that it doesn't evaluate over and over again each time I use the symbol? |
| 20:07 | tieTYT2 | (my function uses an http client) |
| 20:12 | jtoy_ | :( |
| 20:13 | _ft_ | tieTYT2, this may be useful: http://clojuredocs.org/clojure_core/clojure.core/memoize |
| 20:15 | amalloy | tieTYT2: you have described the primary feature of 'let |
| 20:25 | jtoy_ | can anyone help me get this metaprogrammign working: https://www.refheap.com/paste/12879 |
| 20:26 | jtoy_ | bbloom: im close, i read what you said, but not sure still how to do it properly |
| 20:30 | tieTYT2 | _ft_: sounds like memoize is for something that's referentially transparent, which my function isn't |
| 20:30 | tieTYT2 | amalloy: ok I'll use a let, I think I understand how |
| 20:35 | gfredericks | jtoy_: you want the effect to be as if (defn foo [] (+ 4 5))? |
| 20:36 | john2x | how do I use non-Datomic datastore with Pedestal? |
| 20:36 | bttf | if I have ((fn [x] (:foo x) {:foo "bar"}) ... is '(:foo x)' calling a function built into keywords ? |
| 20:37 | bttf | missing a parenthesis in there |
| 20:37 | amalloy | bttf: that's an odd way to phrase it, but basically correct |
| 20:37 | jtoy_ | gfredericks: yes |
| 20:38 | gfredericks | jtoy_: your third argument to intern could be (fn [] (bar (resolve (:extractor x)))) |
| 20:39 | bttf | i meant to say that it is calling a function that every keyword has by default .. how would phrase it amalloy ? |
| 20:39 | gfredericks | bttf: the keyword _is_ a function |
| 20:39 | amalloy | bttf: keywords don't have functions, they are functions |
| 20:39 | bttf | ah right |
| 20:45 | jtoy_ | gfredericks: like this? https://www.refheap.com/paste/12880 doesnt seem to work for me |
| 20:47 | gfredericks | jtoy_: ah, yeah because the extractor is a string |
| 20:47 | gfredericks | wrap it in a call to symbol to convert it before resolve |
| 20:48 | gfredericks | (-> x :extractor symbol resolve bar) would be a more readable version |
| 20:48 | amalloy | barf |
| 20:48 | jtoy_ | amalloy: useful |
| 20:49 | gfredericks | amalloy: the ruby people will never respect us if we can't learn to programmatically intern vars willy-nilly |
| 20:49 | jtoy_ | hah, im a metaprogramming ruby master :) |
| 20:49 | amalloy | gfredericks: i'm not even complaining about the interning (though i hate that too), just that awful arrow form. fewer parens doesn't mean more readability |
| 20:50 | gfredericks | amalloy: it's more the not-backwards part |
| 20:50 | Raynes | jtoy_: Which is equivalent to being the drunk that can piss the farthest. |
| 20:50 | amalloy | if i had to write something that macroexpands the same, i'd write maybe something like (bar (resolve (-> x :extractor symbol))) |
| 20:50 | jtoy_ | and I love metaprogramming in ruby, especially method_missing which clojure doesnt seem to have |
| 20:51 | gfredericks | yeah I wonder why rich forgot that |
| 20:51 | jtoy_ | Raynes: Its actually getting late for me and i started drinking already, im sure it will be fine once i look at it again tomorrow |
| 20:51 | Raynes | gfredericks: You'll learn this about amalloy: he pulls -> forms out of his ass and decides at random which ways look the best. You'll never win unless you have him write it for you in the first place and then agree with him. |
| 20:51 | gfredericks | Raynes: yeah I didn't see any way forward in the discussion |
| 20:53 | gfredericks | jtoy_: has somebody already told you that macros are used for 99% of clojure metaprogramming (rather than dynamically creating vars)? |
| 20:53 | jtoy_ | gfredericks: no, im open to try that, but i still want the vars to be created |
| 20:56 | gfredericks | jtoy_: what's the use case? |
| 21:10 | Glenjamin | is there a shorthand for defining a private macro? |
| 21:11 | gfredericks | no |
| 21:13 | hyPiRion | you have to make a macro for that |
| 21:13 | hyPiRion | heh. |
| 21:13 | Raynes | (defmacro ^:private foo [] ..) |
| 21:13 | hyPiRion | Raynes: I think he meant anonymous |
| 21:13 | Raynes | There should really not be any macros for it at all given the new ^ syntax. |
| 21:14 | Raynes | He didn't say anonymous. |
| 21:14 | amalloy | hyPiRion: wat. bet you a million dollars? |
| 21:14 | Raynes | He said nothing to remotely indicate anonymous, in fact. |
| 21:14 | Glenjamin | Raynes: ah, i tried that in the repo, but now realise i had a typo >.< |
| 21:14 | gfredericks | I bet all of you that he meant symbol macros |
| 21:14 | Glenjamin | ^:private is what i was after :) |
| 21:14 | Raynes | hyPiRion: Go to your room. |
| 21:15 | hyPiRion | I thought he meant something like Common Lisp's macrolet |
| 21:15 | tomoj | wat ##(map conj {:foo 3 :bar 4} [5 6]) |
| 21:15 | lazybot | ⇒ ([:foo 3 5] [:bar 4 6]) |
| 21:15 | hyPiRion | Raynes: I will |
| 21:16 | amalloy | tomoj: (seq {:foo 4 :bar 4}) makes it pretty obvious? |
| 21:16 | dnolen | tomoj: looks right to me. |
| 21:16 | Glenjamin | what does ## do? |
| 21:16 | Glenjamin | where is all of this stuff written down :( |
| 21:16 | dnolen | Glenjamin: eval sexp in lazybot |
| 21:16 | Glenjamin | oh, haha |
| 21:16 | tomoj | yes, it looks right, I just didn't know |
| 21:16 | Glenjamin | thought it was yet another reader macro |
| 21:16 | Raynes | I'm always baffled that people don't realize that immediately. :p |
| 21:16 | hyPiRion | Glenjamin: It's the same a &| (println 'foo) |&, but without an ending delimiter |
| 21:16 | lazybot | ⇒ foo nil |
| 21:16 | tomoj | I mean I didn't know map entries were IPersistentVector |
| 21:17 | hyPiRion | I think they are MapEntries. |
| 21:17 | amalloy | hyPiRion: yes, which are IPV |
| 21:17 | Raynes | Which are a lot like vectors. |
| 21:17 | tomoj | yes, that is what I meant by "map entry" |
| 21:17 | hyPiRion | ,(-> {:a :b} (find :a) class) |
| 21:17 | clojurebot | clojure.lang.MapEntry |
| 21:17 | Raynes | Yall's brains are gonna explode in unison now. |
| 21:18 | tomoj | that conj on a map expects a vector, not a map entry, and that map entries print as vectors both should have suggested that map entries were vectors, but I only realized it after noticing clojure.tools.macro use vector? to catch the map entry case |
| 21:19 | gfredericks | what's weird to me is that you can conj a map onto a map |
| 21:20 | hyPiRion | I think that's one of the weirder things, yeah. |
| 21:20 | Raynes | http://24.media.tumblr.com/tumblr_mbqg5q5V6l1riuh2bo1_400.gif |
| 21:20 | amalloy | it's weird because it's awful |
| 21:20 | hyPiRion | ,(map (partial conj {:a :b}) [[:c :d] {:c :d}]) |
| 21:20 | clojurebot | ({:c :d, :a :b} {:c :d, :a :b}) |
| 21:21 | Glenjamin | ,(conj {:a :b} [:c :d]) |
| 21:21 | clojurebot | {:c :d, :a :b} |
| 21:21 | Glenjamin | bah, beat me to it |
| 21:21 | gfredericks | ,(conj {:a :b} [1 2 3]) |
| 21:21 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Vector arg to map conj must be a pair> |
| 21:21 | hyPiRion | Well, the first one is an entry, the last one is the oddity. |
| 21:24 | tomoj | https://www.refheap.com/paste/eb652b8816d71997fa052e5db |
| 21:25 | tomoj | ..and (= (clojure.lang.MapEntry. :foo 1) [:foo 1]) |
| 21:25 | jjttjj | f |
| 21:26 | hyPiRion | ,(== 0.0M 0.00M) |
| 21:26 | clojurebot | false |
| 21:26 | hyPiRion | It's all these small funny things. |
| 21:27 | gfredericks | ,(= 0.0M 0.00M) |
| 21:27 | clojurebot | false |
| 21:27 | tomoj | I'd like a val? and val= such that (val= a b) implies, uh (val= (f a) (f b)) for 'pure' f? |
| 21:28 | tomoj | I think.. is that possible in clojure? |
| 21:29 | gfredericks | probably depends wth you mean by "pure" |
| 21:29 | tomoj | well I should have just left the scare-quotes off |
| 21:30 | amalloy | tomoj: certainly possible in a number of uninteresting ways |
| 21:30 | tomoj | but I guess that would basically be 'same type and =', which sucks |
| 21:30 | Glenjamin | if f is pure |
| 21:30 | Glenjamin | you can just call it :p |
| 21:30 | Glenjamin | by definition there are no ill effects |
| 21:31 | tomoj | f was supposed to be universally quantified |
| 21:32 | hyPiRion | Glenjamin: Well, you're kind of stuck if (f a) -> a', and (f a') -> a though. |
| 21:32 | amalloy | actually, the only val= i can think of for which this works is (constantly false) or (constantly true) |
| 21:32 | tomoj | obviously my requirements were not complete :) |
| 21:33 | tomoj | generally I'm just wondering how you reason about (= (f a) (f b)) given (= a b) |
| 21:33 | tomoj | ..and the types of a and b? |
| 21:34 | tomoj | I mean, conj is one landmine, given (and (= x1 x2) (vector? x1)), are there a bunch of landmines all over the place, or very few? |
| 21:36 | arrdem | bbloom: very well.... I think I have an idea for solving a subset of the expression problem. |
| 21:36 | amalloy | conj, pop, peek, class, seq?, vector?, empty...those are functions i can think of off the top of my head that will be landmines there |
| 21:36 | tomoj | well, given f #(conj m %), (and (= x1 x2) (every vector? x1)) |
| 21:36 | amalloy | get, find, contains?... |
| 21:37 | arrdem | ah contains? |
| 21:38 | tomoj | I guess it's better than only being able to ask = for same-typed values |
| 21:42 | tomoj | the equality partitions from clojure.data.diff help but still don't clear all mines, right? |
| 21:42 | tomoj | vector? etc being considered irrelevant.. |
| 22:02 | Glenjamin | is anyone aware of a clojure/java lib similar to https://github.com/jugyo/notify (cross platform desktop notifications) |
| 22:30 | yacin | if i have a string of a form e.g., "(1 2 3)", how can i convert it to the form? i.e. so it's like '(1 2 3) |
| 22:30 | yacin | and i can use the usual conj/first/etc. on it? |
| 22:32 | yacin | nvm, figured it out |
| 22:36 | danneu | yacin: what was it |
| 22:38 | yacin | ,(load-string "'(1 2 3)") |
| 22:38 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 22:38 | yacin | ah well that makes sense |
| 22:38 | yacin | but yeah, load-string |
| 22:39 | zakwilson | Is there a good way to get the last thing inserted with korma? |
| 22:40 | groovy2shoes | ,(read-string "(1 2 3)") |
| 22:40 | clojurebot | (1 2 3) |
| 22:40 | groovy2shoes | yacin ^ |
| 22:42 | yacin | thanks |
| 22:43 | groovy2shoes | yacin: even better to use read-string from clojure.edn if you're trying to read arbitrary strings |
| 22:44 | yacin | ah interesting. thanks again |
| 22:44 | groovy2shoes | yacin: http://clojure.github.com/clojure/clojure.edn-api.html (for reasons described in the comments here http://clojuredocs.org/clojure_core/clojure.core/read ) |
| 22:50 | danneu | how would i go about finding out what opts i can pass into slurp? http://clojuredocs.org/clojure_core/clojure.core/slurp |
| 22:51 | danneu | like the available `:encoding`s supported |
| 23:01 | tieTYT2 | i'm using windows 7 and cygwin. Every time I run "repl lein" it leaves behind a java.exe process and they just build up. Anyone know what's causing this? |
| 23:03 | tieTYT2 | i quit with ctrl+C |
| 23:03 | groovy2shoes | danneu: looks like the supported encodings are whatever encodings your JVM supports... I'd imagine Oracle's supports many |
| 23:03 | ivan | tieTYT2: perhaps mintty's inability to handle most windows programs properly |
| 23:03 | ivan | combined with lein's spawning of a second java |
| 23:05 | seangrove | clojurebot: ping |
| 23:05 | clojurebot | PONG! |
| 23:05 | seangrove | clojurebot: lastseen aphyr |
| 23:05 | clojurebot | Cool story bro. |
| 23:05 | seangrove | $seen aphyr |
| 23:05 | lazybot | aphyr was last seen talking on #riemann 6 hours and 20 minutes ago. |
| 23:07 | ivan | (I've seen a lot of mintty problems including child processes not getting killed, or mintty locking up, also with non-cygwin Python) |
| 23:07 | tieTYT2 | ivan: any suggestion to help with this? |
| 23:07 | tieTYT2 | if i could kill all java processes with a cygwin command that'd be enough for me |
| 23:07 | groovy2shoes | yeah, mintty has problems with non-Cygwin anything, in my experience |
| 23:08 | ivan | tieTYT2: install procps in the cygwin package list and use pkill to kill all the javas |
| 23:09 | tieTYT2 | ok thanks |
| 23:09 | ivan | alternatively use conhost instead of mintty and use clink to alleviate some of the conhost pain |
| 23:09 | ivan | more seriously linux |
| 23:10 | tieTYT2 | ok thanks |
| 23:11 | technomancy | tieTYT2: typically ctrl-d is the way you cleanly exit from a repl |
| 23:11 | technomancy | or (System/exit 0) |
| 23:12 | groovy2shoes | ctrl-z on Windows |
| 23:12 | groovy2shoes | even in mintty, when using stock Windows Java |
| 23:15 | groovy2shoes | technomancy: it's funny that I remember it now, but as soon as I try to leave a repl inside mintty, I try ctrl-d a couple times before I remember Windows is weird |
| 23:15 | groovy2shoes | old habits die hard |
| 23:16 | ivan | you could autohotkey that ;) |
| 23:16 | groovy2shoes | I'll look into it... I have a feeling my employer would frown on that... |