2014-07-31
| 00:00 | sritchie | odd; if I call a js function at the repl, I see the code printed out; |
| 00:00 | sritchie | but if I pr-str a call inside of an om protocol fn call, |
| 00:00 | clojurebot | Pardon? |
| 00:01 | sritchie | there seems to be a whole wrapper around it from cljs |
| 00:01 | sritchie | <function (data__68246__auto__,owner80568,var_args){ |
| 00:01 | sritchie | var p__80570 = null;if (arguments.length > 2) { |
| 00:01 | sritchie | p__80570 = cljs.core.array_seq(Array.prototype.slice.call(arguments, 2),0);} |
| 00:01 | sritchie | etc |
| 00:01 | sritchie | it calls a delegate: return users_typeahead__delegate.call(this,data__68246__auto__,owner80568,p__80570);}> |
| 00:01 | brehaut | sritchie: are you knee deep in the madness that is jquery plugins? |
| 00:02 | sritchie | brehaut: trying to get this damned typeahead module to work on an om text input field without rewriting everything |
| 00:02 | sritchie | brehaut: knee deep for sure |
| 00:02 | brehaut | sritchie: youch; im sorry to hear that. I fear you might be in a bit of a pickle; doesnt Om blitz a node if it wants to update it? |
| 00:03 | DomKM | sritchie: there's an om typeahead example. It doesn't use jquery but it might be helpful https://github.com/swannodette/om/blob/master/examples/typeahead/src/core.cljs |
| 00:03 | sritchie | yeah, that’s what I’m trying to figure out - the typeahead props stick around, so that’s fine, |
| 00:03 | sritchie | DomKM: yeah, that doesn’t use the twitter typeahead module |
| 00:03 | sritchie | which I’m depending on for its autocomplete engine, prefetching, etc |
| 00:04 | brehaut | sritchie: my experience with jquery plugins is that a lot of them do funny things stashing stuff in the elements (such as the object that represents all the JS shenanigans, or an ID to look up said object in a ‘map’) |
| 00:04 | sritchie | that’s what this one does for sure |
| 00:04 | sritchie | BUT, I got the google places autocomplete to work just fine, |
| 00:04 | sritchie | and it was doing similar manipulations |
| 00:04 | sritchie | so I have hope :) |
| 00:04 | brehaut | sritchie: what you might need to do is scrap all that nonsense out of the element and store it in your model somewhere, and then reattach it when you build the node? |
| 00:05 | sritchie | brehaut: nice, that’ll work if I hit that issue, and then just handle the events myself if those props need to change |
| 00:06 | brehaut | sritchie: im not sure about ‘nice’ ;) but yeah, that’s where i would look. that and a bottle of tequila |
| 00:06 | sritchie | brehaut: trust me, I’m HEAVILY caffeinated |
| 00:07 | sritchie | this way lies madness |
| 00:07 | brehaut | sritchie: a much more effective chemical |
| 00:07 | sritchie | I’ve been avoid the typeahead thing for days now… I went so far as to port ~half of the react-bootstrap library over to om |
| 00:07 | brehaut | sritchie: yeah; jquery developers seem to have decided that throwing out all the best practises of software dev is the ideal way forward |
| 00:07 | brehaut | coupling? sure! single namespace? sure! |
| 00:08 | brehaut | duck punching objects you down own? a double helping please! |
| 00:08 | sritchie | gotta draw in the ruby devs somehow |
| 00:08 | Jaood | sritchie: or just use JS! |
| 00:09 | justin_smith | (inc brehaut) |
| 00:09 | sritchie | Jaood: the typeahead + react integration problems aren’t due to cljs |
| 00:09 | justin_smith | for duck punching, I know you didn't invent it, but it delights me |
| 00:09 | brehaut | i did however invent duck wrapping (the term, not the behaviour)! |
| 00:10 | justin_smith | brehaut: turduckening is when you mix that with multiple inheritance |
| 00:10 | justin_smith | or something |
| 00:10 | brehaut | hah indeed |
| 00:25 | rhg135 | how do you get a var from a ns from it's symbol? |
| 00:26 | justin_smith | TEttinger: I only just now notice that Bort is a potential output of your name generator |
| 00:26 | TEttinger | bort! |
| 00:26 | trptcolin | (resolve ‘map) |
| 00:26 | trptcolin | ,(resolve ‘map) |
| 00:26 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ‘map in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 00:26 | TEttinger | ,(resolve 'map) |
| 00:26 | clojurebot | #'clojure.core/map |
| 00:26 | rhg135 | ,(resolve 'clojure.core) |
| 00:26 | clojurebot | #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.core> |
| 00:26 | justin_smith | TEttinger: as are words like Yes and Box |
| 00:26 | rhg135 | hmm |
| 00:27 | trptcolin | welp thanks autocorrect-to-weird-quote |
| 00:27 | rhg135 | i want the ns not a symbol from the ns |
| 00:27 | justin_smith | ,`map |
| 00:27 | clojurebot | clojure.core/map |
| 00:27 | justin_smith | rhg135: maybe you want ` |
| 00:27 | trptcolin | ,(doc ns-resolve) |
| 00:27 | clojurebot | "([ns sym] [ns env sym]); Returns the var or Class to which a symbol will be resolved in the namespace (unless found in the environment), else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace." |
| 00:27 | rhg135 | i want the ns's var though |
| 00:28 | justin_smith | ns's var? you mean the name of the ns? |
| 00:28 | rhg135 | where clojure attaches metadata |
| 00:28 | trptcolin | oh. that’s not a var |
| 00:29 | trptcolin | ,(the-ns 'clojure.core) |
| 00:29 | clojurebot | #<Namespace clojure.core> |
| 00:29 | rhg135 | yeah i hava the ns object |
| 00:29 | rhg135 | need the var |
| 00:30 | justin_smith | ,(meta (the-ns 'clojure.core)) |
| 00:30 | clojurebot | {:doc "Fundamental library of the Clojure language"} |
| 00:30 | rhg135 | hmm |
| 00:30 | justin_smith | ns holds vars, they are not in any var |
| 00:30 | rhg135 | weird |
| 00:30 | rhg135 | i didn't see any meta on mine |
| 00:30 | justin_smith | did you put any on it? |
| 00:31 | rhg135 | doesn't clojure put line numbers? |
| 00:32 | rhg135 | ,(meta *ns*) |
| 00:32 | clojurebot | nil |
| 00:32 | justin_smith | on vars |
| 00:32 | sm0ke | ,(vary-meta (the-ns 'clojure.core) assoc :doc "Foo") |
| 00:32 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.IObj> |
| 00:32 | rhg135 | ,(class *ns*) |
| 00:32 | clojurebot | clojure.lang.Namespace |
| 00:33 | sm0ke | ,(vary-meta 'clojure.core assoc :doc "Foo") |
| 00:33 | clojurebot | clojure.core |
| 00:36 | dbasch | golf time if anyone cares: compute the count of the numbers under one million for which the digits add to 42. Can you do less than 90 chars? |
| 00:37 | talios | TEttinger / technomancy - http://blog.sonatype.com/2014/07/ssl_connectivity_for_central |
| 00:38 | bbloom | $mail timsg i'll be around tomorrow, ping me again if you still need help |
| 00:38 | justin_smith | lazybot is not here |
| 00:39 | bbloom | damn lazy bot |
| 00:39 | TEttinger | interesting, talios |
| 00:39 | trptcolin | dbasch: 85 so far |
| 00:39 | justin_smith | sleeping on the job, I am sure |
| 00:39 | talios | 12. signups. |
| 00:39 | rhg135 | i must have missed it, it's working |
| 00:42 | trptcolin | oh whoops, nm, 93 |
| 00:43 | justin_smith | ,(count (filter (fn [n] (= 42 (reduce + (map #(Integer. (str %)) (str n))))) (range 1000000))) |
| 00:43 | clojurebot | 6062 |
| 00:44 | justin_smith | err, that % bothers me |
| 00:44 | justin_smith | oh, never mind |
| 00:44 | justin_smith | d'oh, bedtime |
| 00:48 | trptcolin | heh, 82 if you trim out whitespace doing things like (count(filter(fn[n](= 42 ... etc |
| 00:51 | technomancy | talios: urgh; this is fairly misleading |
| 00:51 | technomancy | "In 2012 we weren’t sure how many people not already running repository managers were interested in SSL access." |
| 00:51 | technomancy | this implies they were willing to give SSL access to people not running repository managers, which was not at all true |
| 00:52 | technomancy | I mean, very good news |
| 00:52 | technomancy | just a nitpick |
| 00:53 | trptcolin | snap, that was quick |
| 00:57 | talios | even if they had made it available to all, very few people would still be able to use it since noone actually tells maven to use http or https, or central. not without releasing a new version of maven and forcing everyone to upgrade ( of course, that should have been done anyway ) |
| 00:57 | technomancy | yeah, I would push out a new lein version within days of public non-preview access |
| 00:58 | talios | and then wait for masses complaining about how much slowwwwwweeeerrrrrr maven was ;p |
| 00:59 | technomancy | talios: also holy crap; only twelve requests =\ |
| 00:59 | technomancy | I'm fairly embarrassed that I didn't request it till this weekend tbh |
| 01:00 | talios | :) I didn't even know about it. I knew central moved to running nexus, but somehow I missed the SSL stuff |
| 01:00 | technomancy | but even though I requested it, I never got it actually working, because I need direct access, not nexus-mediated access |
| 01:00 | talios | and its not like sonatype made money out of it. hell - they're forking out $150k for central bandwidth. youch |
| 01:00 | talios | *nod* |
| 01:01 | talios | I wonder how big clojars is these days? |
| 01:01 | technomancy | I have 2-year-old numbers |
| 01:01 | technomancy | 100GB in a month I think? |
| 01:02 | talios | not bad. any idea of total static size? |
| 01:03 | technomancy | that's easier, hang on |
| 01:03 | technomancy | hah |
| 01:03 | technomancy | only 15GB |
| 01:04 | rhg135 | anybody know if there is a better way to write section* here https://www.refheap.com/88742 |
| 01:07 | talios | only 15? but sending out 100gb? youch - some folk need some caching :) |
| 01:08 | technomancy | talios: I'm sure a ton of that is CI stuff |
| 01:09 | talios | technomancy - which should *cough* come from a caching repo manager :) altho, clojars contains SNAPSHOTs of stuff doesn't it? |
| 01:09 | talios | or not |
| 01:09 | dbasch | ,(count(filter(fn[n](= 42(apply +(map #(Integer. (str %))(str n)))))(range 1e6))) ; justin_smith down to 80 |
| 01:09 | clojurebot | 6062 |
| 01:09 | technomancy | talios: I don't think travis caches anything |
| 01:10 | talios | technomancy - sadly. tho thats also part of its charm. its simple. |
| 01:10 | technomancy | talios: the s3 transfer for lein's uberjar (one single file) was 347GB in May |
| 01:11 | TEttinger | modified justin_smith's answer, 79: |
| 01:11 | TEttinger | ,(count(filter(fn[n](= 42(reduce +(map #(-(int %)48)(str n)))))(range 1000000))) |
| 01:11 | clojurebot | 6062 |
| 01:11 | technomancy | we got off S3 for 2.4.x, so it was 200 in june and so far only 160 in july, but ... yeah. |
| 01:11 | technomancy | lots of jiggabytes |
| 01:15 | technomancy | talios: also 15GB is today's number. 100GB traffic was on a much smaller repo. |
| 01:16 | technomancy | I'd get the latest traffic numbers if it weren't time for me to call it a night. |
| 01:16 | talios | yep - almost home time here too |
| 01:16 | gfredericks | trptcolin: thx |
| 01:17 | trptcolin | ;) |
| 01:18 | brehaut | talios: enjoy the traffic |
| 01:19 | talios | ? |
| 01:19 | brehaut | for your commute |
| 01:19 | talios | Only heading to Mt Eden - curry night :) |
| 01:19 | brehaut | isnt that what living in auckland is all about? |
| 01:19 | brehaut | haha |
| 01:19 | talios | so yes - about an hour ;P |
| 01:19 | brehaut | nice |
| 01:19 | talios | not. |
| 01:26 | dbasch | ,(count (filter #(= 42 %) (map (fn d [n] (if (> 10 n) n (+ (mod n 10) (d (quot n 10))))) (range 1e6)))) ; justin_smith longer but much faster |
| 01:26 | clojurebot | 6062 |
| 01:37 | TEttinger | ok, can anyone get shorter than 75? |
| 01:37 | TEttinger | ,(count(filter(fn[n](= 42(reduce +(map #(-(int %)48)(str n)))))(range 1e6))) |
| 01:37 | clojurebot | 6062 |
| 01:39 | trptcolin | TEttinger: substitute reduce -> apply |
| 01:39 | trptcolin | for 74 |
| 01:58 | TEttinger | hm, I'm thinking it may be possible to go under 74 using unquote-splicing |
| 02:00 | TEttinger | ,(count(filter(fn[n](=(apply +(map #(-(int %)48)(str n)))42))(range 1e6))) |
| 02:00 | clojurebot | 6062 |
| 02:00 | TEttinger | so that's 73 |
| 02:48 | je | I have a cljs function which compares two dates (and it works alright), but every time it compiles I get the error: WARNING: cljs.core/<, all arguments must be numbers, got [nil js/Date] instead. |
| 02:48 | je | https://gist.github.com/jacobemcken/04d264257718f2edea35 |
| 02:50 | je | Am I comparing dates wrong, or is the warning an error i ClojureScript |
| 02:51 | mpenet | js is forgiving, clj(s) not so much |
| 02:51 | mpenet | comparing nil and an Object for > is a bit weird |
| 02:52 | mpenet | you probably want to guard against the nil at least |
| 02:53 | je | mpenet: it is the same for two js dates: https://gist.github.com/jacobemcken/04d264257718f2edea35 |
| 02:53 | piranha | je: js/Data :-) |
| 02:54 | piranha | but that's strange, why would it give you a warning during compilation... |
| 02:54 | mpenet | then maybe getTime on the date instances |
| 02:54 | je | piranha: hehe thanks :) |
| 02:54 | piranha | hah, it gives me a warning as well |
| 02:55 | piranha | yeah, I was about to say that comparing two date objects is asking for trouble |
| 02:55 | piranha | I don't think js compares them properly |
| 02:55 | piranha | probably it converts them to strings and then tries to compare :)) |
| 02:56 | mpenet | the call to getTime should make it long vs long |
| 02:56 | mpenet | hopefully |
| 02:57 | piranha | yeah, unless it's null :) |
| 02:57 | piranha | btw, just checked - JS seems to compare date objects just fine (i.e. feels like real comparison, and not through toString) |
| 02:59 | je | piranha: Indeed it does, that is why I don't get why ClojureScript can't do it as well |
| 02:59 | piranha | je: no idea, to be honest, maybe it's just that comparing non-numbers in js is very error-prone, so it makes sense to forbid it completely :) |
| 03:00 | je | well ClojureScript can it just "complains" about it :) |
| 03:00 | mpenet | well, the js behavior is just weird |
| 03:00 | mpenet | it's neither > or < or = against null, its ... I dont' know what |
| 03:00 | mpenet | always returns false |
| 03:01 | je | piranha: perhaps... how would know if it is intentionally or something that has been overlooked? |
| 03:02 | je | *how = who |
| 03:02 | piranha | David Nolen I would say :) |
| 03:02 | piranha | and there are few other candidates, but it's too early for USA to be up, so you would have more chances getting an answer if you ask that in mailing list |
| 03:04 | ttasterisco | early? it's only midnight in the west coast :) |
| 03:05 | je | hehe |
| 03:07 | piranha | ttasterisco: well, it's already 31 of July there for 4 minutes, so technically it can be described "early" :-) |
| 03:11 | ttasterisco | yes, it's pretty early, the night's still a child |
| 03:12 | mindbender1 | I'm still getting the following compilation errors: https://gist.github.com/johnbendi/9b4f5f1f46c270f63b51#file-clojure-compilation-failure . Has anyone got similar experience trying to compile clojure? |
| 03:15 | Xorlev | mindbender1: Not a Clojure guy, but it looks to me like you have an asm lib conflict. |
| 03:15 | Xorlev | Probably between ASM3 and ASM4 |
| 03:17 | mindbender1 | Xorlev: Where can I check for that? |
| 03:18 | hiredman | mindbender1: are you building against master? |
| 03:18 | hiredman | maybe run mvn clean and try again |
| 03:20 | Xorlev | mindbender1: If that doesn't work, the maven dependency tree plugin |
| 03:20 | mindbender1 | Both master and previous tags report the errors. I'm trying mvn clean && mvn -e install now. |
| 03:21 | hiredman | Xorlev: if you look at the class name it is clojure.asm.* |
| 03:21 | hiredman | which is the version of asm bundled with clojure |
| 03:22 | hiredman | mindbender1: the error is very odd, so it seems likely you have some kind of old or stale partial build state or something |
| 03:22 | mindbender1 | hiredman: mvn clean helps. It's compiling now. |
| 03:23 | mindbender1 | Xorlev: hiredman: Thanks |
| 04:05 | Bosky101 | what am i missing here? http://pastebin.com/Ar2n44gp |
| 04:06 | Bosky101 | (trying to fwd arguments from 1 fund to another ) |
| 05:07 | robothor | Bosky101: I suspect you really want to apply in "foo" when forwarding to "foo*" |
| 05:32 | erdos | hello, in clojure 1.5.1 clojure.test/are one example is (are [x y] (= x y) 2 (+ 1 1) 4 (* 2 2)) . clearly, if i change it to (are [x y] (= x y) 2, (+ 1 1) 4 5) it fails and returns false. but if i change it to (are [x y] (= x y) 2 3, 4 (* 2 2)) the the result is still true. i am not sure if it means that the test is passes, which should not as the first expression should be false. the docs also says that (are) forms expand to (do (is) |
| 05:33 | erdos | is it an intended behavior, if it is to, could you please explain the reason why the first modification returns false and the second true? thanks. |
| 05:33 | ticking | Is there an error printed on the console? |
| 05:34 | erdos | wow, there is an error printed. i was only listening to the return value. |
| 05:34 | ticking | `do` will evaluate its arguments in order for side effects, in this case printing the error is one of those side effects, and then return the value of the last expression |
| 05:34 | erdos | ticking, ok, i see, but does the return value have any meaning then? |
| 05:34 | ticking | since the last test succeeds it will return true |
| 05:35 | ticking | there are cases where the return value of do is useful, but in this case it seems not |
| 05:37 | erdos | ok, thanks |
| 05:40 | erdos | an other question: in clj1.5.1 core.clj:719 the defition of if-not is `(if (not ~test) ~then ~else). i do not understand the extra call to `not` (which expands to and extra `if), and why it is not simply `(if ~test ~else ~then) |
| 05:40 | mbac | is there a clojure web framework that's uses continuation passing style like weblocks? |
| 05:41 | scottj | mbac: no popular ones afaik |
| 05:41 | mbac | d'oh |
| 05:54 | blunte | What is the best way to get a list of all methods that work on a particular class? Like clojure.lang.PersistentHashMap |
| 05:57 | opqdonut | blunte: something like (map str (.getMethods (class the-thing))) |
| 05:57 | blunte | I'm trying to understand why I can't do (keys somemap). I get this error: clojure.lang.PersistentHashMap cannot be cast to java.util.Map$Entry |
| 05:58 | opqdonut | blunte: or just (map str (.getMethods clojure.lang.PersistentHashMap)) if you know the class already |
| 05:58 | opqdonut | blunte: somemap is probably not a map but a sequence of maps |
| 05:58 | opqdonut | observe: |
| 05:58 | opqdonut | ,(keys [{:a 1}]) |
| 05:58 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry> |
| 05:58 | blunte | oh you're right |
| 05:58 | opqdonut | keys loops through the thing it gets and extracts the key |
| 05:59 | opqdonut | so the error message is an artefact of the implementation |
| 05:59 | blunte | opqdonut: thanks! |
| 06:12 | eskatrem | Hey, I can't use org.bson.types.ObjectId for the mongodb driver |
| 06:13 | eskatrem | What is the proper way to import it? I added [org.bson.types] in my project.clj but Leiningen can't find it in the central repos |
| 06:14 | TEttinger | eskatrem, lein doesn't know what packages are where |
| 06:16 | TEttinger | eskatrem, you have [com.novemberain/monger "2.0.0"] in project.clj ? |
| 06:16 | eskatrem | TEttinger doing it now |
| 06:16 | eskatrem | TEttinger: yeah in fact I have it |
| 06:16 | TEttinger | hm |
| 06:17 | eskatrem | Here's what lein tells me: |
| 06:17 | eskatrem | Could not find artifact org.bson.types:org.bson.types:jar:jar in central (http://repo1.maven.org/maven2/) |
| 06:18 | eskatrem | basically when I try to use the ObjectId from monger like in the example, I get: "No matching ctor found for class org.bson.types.ObjectId" and I dont know how to tell Leiningen to get them |
| 06:19 | TEttinger | right, well org.bson.types is a package, not a lein project |
| 06:20 | TEttinger | it is probably provided by monger, but might need a driver for mongo |
| 06:20 | TEttinger | so take out org.bson.types from project.clj deps... and it's possible you're not constructing the objectID how it expects |
| 06:21 | eskatrem | yeah, I just took it out, but the code to that uses ObjectId crashes |
| 06:21 | eskatrem | that's my imports: |
| 06:21 | eskatrem | (:import [com.mongodb MongoOptions ServerAddress ] |
| 06:21 | eskatrem | [org.bson.types ObjectId]) |
| 06:22 | eskatrem | I can use mongo from clojure just fine, just I can't access to the _id field |
| 06:44 | AWizzArd | eskatrem: what happens when you try it? How do you try it (minimal example)? |
| 06:44 | eskatrem | AWizzArd: I'm trying to build the minimal example actually |
| 06:45 | AWizzArd | Did you try something like (:_id db-entry) or (:_ID db-entry) and such? |
| 06:45 | eskatrem | somehow I am confused, how can I just make a project and run it from lein-run (my problem is with a web app I'm making with luminus) |
| 06:46 | eskatrem | yeah I tried with (:_id db-entry) but it doesn't match to the _id from my field |
| 06:46 | AWizzArd | is it :_id or :_Id or :_ID ? |
| 06:47 | eskatrem | (basically clojure is not able to know that {_id: 123} is {_id: ObjectId(123)}) |
| 06:47 | AWizzArd | or maybe (get entry "_id") or "_Id" or "_ID" |
| 06:47 | eskatrem | I did it with _id |
| 06:49 | eskatrem | I'll try with (get entry "_id") |
| 06:49 | eskatrem | actually |
| 06:49 | eskatrem | the real problem is for an update |
| 06:50 | eskatrem | the line that is not working is: (mc/update db coll {:_id _id} {:$set {lang-keyword message}} {:upsert true}) |
| 06:56 | mbac | is there an idiom for printfing sequences? |
| 06:56 | mbac | most of the time i end up with clojure.lang.LazySeq@45101e88 |
| 06:56 | Glenjamin | ,(prn (range 10)) |
| 06:56 | clojurebot | (0 1 2 3 4 ...)\n |
| 06:56 | Glenjamin | oh, rptinf |
| 06:57 | eskatrem | ,(apply println (range 10)) |
| 06:57 | clojurebot | 0 1 2 3 4 5 6 7 8 9\n |
| 06:57 | Glenjamin | ,(format "%s" (prn-str (range 10)) |
| 06:57 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 06:58 | mbac | sure, but then i need to know the tree of whatever it is i'm trying to print out |
| 06:58 | Glenjamin | ,(format "%s" (prn-str (range 10))) ; this, i guess |
| 06:58 | clojurebot | "(0 1 2 3 4 ...)\n" |
| 06:58 | mbac | which i don't. that's why i'm trying to print it :) |
| 06:58 | Glenjamin | either use prn instead of printf, or prn-str before passing to prinf i think |
| 06:59 | mbac | sweet! |
| 06:59 | hyPiRion | pr-str instead of prn-str if you want to avoid the newlines |
| 06:59 | AWizzArd | pr-str |
| 06:59 | Glenjamin | oh right, whoops |
| 07:01 | ro_st | thheller: ping |
| 07:02 | visof | hello |
| 07:04 | eskatrem | AWizzArd: now that's strange, (mc/find-maps db coll {:_id "53d79d8f3943fede9c1c63a2" } ) works just fine |
| 07:06 | visof | i'm using ring, i got error for POST request the details are here https://www.refheap.com/88762 |
| 07:06 | visof | can anybody help |
| 07:09 | ro_st | visof: is "hello, world" a valid json value? |
| 07:09 | ro_st | i bet (json/generate-string "hello, world") fails |
| 07:09 | visof | ro i just observed this and i fixed it |
| 07:09 | visof | thanks man |
| 07:13 | visof | hey (json/generate-string "hello, world") |
| 07:13 | visof | "\"hello, world\"" |
| 07:17 | Xack | is there anyway to directly insert javascript in a clojurescript file? |
| 07:18 | eskatrem | I don't know much about clojurescript, but can you call from clojurescript the javascript eval and dump your code here? (prize of elegance) |
| 07:19 | eskatrem | Xack: ^ |
| 07:19 | Xack | ah, thanks eskatrem :) |
| 07:20 | eskatrem | Xack: it's just a bad solution coming from someone who never used clojurescript in his life, but I'd be curious to know if it works |
| 07:21 | thheller | Xack: it is possible, but there rarely is a reason to do it |
| 07:21 | Xack | eskatrem: it should work, I wasn't even aware javascript had that, i'm new to javascript (and clojure), i'm currently making a game with it :) |
| 07:21 | thheller | better to just write javascript in javascript and then use it from cljs |
| 07:21 | thheller | interop is so easy |
| 07:30 | Xack | it works :) |
| 07:49 | wink | anyone ever heard of a js minifier written in clojure? |
| 07:55 | visof | defresource return fn object |
| 07:55 | visof | how can i deal with it? |
| 07:56 | clgv | visof: what? |
| 07:59 | visof | clgv: https://www.refheap.com/88764 check this? |
| 08:00 | clgv | visof: where is defresource from? |
| 08:01 | visof | clgv: [liberator.core :refer [defresource resource request-method-in]]) |
| 08:01 | nathan7 | wink: no, but why would you need one? |
| 08:01 | nathan7 | wink: you could use Google Closure from Clojure just fine |
| 08:01 | wink | nathan7: someone mentioned it, but didnt remember the name. and I couldn't quickly google it. |
| 08:03 | clgv | wink: maybe a ring middleware? |
| 08:03 | Glenjamin | dieter |
| 08:03 | Glenjamin | perhaps? |
| 08:05 | clgv | visof: are you sure that you are supposed to call a resource like that? |
| 08:05 | visof | clgv: what do you mean? |
| 08:05 | clgv | visof: well there is certainly documentation for it |
| 08:11 | mbac | what's the idiom for filtering non-nil stuff out of a seq |
| 08:11 | mbac | i'm writing this (filter (fn [x] (not (nil? x))) seq) |
| 08:11 | mbac | er, for filtering nil stuff out of a seq |
| 08:11 | clgv | mbac: do you use "map" before the filtering? then you can simply switch to "keep" |
| 08:12 | swi | mbac: (complement nil?) |
| 08:12 | llasram | mbac: (remove nil? s) |
| 08:12 | llasram | Or in 1.6+ (filter some? s) |
| 08:19 | mbac | hmm, keep wins i thik |
| 08:26 | jinks_ | wink: this one? https://github.com/yogthos/asset-minifier |
| 08:29 | wink | jinks_: I don't know. but thanks, will have a look! |
| 08:32 | mindbender1 | Is there a standard way to convert a MapEntry to a map of itself? |
| 08:32 | mindbender1 | [:a "foo"] => {:a "foo'} for example. |
| 08:33 | clgv | ,(into {} (first {:a :b})) |
| 08:33 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword> |
| 08:33 | verma | ,(into {} [[:a :b]]) |
| 08:33 | clojurebot | {:a :b} |
| 08:34 | nathan7 | ,(apply hash-map [:a :b]) |
| 08:34 | clojurebot | {:a :b} |
| 08:34 | verma | nice |
| 08:34 | clgv | yeah better use apply+hash-map |
| 08:34 | verma | ,(apply hash-map [:a :b :c :d]) |
| 08:34 | clojurebot | {:c :d, :a :b} |
| 08:34 | verma | ,(apply hash-map [:a :b :c :d :e]) |
| 08:34 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No value supplied for key: :e> |
| 08:34 | nathan7 | I spent a while thinking about that before realising "wait, so basically the same as pasting it into {}… wait…" |
| 08:35 | mindbender1 | Alright. Thanks. |
| 08:54 | clgv | ,(mapv (partial apply hash-map) {:a 1 :b 2}) |
| 08:54 | clojurebot | [{:b 2} {:a 1}] |
| 09:07 | mpenet | ,(conj {:a 1} [:b 2]) |
| 09:07 | clojurebot | {:b 2, :a 1} |
| 09:23 | Ven | erm, I wonder what's the difference between repeat and constantly |
| 09:23 | clgv | Ven: constantly creates a function that constantly returns the given value |
| 09:23 | swi | Hello. what difference between rest and next functions ? i dont' get it |
| 09:24 | clgv | Ven: "repeat" creates a sequence with the given length that contains only the given element |
| 09:24 | clgv | ,((juxt rest next) [a]) |
| 09:24 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 09:24 | clgv | ,((juxt rest next) [1]) |
| 09:24 | clojurebot | [() nil] |
| 09:25 | Ven | clgv: so `constantly` is like `fn []` ? |
| 09:25 | Ven | or is it used like a "let over lambda" kind of thing ? |
| 09:26 | justin_smith | Ven: (fn [& _] :foo) |
| 09:26 | justin_smith | takes zero or more arguments, returns value |
| 09:27 | Ven | justin_smith: (plus does caching :) !). alright, thanks. Because the example I saw was `(map (constantly 42) (range 10))` and I was like, you could `(take 10 (repeat 42))` |
| 09:27 | justin_smith | ,(take 5 (repeatedly (constantly (rand-int)))) |
| 09:27 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/rand-int> |
| 09:27 | justin_smith | ,(take 5 (repeatedly (constantly (rand-int 5)))) |
| 09:27 | clojurebot | (0 0 0 0 0) |
| 09:28 | justin_smith | Ven: yeah, constantly is more useful if you make a call which returns the function to apply - it may have (constantly :some-default) as one thing it gives you |
| 09:29 | swi | clgv: well, in this https://www.refheap.com/88766 if i replace rest for next in 3rd string, function working, but wit rest it's stacked :) I mean what the diff in this situation ? |
| 09:30 | clgv | ,(source constantly) |
| 09:30 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 09:30 | clgv | $source constantly |
| 09:30 | clgv | :/ |
| 09:30 | clgv | Ven: it creates a function and returns it |
| 09:30 | clgv | ,(type (constantly 5)) |
| 09:30 | clojurebot | clojure.core$constantly$fn__4085 |
| 09:31 | clgv | ,(type (repeat 10 5)) |
| 09:31 | clojurebot | clojure.lang.LazySeq |
| 09:37 | clgv | ,(mapv sequential? [nil []]) |
| 09:37 | clojurebot | [false true] |
| 09:38 | clgv | swi: nil is not sequential whereas an empty vector/sequence is |
| 09:39 | swi | clgv: ah, so when i use rest it's work right the same as with next, but on the last iteration it's get [] and iterate over it forever? |
| 09:39 | clgv | ,(rest []) |
| 09:39 | clojurebot | () |
| 09:40 | justin_smith | ,(take 10 (iterate rest [])) |
| 09:40 | clojurebot | ([] () () () () ...) |
| 09:40 | swi | got it :) |
| 09:40 | swi | clgv: justin_smith thanks :) |
| 09:40 | clgv | swi: yeah, you'll have to ask for empty? |
| 09:40 | Ven | clgv: thanks too :) |
| 09:44 | visof | https://www.refheap.com/88767 i can't use post |
| 09:44 | visof | can anybody help me in this? |
| 09:46 | justin_smith | visof: if you want to accept post, why do you only declare GET ? |
| 09:46 | visof | justin_smith: https://www.refheap.com/88768 |
| 09:46 | visof | i fixed it, i don't get anything though |
| 09:47 | clgv | visof: "(slurp body)" looks pretty strange |
| 09:47 | justin_smith | are you sure you need to slurp? |
| 09:47 | justin_smith | ring should just give you the body |
| 09:47 | visof | justin_smith: so i need to remove slurp? |
| 09:48 | justin_smith | yeah, just use the body directly |
| 09:48 | visof | justin_smith: okay i'm trying |
| 09:49 | justin_smith | also, even if the body was an input stream, slurp would not be the right way to consume it |
| 09:49 | visof | justin_smith: i got this error https://www.refheap.com/88769 |
| 09:49 | justin_smith | yeah, you want to get the string from the HttpInput |
| 09:50 | visof | so how can i do this? |
| 09:50 | drbobbeaty | visof: justin_smith: ... don't mean to butt in, but you need the 'slurp' to convert the body. |
| 09:50 | justin_smith | usually I use a middleware that does that for me |
| 09:50 | justin_smith | drbobbeaty: really? |
| 09:51 | visof | justin_smith: can you give me simple Example for how middleware do this? |
| 09:51 | justin_smith | OK, sorry, I guess I am so dependent on my habitual middleware that I didn't realize |
| 09:51 | drbobbeaty | Here's what I've done - and it works: (POST "/blah" [:as {body :body}] (let [lst (json/parse-string (slurp body))] ... |
| 09:52 | drbobbeaty | where the 'json' namespace is the cheshire library. |
| 09:52 | justin_smith | visof: https://github.com/ring-clojure/ring-json wrap-json-params is what I use |
| 09:52 | sveri | Hi, does it make sense / is it possible to use core.typed only partially in an applicatoin? I want to use more as a kind of documentation like, here, this method returns an int |
| 09:54 | boxed | sveri: I thought partial use was sort of the point ^_- |
| 09:54 | blunte | I have a PersistentHashMap that looks like this when printed: [:key1 val1] [:key2 val2]. I'm trying to put it into a defined record that looks like (defrecord Foo [key1 key2]), but I cannot figure out the right way to convert the hashmap so the ->Foo works |
| 09:55 | blunte | Is there a standard way of populating a record from a hashmap (where the keys are specified, not just a list of values)? |
| 09:55 | justin_smith | ,(slurp (-> "hello" .getBytes java.io.ByteArrayInputStream.)) |
| 09:55 | clojurebot | "hello" |
| 09:56 | justin_smith | blunte: map->Foo is generated automatically when you define a record Foo |
| 09:57 | visof | drbobbeaty: that's my code based on what you told https://www.refheap.com/88770 and i got nothing |
| 09:57 | visof | shouldn't i got the json again on the browser? |
| 09:57 | drbobbeaty | visof: let me have a look-see... |
| 09:57 | visof | okay |
| 09:58 | blunte | justin_smith: that works in repl, where my hash-map printed looks like {:key1 val1, :key2 val2}. But for some reason, the data I'm processing in my program claims to be a PersistentHashMap (but prints like [:key1 val1] [:key2 val2]). And map->Foo fails because it is receiving too many arguments. |
| 09:59 | justin_smith | blunte: someone called seq on the hash-map |
| 09:59 | justin_smith | you can either use (into [] s) to make it a hash-map again, or make it not get turned into a seq |
| 09:59 | justin_smith | sorry, (into {} s) |
| 10:00 | blunte | justin_smith: ok, it's coming out of jdbc as a lazy sequence. I'm doing doall, but the doall map apply % stuff is making my head spin. |
| 10:00 | blunte | justin_smith: (doall (map #(apply create-rec (into {} %)) recs)) ; where create-rec is the function map->Foo |
| 10:00 | justin_smith | ,(into {} ([:a 0] [:b 1])) |
| 10:00 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer> |
| 10:00 | drbobbeaty | visof: Ah... nope. You need to have the return value from your route be a map with a :body key and the value of a map. So if you changed it to: {:status 200, :body (postResource lst)} - try that... |
| 10:01 | justin_smith | ,(into {} '([:a 0] [:b 1])) |
| 10:01 | clojurebot | {:a 0, :b 1} |
| 10:01 | drbobbeaty | visof: I'm preparing a Gist for you of exactly what I do... |
| 10:02 | justin_smith | blunte: apply is calling seq on the map |
| 10:02 | justin_smith | ,(apply identity {:a 0 :b 1}) |
| 10:02 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core/identity> |
| 10:02 | blunte | Ohh |
| 10:02 | justin_smith | so you likely don't need into, just don't use apply |
| 10:03 | blunte | justin_smith: Yeah, what I receive from jdbc looks like ({:key1 val1, :key2 val2} {:key1 ... :key2 ...}) |
| 10:03 | blunte | I was just trying to iterate over all elements and stuff them into records |
| 10:04 | justin_smith | so yeah, you don't need apply, just (doall (map map->Foo ...)) |
| 10:04 | blunte | justin_smith: ahh, that makes some sense. Thanks much |
| 10:05 | clgv | please don't (doall (map ...)) just use (mapv ...) ;) |
| 10:07 | blunte | ok |
| 10:08 | drbobbeaty | visof: Have a look at this: https://gist.github.com/drbobbeaty/e580eba3e13a799b91c1 |
| 10:08 | blunte | clgv: why is a vector preferred to a sequence? |
| 10:08 | blunte | for output |
| 10:08 | drbobbeaty | visof: It has several useful functions to return JSON and codes, etc. |
| 10:09 | drbobbeaty | visof: I got a lot of help from gfredericks on this... |
| 10:10 | clgv | blunte: it's not the vector. why do you want to explicitely construct a lazy sequence that you immediately force to evaluate? |
| 10:10 | clgv | blunte: in your case just use the eager "mapv" instead of the lazy "map" |
| 10:11 | blunte | clgv: how did you know I was going to immediately evaluate the end result? :) I am, so it makes sense here. But isn't the idea that you try to stay lazy as long as possible? |
| 10:11 | justin_smith | clgv: because outside that block, the result stream you are consuming is no longer valid. Though the vector overhead is small, it is there, and not needed if the output will be consumed in order anyway. |
| 10:11 | clgv | blunte: because you accepted the doall+map suggestion :P |
| 10:12 | clgv | justin_smith: the (transient) vector construction is much faster than what doall+map offers you ;) |
| 10:13 | clgv | justin_smith: yeah exactly that is the reason you should process it there, but still "mapv" is preferable then |
| 10:13 | justin_smith | clgv: the vector construction can't be faster than a doall on a map - it calls map eagerly internally |
| 10:13 | clgv | blunte: no not necessarily. I'd only use lazy where it fits |
| 10:13 | justin_smith | and using a vector sequentially is not faster than using a realized lazy-seq |
| 10:15 | clgv | justin_smith: you are wrong there. there is no optimization for "doall" on lazy-seqs, hence there are a lot of temporary lazy-seq objects created |
| 10:16 | hyPiRion | clgv: It's unchunked vs. chunked essentially. |
| 10:17 | clgv | hyPiRion: I guess database results are not chunked, right? |
| 10:17 | clojurebot | Titim gan éirí ort. |
| 10:18 | hyPiRion | clgv: I dunno, they might be? I wasn't saying you were wrong btw, I was saying that creating a vector of size n is cheaper than creating a lazy-seq of size n, if you were to realise everything immediately. |
| 10:18 | clgv | hyPiRion: ah ok^^ |
| 10:19 | clgv | hyPiRion: you'd agree to prefer "(mapv f coll)" over "(doall (map f coll))" in general? |
| 10:20 | hyPiRion | clgv: If that's the last time you're going to map over the collection, yes |
| 10:21 | clgv | hyPiRion: what is the reason for the restriction? |
| 10:21 | clgv | mapping over anything seqable shouldnt make a difference, right? |
| 10:24 | blunte | why convert a lazy sequence into something fully realized, then back to another lazy one |
| 10:24 | blunte | that's my guess |
| 10:24 | hyPiRion | clgv: If you really need performance and want to do multiple mappings on a seq, better use reducers. |
| 10:24 | hyPiRion | avoid the intermediate seqs. |
| 10:25 | clgv | blunte: because you need to force it anyway - so why not use the fast and syntax-wise lightweight approach? |
| 10:25 | blunte | clgv: makes sense. And honestly, this is all still so very vague for me... I'll use whatever works and that I can wrap my head around. I know the nuanced/idiomatic use will come with experience |
| 10:25 | clgv | hyPiRion: ah ok right. I was only considering "map" vs "mapv" here ;) |
| 10:26 | hyPiRion | clgv: right, then I'd go mapv all day |
| 10:26 | clgv | blunte: as far as I observed it, "mapv" was introduced as better version of "doall+map" ;) |
| 10:26 | hyPiRion | (if you do a doall over it) |
| 10:26 | blunte | Thanks for the advice. Brevity is a nice bonus too |
| 10:37 | justin_smith | blunte: you are right about mapv, mea culpa https://www.refheap.com/88773 |
| 10:38 | justin_smith | I clearly underistimated the overhead on a lazy-seq (even a realized one) |
| 10:39 | schmee | if I have a function (defn listener [socket running] |
| 10:39 | schmee | ), how can I apply partial to the second argument, so I get function (defn L [socket])? |
| 10:39 | joegallo | partial doesn't do that |
| 10:39 | joegallo | use #(listener % second-arg-here) |
| 10:39 | joegallo | and you'll get the same net effect |
| 10:39 | joegallo | more or less |
| 10:39 | schmee | gah, of course! |
| 10:40 | schmee | thanks! |
| 10:40 | joegallo | anytime |
| 10:40 | clgv | blunte: that was me ;) |
| 10:40 | clgv | justin_smith: try replacing the chunked (range 10) with (take 10 (iterate inc 0)) |
| 10:41 | blunte | Fancy! |
| 10:41 | blunte | :) |
| 10:41 | clgv | oops lol mean justin_smith: ^^ |
| 10:41 | clgv | :P |
| 10:41 | justin_smith | clgv: oops |
| 10:41 | justin_smith | heh |
| 10:41 | clgv | complete reference confusion :D |
| 10:50 | hugod | Is there any way to add a namespace dependency in clojurescript, other than via the ns form? (ie. I'm looking for the equivalent of a top-level `require` in clojure) |
| 10:50 | gfredericks | hugod: I doubt it |
| 10:51 | hugod | the ns form can't be the output of a macro either :( |
| 10:53 | gfredericks | yeah I believe it's a lot more actually-declarative and less hackable than clojure's |
| 10:54 | hugod | I am trying to do plugin discovery of javascript components via clojure namespace enumeration |
| 11:00 | hugod | s/javascript/om clojurescript/ |
| 11:10 | michaelr525 | hi |
| 11:10 | michaelr525 | anyone works with liberator? |
| 11:11 | michaelr525 | why post!ing a new item can't return a response? is it because of the HTTP standard? |
| 11:12 | michaelr525 | according to the decission graph I have to return new? => false and respond-with-entity? => true and then I get a 200 status with the response I provide in handle-ok. |
| 11:12 | michaelr525 | so this works, but why this way? |
| 11:19 | michaelr525 | ok, I think I should use handle-created |
| 11:20 | michaelr525 | yeah |
| 11:20 | michaelr525 | it works |
| 11:20 | michaelr525 | thanks anyway :) |
| 11:22 | Fare | I've started getting this error: IllegalArgumentException No method in multimethod 'done?' for dispatch value: class skylark.lexer.Σ clojure.lang.MultiFn.getFn (MultiFn.java:160) |
| 11:22 | Fare | but the very same thing used to work, and the namespaces look correct to me, so I'm baffled. |
| 11:24 | Fare | how do I inspect the MultiFn object? |
| 11:25 | clgv | Fare: you might have forgotten to load a namespace that defines the corresponding method |
| 11:25 | clgv | Fare: maybe due to changed :require statements in your ns-form |
| 11:26 | Fare | `(defmethod ...) shows the correct namespaces |
| 11:26 | Fare | I grouped the :use and :require statements --- maybe that's the issue? But why does `(defmethod done? ...) show the apparently correct thing? |
| 11:28 | Fare | oh, maybe the class got overwritten after defining the method? |
| 11:29 | Fare | or something like that? |
| 11:33 | clgv | Fare: redefinition of the class after the method definition is problematic, if it happened |
| 11:34 | clgv | did you restart the repl to try whether it works then? |
| 11:35 | Fare | same |
| 11:36 | clgv | ok. if your last action had to do with reorganizing the :use/:require statements you should look at the differences to see if an error happened there |
| 11:37 | clgv | each namespace containing defmethods that was removed is a problem |
| 11:58 | Fare | could my build be corrupted somehow? |
| 11:58 | Fare | how do I inspect a multifn ? |
| 12:15 | clgv | Fare: maybe with that method https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/MultiFn.java#L577 |
| 12:18 | Bronsa | clgv: Fare there's clojure.core/methods |
| 12:18 | Fare | I'm totally confused: this used to work, and stopped working suddenly. From the user namespace, I can define methods on vectors, but not on the defrecord I care for. WTF? |
| 12:19 | Bronsa | that's does what clgv linked, but as a function |
| 12:19 | clgv | Fare: well you could use "git bisect" to find the commit that introduced the problematic changes |
| 12:19 | Fare | also works with a new record class |
| 12:20 | Fare | I know which commit it is, but it has plenty of unrelated changes |
| 12:20 | clgv | your best bet is that the method definition is not loaded. |
| 12:21 | Bronsa | or you have a redefinition of that record somewhere |
| 12:21 | clgv | couldnt you just reevaluate the desired method definition? |
| 12:21 | Fare | clgv: doesn't look like it's working |
| 12:21 | Fare | Bronsa, not voluntarily, though there might be some symbol clash with namespaces, though I didn't seen any error or warning |
| 12:22 | Bronsa | Fare: does (= (class some-instance) the-record) return true? |
| 12:22 | clgv | Fare: reevaluting the desired defmethod does not work? then something is seriously wrong since that should fix the class-redefinition issue |
| 12:22 | Bronsa | Fare: might also be a problem with mixing AOT code w/ JIT |
| 12:22 | Fare | Bronsa, yes |
| 12:23 | Bronsa | no idea then |
| 12:23 | Fare | Bronsa, wait, no |
| 12:23 | clojurebot | excusez-moi |
| 12:23 | Fare | how is that possible??? |
| 12:23 | Bronsa | ,(defrecord x []) |
| 12:23 | clojurebot | sandbox.x |
| 12:23 | Fare | the class has the same name |
| 12:23 | Bronsa | ,(def a (x.)) |
| 12:23 | clojurebot | #'sandbox/a |
| 12:23 | Bronsa | ,(defrecord x []) |
| 12:23 | clojurebot | sandbox.x |
| 12:24 | Bronsa | ,(= x (class a)) |
| 12:24 | clojurebot | false |
| 12:24 | Bronsa | Fare: ^ |
| 12:24 | Fare | I don't get it |
| 12:24 | Bronsa | Fare: the second defrecord overwrites the first one |
| 12:25 | Bronsa | Fare: but a is an instance of the first record, not the second one |
| 12:25 | Bronsa | even if the two records have the same class name, they are not the same class |
| 12:26 | Bronsa | Fare: if you don't have a redefinition of your record, you are probably AOT compiling the record somewhere, that messes things up |
| 12:28 | Fare | I have no idea where my defrecord is somehow defined twice, though. |
| 12:28 | Fare | Bronsa, probably, though I have no idea how |
| 12:32 | clgv | Fare: do you have namespaces with hyphens? |
| 12:34 | clgv | if so, make sure they are all written identically in the require clauses. using "my-ns" and "my_ns" in differents ns forms loads my-ns twice |
| 12:34 | clgv | at least this was the case with Clojure 1.4.0 |
| 12:48 | Ro_ | Hello, is there a book/paper for functional scalable modular software creation |
| 12:48 | Ro_ | ? |
| 12:48 | Ro_ | or similar |
| 12:53 | jjwatt | Ro_: Maybe you want "on the criteria to be used in decomposing systems into modules," "out of the tarpit," "why functional programming?," or "equal rights for functional objects." |
| 12:53 | jjwatt | all are great papers |
| 12:54 | bbloom_ | jjwatt: those are all definitely great |
| 12:54 | jjwatt | and not too specific |
| 12:54 | bbloom_ | Ro_: or are you looking for more info about how to structure larger code bases in a functional language? |
| 12:54 | jjwatt | hopefully |
| 12:55 | Ro_ | bbloom, yes |
| 12:55 | bbloom_ | Ro_: watch this: https://www.destroyallsoftware.com/talks/boundaries |
| 12:55 | Ro_ | but I think both |
| 12:55 | mdrogalis | stuartsierra's Clojure in the Large talk was pretty good, Ro_. |
| 12:56 | jjwatt | bbloom_: cool, i've never seen that |
| 12:57 | Ro_ | Ok, I am going to see those. If you'll think something more, notify me. :) |
| 12:57 | Ro_ | btw, thanks :) |
| 12:57 | jjwatt | heh. there are a ton more. but hopefully, that's a good start. |
| 12:58 | Ro_ | is there a list? |
| 12:58 | jjwatt | i think there might be a list of papers on the clojure site somewhere. |
| 12:59 | bbloom_ | jjwatt: are you thinking of the clojure bookshelf? |
| 12:59 | bbloom_ | ~bookshelf ; i hope |
| 12:59 | clojurebot | excusez-moi |
| 12:59 | jjwatt | not a huge list, though. a lot of papers you just hear people refer to in their talks or books |
| 12:59 | bbloom_ | clojurebot: bookshelf is http://www.amazon.com/Clojure-Bookshelf/lm/R3LG3ZBZS4GCTH |
| 12:59 | clojurebot | c'est bon! |
| 13:00 | jjwatt | bbloom_: no, I meant papers specifically |
| 13:00 | bbloom_ | do share if you find it |
| 13:01 | jjwatt | looks like fogus has a list, but they're not all functional and some are fundamentals heavy: http://blog.fogus.me/2011/09/08/10-technical-papers-every-programmer-should-read-at-least-twice/ |
| 13:02 | jjwatt | which reminds me, his bibliographies are a great place to find papers and books! |
| 13:02 | Ro_ | I was right coming here and asking! :D |
| 13:03 | jjwatt | oh, i found the papers list i was talking about. it's actually on github! https://github.com/papers-we-love/papers-we-love |
| 13:04 | jjwatt | there's a clojure section, funtional section, and a ton more |
| 13:04 | jjwatt | wonder if that's in the bot. |
| 13:05 | justin_smith | ~papers |
| 13:05 | clojurebot | It's greek to me. |
| 13:08 | TimMc | make it so |
| 13:11 | jjwatt | clojurebot: papers is https://github.com/papers-we-love/papers-we-love |
| 13:11 | clojurebot | Ack. Ack. |
| 13:14 | timothyw | clojure.core.cache/through |
| 13:15 | timothyw | oops… that was supposed to go in the search bar |
| 13:25 | hoverbear | Is there a library for Clojure to make OAuth HTTP requests? |
| 13:26 | technomancy | depending on what you need, this can be done in ~20 lines with clj-http and cheshire |
| 13:26 | hoverbear | technomancy: Perfect. I'll check those out |
| 13:27 | technomancy | https://github.com/technomancy/syme/blob/master/src/syme/web.clj#L21 |
| 13:34 | hoverbear | technomancy: Thanks :) |
| 13:37 | timothyw | I’m having some Clojure / Core.Async Dependency Issues (see https://groups.google.com/forum/#!topic/clojure/YYH6XUJ2PzE) |
| 13:37 | timothyw | looks to be the same “No such var: clojure.core.cache/through” as here: http://www.raynes.me/logs/irc.freenode.net/clojure/2013-09-11.txt |
| 13:38 | timothyw | but explicitly including org.clojure/core.cache didn’t work for me |
| 13:38 | timothyw | anyone else seeing this? |
| 13:40 | jjwatt | haven't seen it; using core.async |
| 13:42 | timothyw | the current page (https://github.com/clojure/core.async/) recommends [org.clojure/clojure "1.6.0"] |
| 13:42 | timothyw | [org.clojure/core.async "0.1.303.0-886421-alpha"] |
| 13:42 | timothyw | I’ve tried different permutations to no avail |
| 13:42 | jjwatt | just rebuilt this project on a server yesterday |
| 13:43 | jjwatt | yeah, i'm using 1.6 |
| 13:43 | jjwatt | [org.clojure/core.async "0.1.303.0-886421-alpha"] |
| 13:43 | timothyw | and you’re good? |
| 13:44 | timothyw | … I even tried a clean .m2/repository |
| 13:44 | jjwatt | yeah. hmm. I don't :refer :all |
| 13:44 | jjwatt | not sure if that makes a diff |
| 13:44 | jjwatt | maybe you wouldn't pull in some defs |
| 13:45 | hiredman | timothyw: what version of lein? |
| 13:45 | jjwatt | [clojure.core.async :as a :refer |
| 13:45 | jjwatt | [chan go go-loop close! <!! <! >! >!!]] |
| 13:45 | jjwatt | |
| 13:45 | timothyw | tried removing :refer :all - same error |
| 13:45 | timothyw | Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM |
| 13:46 | hiredman | there is an issue with certain versions of lein and some line plugins that causes that exception |
| 13:46 | hiredman | what plugins are you using? |
| 13:46 | hiredman | oh |
| 13:46 | timothyw | umm… a bunch (in ~/.lein/profiles.clj) |
| 13:47 | jjwatt | i'm only using cider-nrepl |
| 13:47 | hiredman | lein deps :tree will print a list of depdencies and may print out warnings for things that stomping on the depdencies of other things |
| 13:47 | hiredman | timothyw: commenting out all the plugins and see what happens |
| 13:47 | timothyw | ok, lemme try |
| 13:49 | timothyw | nope. I tried commenting out all my plugins (below), but no dice. |
| 13:49 | timothyw | :plugins [[lein-ancient "0.5.5"][codox "0.8.10"][lein-ritz "0.7.0"][lein-midje "3.1.3"][lein-midje-doc "0.0.22"][lein-ring "0.8.11"][lein-try "0.4.1"][lein-localrepo "0.5.3"][alembic "0.2.1"][hiccup-bridge "1.0.0-SNAPSHOT"][lein-cljsbuild "1.0.3"][lein-release "1.1.3"]] |
| 13:50 | timothyw | lemme try disabling ~/.lein/profiles.clj |
| 13:50 | hiredman | so run lein deps :tree and see what conflicting versions of core.cache are being required |
| 13:52 | timothyw | ok, I got it |
| 13:52 | timothyw | disabling ~/.lein/profiles.clj fixed the problem |
| 13:52 | timothyw | so something in there is conflicting with core.cache |
| 13:52 | xeqi | jjwatt: are you in the houston area? |
| 13:53 | jjwatt | xeqi: no, in the south, though. |
| 14:05 | jinks_ | is there a prettier/fancier way to express "(if (> p 10) 10 p)"? |
| 14:06 | technomancy | max |
| 14:06 | technomancy | err |
| 14:06 | technomancy | min |
| 14:07 | justin_smith | and don't forget minimax http://en.wikipedia.org/wiki/Minimax |
| 14:07 | amalloy | minimax's big brother maxerrmin |
| 14:07 | amalloy | that actually sounds like a cool name. i wouldn't mind being named Max Errmin |
| 14:07 | technomancy | it's just a /nick away |
| 14:08 | technomancy | oh, except your karma is not transferrable |
| 14:08 | amalloy | technomancy: i have access to the karma database though |
| 14:08 | jinks_ | augh... could've thought of that. Looks like there's too much blood in my caffeine circulation :) |
| 14:08 | technomancy | amalloy: you wouldn't... |
| 14:08 | amalloy | $karma MaxErrmin |
| 14:08 | lazybot | MaxErrmin has karma 0. |
| 14:08 | amalloy | apparently i wouldn't |
| 14:13 | Fare | so the only change I made that could have messed AOT was adding a :main foo.core to the project.clj |
| 14:13 | Fare | would that explain why my defmethod didn't work anymore? |
| 14:15 | amalloy | Fare: it's certainly suspicious, anyway |
| 14:15 | amalloy | AOT is just a vehicle for sadness |
| 14:16 | mdrogalis | Shotgun! |
| 14:20 | amalloy | Fare: probably lein clean would have had the same effect |
| 14:20 | Fare | amalloy: quite possible |
| 14:20 | Fare | amalloy: thanks for the tip |
| 14:29 | amalloy | &(class (hash-map)) |
| 14:29 | lazybot | ⇒ clojure.lang.PersistentArrayMap |
| 14:29 | xeqi | $karma MaxErrmin |
| 14:29 | lazybot | MaxErrmin has karma 1000. |
| 14:29 | amalloy | reeeeeally |
| 14:30 | xeqi | yearly reminder |
| 14:30 | jinks_ | amalloy: must be _random_ database corruption... |
| 14:30 | xeqi | those cosmic rays |
| 14:31 | aperiodic | you can't *disprove* it |
| 14:32 | bbloom_ | hash-map is such a strange function name compared to the other data structure factory names |
| 14:32 | Bronsa | bbloom_: well map was already taken |
| 14:32 | amalloy | srsly though who did that? i actually didn't touch MaxErrmin's karma, and karma is channel-local, so it can't have been set in PM. does xeqi have db access? |
| 14:33 | bbloom_ | Bronsa: and there's an alternative conflict with the name "assoc" if you wanted to call them "associations" |
| 14:34 | amalloy | bbloom_: it seems consistent with the other datastructure factory names. hash-map, hash-set, array-map |
| 14:34 | Bronsa | bbloom_: there's still dict though |
| 14:34 | bbloom_ | amalloy: i would clarify, but i know you knew what i meant :-P |
| 14:34 | bbloom_ | Bronsa: for some reason dict just seems wrong to me... |
| 14:35 | bbloom_ | but i guess (map seq), (dict & keyvals), (assoc dict & keyvals) works out |
| 14:36 | bbloom_ | barring my discomfort, that's probably a good solution |
| 14:36 | bbloom_ | especially since my discomfort doesn't count for anything |
| 14:40 | amalloy | $karma MaxErrmin |
| 14:40 | lazybot | MaxErrmin has karma -1000.0. |
| 14:40 | amalloy | haha a float. silly me |
| 14:43 | expez | (try (schema/validate MySchema {}) (catch Exception e (println e))) at the repl works fine, but if I replace println with log/error (from timbre) it just hangs, why? |
| 14:44 | expez | validate throws an ExceptionInfo |
| 14:44 | expez | I had this in a (future ...) and I think this explains why it inexplicably dies, without printing any stacktrace |
| 14:45 | mdrogalis | expez: Correct. |
| 14:49 | expez | mdrogalis: why does this happen? |
| 14:50 | mdrogalis | expez: When you spin up a future, you're no longer on the main thread. Std out/err from other threads goes to, at least in Emacs, *nrepl-server*, not *nrepl* to avoid mixing the two, I guess. |
| 14:51 | mdrogalis | At least, that was always my understanding. Can anyone confirm/disconfirm? |
| 14:51 | mdrogalis | Even when not using Emacs, stderr will be thrown out in a future if not caught. I dont know why on that one. |
| 14:51 | mdrogalis | I suppose because the thread just gets terminated if the exception bubbles all the way up. End of game. |
| 14:52 | expez | mdrogalis: I had (future (try (catch ..(log/error e)) thinking that would at least let me know about any failures, but that is indeed causing a freeze not just in emacs? |
| 14:52 | justin_smith | you could wrap your future in a try/catch that logs |
| 14:52 | justin_smith | jynx |
| 14:53 | mdrogalis | You're seeing a freeze? I would have expected that to log just fine. |
| 14:53 | justin_smith | unless you have a problem in your catch block maybe? |
| 14:55 | expez | yes, it appears to just die at the (validate ..) |
| 14:55 | expez | I added some logging just prior and after, and jus the line prior prints |
| 14:55 | expez | I'm using the default configuration for timbre, so this is all logging to console |
| 15:08 | vdmit11 | Hi folks. Can clojure sets (I mean data structures) handle large elements? The elements may be several megabytes in size and I need to keep them unique, so can I use sets and how slow that would be? |
| 15:11 | bbloom_ | vdmit11: the only thing that matters is the speed of your hash and equality functions |
| 15:12 | bbloom_ | vdmit11: if you're storing immutable byte blobs for example, you can either pre-hash or lazy (ie caching) hash them |
| 15:13 | bbloom_ | in that case, the size won't matter at all really |
| 15:14 | justin_smith | bbloom_: or give them a hash function that does not require reading the whole element |
| 15:15 | celwell | Would it be possible (and reasonable) to make macro that let's you use a period as a composition operator? (e.g., haskell's "(x . y)" instead of "(comp x y)") ... Hmm... now that I think about it, that's not prefix notation. Any thoughts? |
| 15:16 | justin_smith | celwell: . is picked up on the reader level |
| 15:16 | gtrak | ,(read-string "(x . y)") |
| 15:16 | clojurebot | (x . y) |
| 15:16 | gtrak | oh, huh |
| 15:16 | justin_smith | wait, maybe I am wrong... |
| 15:16 | gtrak | not what I expected to happen |
| 15:17 | aperiodic | isn't . just a special form and the other interop forms are macros that expand to .? |
| 15:17 | gtrak | in the first position yes |
| 15:17 | gtrak | ,. |
| 15:17 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: . in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:17 | justin_smith | ahh, it is position dependent |
| 15:17 | gtrak | ,do |
| 15:17 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 15:17 | justin_smith | ,(do (def . :hello) .) |
| 15:17 | clojurebot | :hello |
| 15:18 | gtrak | ,`. |
| 15:18 | clojurebot | . |
| 15:18 | gtrak | ,'`. |
| 15:18 | clojurebot | (quote .) |
| 15:18 | xeqi | ,(second "(read-string "(x . y)") |
| 15:18 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading string> |
| 15:18 | xeqi | ,(second "(read-string "(x . y)")) |
| 15:18 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading string> |
| 15:18 | justin_smith | ,(do (def . :hello) (. . getName)) |
| 15:18 | clojurebot | "hello" |
| 15:18 | gtrak | why isn't that namespaced? |
| 15:18 | gtrak | ,`do |
| 15:18 | clojurebot | do |
| 15:18 | gtrak | ,`somesym |
| 15:18 | clojurebot | sandbox/somesym |
| 15:19 | gtrak | funny |
| 15:19 | justin_smith | I still think binding . will have weird effects |
| 15:19 | Bronsa | gtrak: special-symbols aren't namespaced |
| 15:19 | Bronsa | and ` doesn't namespace them |
| 15:19 | justin_smith | since it is special in the first position, see my last clojurebot invocation |
| 15:19 | Bronsa | well except import* |
| 15:20 | vdmit11 | bbloom_: tnx |
| 15:20 | Bronsa | wich I just realized ` doesn't handle |
| 15:33 | sveri | Hi, I am trying to use core.typed in a namespace where I require datomic.api and get this error: Type Error (NO_SOURCE_FILE) Internal Error (:<NO LINE>) File for datomic.api not found on classpath: datomic/api.clj What can I do to exclude datomic? |
| 15:35 | Bronsa | sveri: https://groups.google.com/d/msg/clojure-core-typed/ptVyTMmSHyQ/jN5jquozM2IJ |
| 15:36 | sveri | Bronsa: ah, thats funny, just a few hours old this thread, thank you very much |
| 15:47 | schmee | is it idiomatic to use `juxt` for side-effects (if you don't care about the returned array)? |
| 15:47 | amalloy | seems a little weird |
| 15:48 | amalloy | i'd write (doseq [f [a b]] (f x y z)) |
| 15:48 | gfredericks | s/a b/g h/ |
| 15:48 | amalloy | but ((juxt a b) x y z) is understandable too |
| 15:49 | amalloy | gfredericks: naw, that implies that f is in the same family as g and h, where really it's the general name for any of them |
| 15:49 | gfredericks | amalloy: I'll fight you. |
| 15:49 | amalloy | bahaha |
| 16:50 | eskatrem | Sorry for the noob question, but how (or where can I find how) write and compile a program in clojure that simply puts hello world on the command line? |
| 16:51 | rlb | eskatrem: one option -- http://leiningen.org/ |
| 16:51 | rlb | and then "lein new app my-app" followed by "cd my-app; lein run" |
| 16:51 | justin_smith | eskatrem: if you run "lein new", that will create something very close to a hello world clojure app |
| 16:51 | rlb | you can see the core code in new/my_app/core.clj |
| 16:51 | justin_smith | or what rlb said |
| 16:51 | rlb | s/new/src/ |
| 16:52 | rlb | i.e. src/my_app/core.clj |
| 16:52 | eskatrem | the fact is: I am building a web app right now, and I realized I didn't know how to reproduce outside the web app simple problems |
| 16:53 | rlb | So I'm relatively new to kerodon/peridot, but it seems like wrap-ssl-redirect as :middleware breaks them. Is that expected and is there a fix, or am I just doing it wrong? |
| 16:54 | xeqi | rlb: how does it break them? |
| 16:54 | rlb | xeqi: it *seems* to be forgetting the session |
| 16:56 | rlb | i.e. to make it simple, if I try (request "/login" ... :password ...) (request "/foo"), that works fine without the redirect, but with it, the second request fails, redirecting to /login, as if it couldn't find the session or the :user in the session anymore. |
| 16:57 | rlb | (don't know for sure yet if it lost the session, or somehow cleared the user from the session) |
| 16:57 | rlb | but the latter's unlikely |
| 16:58 | rlb | xeqi: if it helps, this was via lib-noir's app-handler :middleware setting. |
| 16:58 | rlb | i.e. :middleware [#(wrap-ssl-redirect % {:ssl-port ssl-port})] |
| 16:58 | rlb | and there's also a |
| 16:58 | rlb | :access-rules [{:rule authorized-user? :on-fail redirect-to-login}] |
| 16:59 | rlb | suppose I should strip down to a trivial application and make sure I can still reproduce it there |
| 17:00 | xeqi | rlb: are you adding (follow-redirect) in between the requests? |
| 17:00 | petrust | hey peeps. I’m having some trouble getting Light Table to connect to an nREPL for a particular project. My ~/.lein/profiles.clj file contains the [lein-light-nrepl "0.0.18"] dependency and :repl-options {:nrepl-middleware [lighttable.nrepl.handler/lighttable-ops]}}. The error I get is: Unable to resolve var: lighttable.nrepl.handler/lighttable-ops in this context |
| 17:00 | rlb | xeqi: not sure that matters -- it's redirecting to /login when I ask for /foo, which I assume means it forgot who you are? |
| 17:01 | xeqi | rlb: I'm more thinking (request "/login" ...) is sending back a redirect due to wrap-ssl |
| 17:01 | rlb | but no, in the current test case, I'm not |
| 17:02 | rlb | well I can see that the login has succeeded (i.e. I print the response and it's at the normal post-login page) |
| 17:02 | rlb | let me double check that, though |
| 17:13 | rlb | xeqi: ok, thanks for the help -- it looks like it may be a url problem (which was causing unexpected redirects), at least for peridot. If that's true, then I'll have to see if the same issue applies at the kerodon level. |
| 17:15 | xeqi | quack |
| 17:26 | michaelr525 | sometimes cider returns just the first line of the stacktrace, it drives me crazy |
| 17:26 | michaelr525 | good evening |
| 17:27 | justin_smith | michaelr525: do you know about clojure.repl/pst ? |
| 17:27 | danielcompton | michaelr525: good morning |
| 17:27 | justin_smith | ~ugt |
| 17:27 | clojurebot | ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html |
| 17:29 | ben_vulpes | i'd like to get .00001 instead of 1e-5 - what is my brain failing to figure out today? |
| 17:29 | ben_vulpes | ,(/ 1 100000000) |
| 17:29 | clojurebot | 1/100000000 |
| 17:29 | ben_vulpes | ,(/ 1 100000000.0) |
| 17:29 | clojurebot | 1.0E-8 |
| 17:29 | justin_smith | ,(format "%f" 0.00001) |
| 17:29 | clojurebot | "0.000010" |
| 17:29 | ben_vulpes | justin_smith to the rescue again |
| 17:29 | ben_vulpes | thanks boss |
| 17:29 | justin_smith | heh, np |
| 17:31 | michaelr525 | justin_smith: what's clojure.repl/pst? |
| 17:32 | justin_smith | ,(1) |
| 17:32 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 17:32 | justin_smith | ,(clojure.repl/pst) |
| 17:32 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable> |
| 17:32 | justin_smith | oops |
| 17:32 | justin_smith | ,(do (1) (clojure.repl/pst)) |
| 17:32 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 17:33 | justin_smith | anyway, the repl keeps track of the last exception thrown, pst prints the stack trace for that exception |
| 17:33 | ben_vulpes | justin_smith: any way to force format to return more decimals? |
| 17:33 | gws | ,(format "%.20f" 0.0001) |
| 17:33 | clojurebot | "0.00010000000000000000" |
| 17:33 | justin_smith | ,(format "%20.20f" 0.00001) |
| 17:33 | clojurebot | "0.00001000000000000000" |
| 17:33 | justin_smith | yeah, something like that |
| 17:34 | justin_smith | gws: I guess 20 is the magic number |
| 17:34 | gws | haha guess so |
| 17:34 | gws | i know it's not a telepathic connection with you otherwise i'd be a lot smarter |
| 17:35 | justin_smith | oh, pshaw |
| 17:35 | michaelr525 | justin_smith: ok, sounds usefull.. :) |
| 17:36 | michaelr525 | but why cut the stack trace in the first place |
| 17:36 | michaelr525 | ? |
| 17:36 | ben_vulpes | ,(format "20.20%f" (/ 2 100000000.0)) |
| 17:36 | clojurebot | "20.200.000000" |
| 17:36 | amalloy | michaelr525: because newcomers complain that stacktraces are scary |
| 17:36 | ben_vulpes | d'oh |
| 17:37 | michaelr525 | amalloy: I pitty newcomers who try emacs+cider.. |
| 17:38 | michaelr525 | Looks like I use emacs all the time now, but I still kind of hate it :) |
| 17:38 | ben_vulpes | michaelr525: one must learn emacs and lisp at the same time! |
| 17:38 | justin_smith | ben_vulpes: the 20.20 means at least 20 wide, 20 points after the decimal point (kind of redundant, I was being sloppy) |
| 17:38 | ben_vulpes | fascinating, justin_smith, i have lots of javadoc reading backlog :( |
| 17:38 | ben_vulpes | the formatter in particular is a great mystery to me |
| 17:39 | ben_vulpes | learning java from clojure is a pretty hilarious experience |
| 17:40 | justin_smith | indeed |
| 17:40 | justin_smith | (that's how I learned java too) |
| 17:41 | ben_vulpes | javadocs in emacs is p neat. |
| 17:41 | amalloy | does cider hide the stacktrace by default? i thought it was just clojure's built-in repl |
| 17:41 | ben_vulpes | amalloy: mine catches the stacktrace and the puts it into its own buffer, and i haven't put the time into making it not yet. |
| 17:41 | amalloy | ben_vulpes: clojure's formatter is based on c's printf, so you can read about that and apply most of what you learned to java's |
| 17:42 | ben_vulpes | amalloy: neat! thanks. |
| 17:42 | ben_vulpes | another excuse to dabble in C. |
| 17:42 | justin_smith | amalloy: put a small ttl on any the cache for any answer to does cider [x]? |
| 17:43 | amalloy | justin_smith: yeah. a co-worker today asked me for help with cider where sometimes when he loaded his project it blew up because it couldn't find "pp" in some namespace he wasn't requiring |
| 17:43 | justin_smith | lol |
| 17:43 | amalloy | he was like "hang on i'll try getting the latest version of cider" |
| 17:43 | justin_smith | even better |
| 17:43 | amalloy | me: man i would try getting a REALLY OLD version of cider |
| 17:44 | amalloy | my 2010 swank is still running like a dream |
| 17:44 | ben_vulpes | surely you want really really really fancy stack trace handling |
| 17:44 | justin_smith | putting it that way makes me imagine some old hoopty with air fresheners on the rear view |
| 17:44 | amalloy | ben_vulpes: swank's is better! |
| 17:44 | justin_smith | duct tape on the glove box "still purrs like a kitten" |
| 17:45 | andyf_ | When one runs "java -cp clojure.jar clojure.main", how is it that the function clojure.main/main is then called? |
| 17:46 | justin_smith | andyf_: I think it is related to the fact that fns are runnable / callable |
| 17:46 | justin_smith | and you are telling java to execute that method |
| 17:46 | amalloy | andyf_: the namespace clojure.main is gen-classed, and its main(String[] args) delegates to -main |
| 17:46 | andyf_ | I mean, why clojure.main/main and not one of the other functions in that namespace? |
| 17:47 | amalloy | andyf_: actually, that was a lie |
| 17:47 | amalloy | src/jvm/clojure/main.java |
| 17:48 | amalloy | requires clojure.main, then calls clojure.main/main |
| 17:49 | andyf_ | Thanks. The only .java file in that source directory, which I have probably never noticed before |
| 17:50 | amalloy | yeah, same here |
| 17:50 | amalloy | but it was the only explanation once clojure.main turned out not to be gen-classed like i expected |
| 18:02 | jjwatt | cleaner way to say this? (reduce-kv (fn [i k v] (into i {k (if (nil? v) "unknown" v)})) {} {:ip_addr nil :id 1}) |
| 18:04 | justin_smith | whay not assoc instead of into? |
| 18:05 | justin_smith | also, you could do ({nil "unknown"} v v) but that may be excessively clever |
| 18:07 | jjwatt | oh yeah. assoc would make it a little less noisy. I seem to have gotten in the habit of using into, and I barely use assoc |
| 18:08 | jjwatt | is assoc more performant? |
| 18:09 | justin_smith | jjwatt: in that case maybe barely - since it does not need to create the hash map just to break it down again immediately |
| 18:09 | jjwatt | that's what I was thinking |
| 18:09 | justin_smith | but regardless it avoids pointless nesting |
| 18:10 | jjwatt | it could matter over millions of times, and yeah, avoiding the nesting is even more important. |
| 18:11 | jjwatt | justin_smith: looks a surprising amount nicer |
| 18:11 | justin_smith | cool |
| 18:11 | Bronsa | uh weird, I'd have expected ((fnil assoc "unknown") {} :foo nil) to work |
| 18:12 | justin_smith | fnil looks at the first arg, right? |
| 18:12 | Bronsa | I never realized fnil is positional |
| 18:13 | justin_smith | ,((fnil + 0) nil 1) |
| 18:13 | clojurebot | 1 |
| 18:13 | justin_smith | ,((fnil + 0) 1 nil) |
| 18:13 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 18:13 | eskatrem | what's fnil? |
| 18:13 | justin_smith | replaces the first arg if nil |
| 18:13 | justin_smith | otherwise acts like the function provided |
| 18:13 | Bronsa | ,((fnil + 0 0) 1 nil) |
| 18:13 | clojurebot | 1 |
| 18:14 | justin_smith | ahh, fnil is varargs, of course :) |
| 18:14 | justin_smith | I should have expected that |
| 18:14 | justin_smith | so replaces Nth arg if Nth arg is nil |
| 18:14 | Bronsa | yeah |
| 18:15 | eskatrem | so (fnil+0 0) is equivalent to #(if (nil? %) 0 (+ 1 %)) ? |
| 18:15 | justin_smith | ,((fnil assoc nil nil "unknown") {} :foo nil) |
| 18:15 | clojurebot | {:foo "unknown"} |
| 18:15 | Bronsa | justin_smith: uhm it's not vararg, only 1-to-3 |
| 18:15 | justin_smith | eskatrem: you missed some spaces in there |
| 18:15 | justin_smith | Bronsa: OK, that's weird |
| 18:16 | eskatrem | justin_smith: in my lambda? |
| 18:16 | justin_smith | in your fnil call |
| 18:16 | eskatrem | sorry I just had this chan open and I noticed something I've never seen before (fnil), so I'm just curious, so I'm bumping in the conversation with stupid questions |
| 18:17 | jjwatt | yeah, i had never seen it either |
| 18:17 | eskatrem | oh yeah right, fnil + 0, not fnil+0, of course |
| 18:17 | Bronsa | justin_smith: it is, I have no idea why it isn't vararg |
| 18:17 | clojurebot | Gabh mo leithscéal? |
| 18:17 | justin_smith | eskatrem: fnil returns a function, (fnil + 0 0) takes N numbers, and if the first or second number is nil they get replaced with 0 |
| 18:17 | Bronsa | seems like it shouldn't be hard to implement as such |
| 18:17 | justin_smith | eskatrem: otherwise it is + |
| 18:18 | jjwatt | that just prompted me to search for every fn with "nil" in the name hehe |
| 18:18 | jjwatt | it looks like it's only the two |
| 18:18 | eskatrem | justin_smith: gotcha!! |
| 18:18 | justin_smith | eskatrem: but (fnil+0 0) is an invocation of the nonexistant fnil+0 function |
| 18:18 | DomKM | Anyone familiar with what ^not-native, ^clj, and ^clj-or-nil does in cljs? |
| 18:19 | eskatrem | justin_smith: yeah exactly, asef+0 is a legal variable name in clojure |
| 18:20 | justin_smith | ,(let [?1+1=2 5] ?1+1=2) |
| 18:20 | clojurebot | 5 |
| 18:20 | hyPiRion | ,(let [ 10] ) |
| 18:20 | clojurebot | 10 |
| 18:20 | hyPiRion | those variable names. |
| 18:21 | jjwatt | justin_smith: so, can you use fnil to do the reduce-kv I was doing? |
| 18:21 | bbloom_ | hyPiRion: what is that? a non-breaking space or something? |
| 18:21 | jjwatt | seems like you would need an apply. probably uglier. |
| 18:21 | verma | can I memoize a function defined inside deftype (and implementing a protocol)? |
| 18:21 | justin_smith | ,((fnil assoc nil nil "unknown") {} :foo nil) eskatrem: yeah but it's ugly I think |
| 18:21 | clojurebot | {:foo "unknown"} |
| 18:21 | hyPiRion | bbloom_: yeah, just a nsbp which incidentally is a legal clojure variable name |
| 18:22 | hyPiRion | and, java for that matter. |
| 18:22 | Bronsa | justin_smith: http://sprunge.us/NFjC?clj |
| 18:22 | bbloom_ | hyPiRion: 'puters |
| 18:22 | bbloom_ | how do they work? |
| 18:23 | cbp | o man fnil has gotta be one of the least used functions |
| 18:23 | jjwatt | if you press the buttons the right way for long enough, money comes out |
| 18:23 | justin_smith | Bronsa: looks about right at first glance, nice |
| 18:23 | cbp | hmm or at least i had forgotten about it |
| 18:23 | bbloom_ | i use fnil all the time for (def conjs (fnil conj #{})) and (def conjv (fnil conj [])) for the purposes of update-in conjs etc |
| 18:24 | Bronsa | bbloom_: me too, I think think I only used fnil for update-in |
| 18:24 | justin_smith | bbloom_: (fnil inc 0) is a good one too |
| 18:24 | bbloom_ | ah, yes, i call that one zinc :-) |
| 18:37 | rlb | xeqi: ok, so smaller example -- with this, the session is clobbered for the second per/request: https://www.refheap.com/f951cfb67b36c8eb477c08af3 |
| 18:38 | rlb | and if we print *noir-session* from our access-rules rule function, it's valid for the first request and gone for the second one. |
| 18:39 | rlb | of course it may still be something we're doing wrong, so I'll need to narrow further |
| 18:43 | Bronsa | justin_smith: http://dev.clojure.org/jira/browse/CLJ-1486 |
| 18:43 | justin_smith | nice |
| 18:44 | ahoenigmann | added the paredit package but forward slurp isnt working |
| 18:44 | ahoenigmann | C-<right arrow> |
| 18:44 | ahoenigmann | or C-) |
| 18:45 | ahoenigmann | got this on emacs startup: |
| 18:45 | ahoenigmann | /.emacs.d/elpa/paredit-22/paredit.el at Thu Jul 31 15:34:11 2014 |
| 18:45 | ahoenigmann | In paredit-kill-region: |
| 18:45 | ahoenigmann | paredit.el:1650:4:Warning: kill-region called with 3 arguments, but accepts |
| 18:45 | ahoenigmann | only 2 |
| 18:45 | ahoenigmann | In paredit-recentre-on-sexp: |
| 18:45 | ahoenigmann | paredit.el:1765:37:Warning: `goto-line' used from Lisp code |
| 18:45 | ahoenigmann | That command is designed for interactive use only |
| 18:47 | jjwatt | Bronsa: awesome |
| 18:47 | justin_smith | ahoenigmann: just to double check, you are doing c-<right arrow> while inside the parens that should be slurping? |
| 18:47 | ahoenigmann | yes |
| 18:47 | ahoenigmann | im on mac |
| 18:47 | jjwatt | type C-h k |
| 18:47 | ahoenigmann | with meta mapped to alt key |
| 18:47 | jjwatt | and then hit right arrow |
| 18:47 | ahoenigmann | okay |
| 18:47 | jjwatt | and see what emacs tells you. er, I mean C-<right arrow> |
| 18:48 | jjwatt | C-h k C-<right> |
| 18:48 | ahoenigmann | says Describe key (or click or menu item): |
| 18:48 | ahoenigmann | in mini buffer |
| 18:48 | jjwatt | mine's always messed up in urxvt |
| 18:48 | jjwatt | and tmux |
| 18:48 | jjwatt | yeah hit c-right there |
| 18:48 | Jaood | do you guys invert cmd and option for emacs on osx_ |
| 18:48 | Jaood | ? |
| 18:48 | ahoenigmann | doesnt do anything just like in the buffer thats in paredit-mode |
| 18:49 | justin_smith | ahoenigmann: so emacs is not receiving the C-<right> keystroke |
| 18:49 | ahoenigmann | to install I just put paredit in list of packages, then i did M-x paredit-mode after emacs startup |
| 18:49 | ahoenigmann | ok |
| 18:49 | justin_smith | check your os / desktop key bindings, you may need to change one that steals that one |
| 18:49 | technomancy | ahoenigmann: many keystrokes are impossible to represent with terminal keycodes |
| 18:49 | ahoenigmann | sucks |
| 18:49 | technomancy | since ctrl and meta are represented as bitmasks on normal keycodes |
| 18:50 | technomancy | it does |
| 18:50 | ahoenigmann | so i have to use emacs outside the terminal, seems so wrong |
| 18:50 | jjwatt | there's some blargs or w/e if you google around for paredit and iterm |
| 18:50 | technomancy | ahoenigmann: not at all; just pick new bindings |
| 18:50 | jjwatt | or term or whatever it's called on macs |
| 18:50 | justin_smith | but if you use a windowed emacs it can do fancy things like inline svg! |
| 18:50 | ahoenigmann | iterm fixes this? |
| 18:51 | jjwatt | ahoenigmann: when i'm too lazy or stuborn to change my bindings, I just M-x paredit-slurp-sexp |
| 18:51 | Jaood | iterm lets you control modifiers keys |
| 18:51 | jjwatt | every key in emacs is a command |
| 18:53 | Jaood | the nice thing about vim is that key bindings do not interfere with the world ;) |
| 18:53 | justin_smith | Jaood: dunno, last time I used it it interfered with my vi muscle memory |
| 19:07 | xeqi | rlb: and this works w/o wrap-ssl? |
| 19:08 | rlb | sorry, no -- that was a red herring |
| 19:09 | rlb | it just doesn't work -- disabling our access-rules *does* fix it, but I'm not sure yet if that's symptom or related to cause |
| 19:10 | xeqi | rlb: I've never really worked wit hlib-noir, but my instinct is to say if *noir-session* isn't being populated then the correct cookie must not be kept between request 1 and 2 |
| 19:11 | rlb | xeqi: ok -- thanks -- I'll keep poking around -- see if I can isolate the problem better. |
| 19:12 | xeqi | is it possible to print the response state out and the next request to see if the cookies make it across correctly? |
| 19:14 | justin_smith | rlb: is this way of wrapping the session the type where you need to explicitly put any data to be persisted under the :session key of your response? |
| 21:03 | ben_vulpes | does anyone know why clj-time.format/formatter takes either a string or a datetimezone and many strings? what are the implications of using a formatter without a datetime zone? |
| 21:07 | gws | you get UTC if you don't specify a tz |
| 21:08 | ben_vulpes | gotcha |
| 21:18 | gozala | can someone please help me figure out why do I get this error ? |
| 21:18 | gozala | https://gist.github.com/Gozala/fc26deeabac7e05e42c6 |
| 21:20 | timsg | gozala: try making it state#? |
| 21:21 | DomKM | gozala: also diff# |
| 21:21 | timsg | gozala: and model# |
| 21:21 | timsg | though I guess you don’t use it |
| 21:22 | amalloy | well, he probably wants the field to be publicly visible and named state, not state__1234__auto__5678 |
| 21:22 | amalloy | oh, but that's just the method param |
| 21:34 | xeqi | has anyone put together a list of design pattenrs for clojure? |
| 21:35 | justin_smith | xeqi: many of us agree with stuart halloway http://thinkrelevance.com/blog/2007/05/17/design-patterns-are-code-smells |
| 21:35 | xeqi | justin_smith: but yet things like "middleware" still exist |
| 21:36 | xeqi | fwiw I agree w/ respect to many of the gof patterns |
| 21:36 | justin_smith | it's true, but I think anyone who tried to write the "clojure design patterns" book would get shown that blog post, and would likely be expected to at least respond to it |
| 21:36 | xeqi | cat theory based patterns... maybe |
| 21:37 | brehaut | if you think of patterns as common solutions to acknowledged tradeoffs (identifying the pros and cons of said trade off) then the idea that they can be languages with no patterns is absurd |
| 21:38 | brehaut | even the gof book has patterns that it basically says ‘this is what we do in C++ but in smalltalk its just a block' |
| 21:38 | justin_smith | brehaut: that's a good point |
| 21:38 | john2x | I like this comment in the article: "Design patterns are programming language smell." |
| 21:39 | justin_smith | brehaut: and even if it is just using simple language features (or a well respected community lib), it's good to document how they are most successfully used |
| 21:39 | brehaut | i think in clojure the tendancy is to write a little library that packages an idiom up as functions or macros (ie, semi-formally) rather than as text on a webpage |
| 21:40 | brehaut | explaining to new clojure programmers when to use agents, atoms and refs is in a lot of ways the same sort of discussion as when to use various patterns |
| 21:40 | justin_smith | yeah, we can reify patterns into functions or syntax quite trivially, but it is still useful to document |
| 21:41 | brehaut | right |
| 21:41 | xeqi | I'm a fan of naming things makes it easier to communicate them |
| 21:41 | justin_smith | so instead of "which pattern to use here?" we can end up with "should I use an agent or a go block for this" |
| 21:43 | brehaut | xeqi: totally agreed |
| 21:47 | brehaut | justin_smith, xeqi: i think the other thing is that once you get past basic language deficiencies, patterns tend to be architectural rather than simply behavioural |
| 21:47 | brehaut | s/behavioural/implementational/? |
| 21:47 | xeqi | brehaut: do you have an example of the later? |
| 21:47 | brehaut | xeqi: strategy is a poor mans first class function |
| 21:52 | xeqi | ah right, looking up the gof book and it has creational / structural / behavioural |
| 21:52 | xeqi | been awhile since I've leafed through it |
| 21:53 | brehaut | the nuts and bolts of the book have mostly aged into irrelevance |
| 21:53 | brehaut | but the discussion around it is still quite intereseting i think |
| 22:28 | LukePaul | I am trying to figure out defrecord. I am wanting to implement my own "empty?" method for the record that I am making, but I don't quite understand what I am doing. Like what protocol should I be using for this? |
| 22:28 | bbloom_ | empty? is already defined for records... |
| 22:28 | bbloom_ | ,(defrecord EmptyRecord []) |
| 22:29 | clojurebot | sandbox.EmptyRecord |
| 22:29 | bbloom_ | ,(empty? (EmptyRecord.)) |
| 22:29 | clojurebot | true |
| 22:29 | bbloom_ | ,(empty? (assoc (EmptyRecord.) :x 1)) |
| 22:29 | clojurebot | false |
| 22:29 | bbloom_ | but generally, records with fields can't be empty: |
| 22:29 | bbloom_ | ,(defrecord Foo [x]) |
| 22:29 | clojurebot | sandbox.Foo |
| 22:29 | bbloom_ | ,(Foo. 1) |
| 22:29 | clojurebot | #sandbox.Foo{:x 1} |
| 22:29 | bbloom_ | ,(dissoc (Foo. 1) :x) ; note: no longer a Foo |
| 22:29 | clojurebot | {} |
| 22:34 | LukePaul | My record has a cljs.core.async channel that acts as a queue and I have a field (queue-count) that records the number of items in that queue. I was hoping to override empty? to check if the queue-count is 0 or less. |
| 22:35 | bbloom_ | that seems unwise |
| 22:36 | bbloom_ | (doc empty?) |
| 22:36 | clojurebot | "([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))" |
| 22:36 | bbloom_ | your use doesn't seem to match that doc string |
| 22:36 | bbloom_ | if you want a map-like thing, you (preferably just use a map or) use defrecord |
| 22:36 | bbloom_ | alternatively, you can make custom data structures with deftype |
| 22:36 | bbloom_ | but in this case, it sounds like you just want to define a function of your own |
| 22:37 | justin_smith | LukePaul: sounds more like .available than empty? |
| 22:48 | LukePaul | Thanks, I wasn't convinced that I was doing it right, so that helps. I will just define a new function outside of the record to check. |
| 22:54 | kelseygi | i wrote this function so i could use it in a ->> : https://www.refheap.com/88784 |
| 22:55 | kelseygi | is there a simpler/more idiomatic way to do that? |
| 22:55 | justin_smith | (identity coll) is coll |
| 22:55 | justin_smith | and defn contains an implicit do |
| 22:56 | justin_smith | (defn log-size [coll] (log/debug (str "filtering " (count coll) " items")) coll) |
| 23:01 | kelseygi | oh duh |
| 23:01 | kelseygi | thanks! |
| 23:01 | kelseygi | there isn't like a "run" with side effects that returns what's passed in? |
| 23:01 | justin_smith | doto |
| 23:02 | justin_smith | but that goes by first arg, not last |
| 23:02 | justin_smith | otherwise I would have suggested it :) |
| 23:02 | justin_smith | ,(doto 1 println) |
| 23:02 | clojurebot | 1\n1 |
| 23:02 | kelseygi | ah ok! that'd work with -> then |
| 23:02 | justin_smith | yeah |
| 23:02 | justin_smith | even works with more args... |
| 23:03 | justin_smith | ,(doto 1 (println "is the loneliest number...")) |
| 23:03 | clojurebot | 1 is the loneliest number...\n1 |
| 23:03 | justin_smith | very similar to -> actually |
| 23:03 | justin_smith | someone should make otod, for ->> forms |
| 23:04 | justin_smith | or maybe dotoo, to follow the -> to ->> transformation |
| 23:11 | oskarkv | Hm ""Parameter declaration let should be a vector" pointing to the closing paren of this function declaration https://www.refheap.com/93692024c74d2fb9536b51134 Am I blind or what's the problem? |
| 23:14 | justin_smith | I see nothing wrong there (except for that dirty naughty mutation) |
| 23:18 | oskarkv | Oh, now I see it, in the next function. :P |
| 23:20 | oskarkv | Thanks for taking a look justin_smith |
| 23:21 | justin_smith | np |
| 23:44 | ben_vulpes | the funniest part about cider is how " Error compiling: |
| 23:44 | ben_vulpes | /Users/mrfox/repos/van/api/test/van/handler_test.clj:368:17" |
| 23:44 | ben_vulpes | is not linked to the source |
| 23:45 | justin_smith | wow, in emacs that is really low hanging fruit |
| 23:45 | justin_smith | compilation mode alreayd has all the code to parse that file / line / char info |