2012-06-17
| 00:01 | loliveira | and i just checked. there is no ring.server.leiningen in my source code. |
| 00:01 | xeqi | loliveira: what is noir 1.2.2.1-patch ? |
| 00:04 | loliveira | xeqi: https://github.com/loliveira/noir/blob/master/project.clj#L4 |
| 00:06 | xeqi | you're requiring hiccup 0.3.7 in that project.clj, which is not compatible with 1.0.0 |
| 00:06 | loliveira | xeqi: and... https://github.com/loliveira/compojure/commit/ef382f5e1679aec90ee5fe088047247827cd1846 |
| 00:06 | loliveira | xeqi: bingo |
| 00:11 | loliveira | xeqi: changed to [hiccup "0.3.7"] and error persists. =/ |
| 00:12 | xeqi | which error? |
| 00:13 | arrdem | anyone know a good tutorial for building websites with Clojure? |
| 00:13 | loliveira | java.io.FileNotFoundException: Could not locate |
| 00:13 | loliveira | +hiccup/page_helpers__init.class or hiccup/page_helpers.clj on classpath |
| 00:15 | xeqi | what version of lein are you using? |
| 00:17 | loliveira | Leiningen 1.7.1 on Java 1.6.0_31 Java HotSpot(TM) 64-Bit Server VM |
| 00:18 | xeqi | what version of hiccup ends up in lib/? |
| 00:22 | loliveira | 0.3.7 |
| 00:27 | akhudek | arrdem: the clojure noir tutorials should help |
| 00:28 | akhudek | unless you want to try clojurescript as well |
| 00:28 | akhudek | clojurescript is not well documented at the moment |
| 00:29 | xeqi | loliveira: your custom noir uses hiccup 0.3.7. that means ring-devel 1.0.2, ring 1.0.2, ring-server 0.2.1, and lein-ring 0.6.7 are the lastest you can use |
| 00:31 | loliveira | xeqi: makes a lot of sense. |
| 00:35 | loliveira | i removed ring-server "0.2.3", now i back with the original error. =) |
| 00:37 | loliveira | Could not locate ring/server/leiningen__init.class or ring/server/leiningen.clj on classpath |
| 00:38 | xeqi | what version of lein-ring ? |
| 00:39 | loliveira | :dev-dependencies [[lein-ring "0.7.1"]] |
| 00:41 | xeqi | with lein 1.7.1 that should be in :plugins |
| 00:42 | loliveira | same error. |
| 00:42 | arrdem | akhudek: thanks I'll check it out. |
| 00:42 | xeqi | try 0.6.7 |
| 00:49 | loliveira | smae error with: 0.6.7 0.6.6 0.6.5 0.6.4 0.6.3 0.6.2 0.6.1 |
| 00:49 | loliveira | but |
| 00:49 | loliveira | different error with 0.6.0 |
| 00:50 | loliveira | http://pastebin.com/jNC1K9eE |
| 00:58 | jayunit100__ | technomancy: oops i just issued a pull request to leiningan that was a bit of a mistake. Sorry sir ! I meant to simply edit the readme in the main site to link to the stable version rather than the main version. |
| 06:08 | _ulises | morning |
| 06:15 | atc-- | hey, I've come across a peculiarity that my inexperience can't explain. Can someone help me understand what I'm doing wrong? |
| 06:15 | atc-- | http://pastebin.com/8yJhyeV1 |
| 06:18 | raek | atc--: a string can be used as a sequence of characters, but you try to use it as a sequence of strings |
| 06:18 | atc-- | raek, I feel stupid |
| 06:18 | atc-- | raek, so I just need to (int ch) the chars instead of sequencing them to strings |
| 06:19 | raek | (defn is-period? [c] (or (= \. c) (= \, c))) |
| 06:19 | atc-- | raek, question is though, why is it getting characters when ltrs is a secquence of strings |
| 06:19 | atc-- | raek, ok |
| 06:19 | raek | ah, didn't see that |
| 06:20 | raek | (the (map str (seq w)) thing |
| 06:20 | atc-- | see what I mean? |
| 06:20 | atc-- | ltrs is defined as a sequence of strings |
| 06:20 | atc-- | rightly or wrongly |
| 06:21 | atc-- | so given I'm probably pointlessly converting to a seq of strings |
| 06:21 | raek | atc--: also you are calling filter on a single element |
| 06:21 | atc-- | there is still a bit of oddness in the behaviour |
| 06:21 | atc-- | raek, so? |
| 06:21 | raek | which happened to be a string, which is seqable in your case |
| 06:21 | atc-- | yeah |
| 06:21 | atc-- | but a seq of chars |
| 06:22 | atc-- | I wanted (granted, naively) a seq of strings |
| 06:22 | atc-- | hence the let bindings to (map str (seq w)) |
| 06:22 | atc-- | so I can convert to an ascii val later on |
| 06:22 | raek | I would do (+ (if (is-capital? (first ltrs)) 1 0) (count (filter is-period? (rest ltrs)))) |
| 06:22 | atc-- | yeah |
| 06:22 | atc-- | I'm just curious why they're chars and not strings when the filter calls is-capital> |
| 06:22 | atc-- | *? |
| 06:22 | clojurebot | * is just for when you are lazy and sloppy |
| 06:23 | raek | I don't see why having the individual characters as strings simplify things |
| 06:23 | atc-- | raek, it doesn't |
| 06:23 | raek | first you stringify them with str and then you extract the char again with (.charAt c 0) |
| 06:23 | atc-- | raek, it's making it worse. I'm changing that |
| 06:23 | atc-- | raek, I just want to understand why they're chars at runtime when my understanding suggests they should be strs |
| 06:24 | raek | atc--: filter operates on sequences of elements, but you gave it a single element |
| 06:24 | atc-- | raek, right, but that element is a str, no? |
| 06:24 | raek | you could do (filter is-capital? [(first ltrs)]) |
| 06:25 | raek | atc--: yes, but you want to pass a sequence of strings to that filter, not a sequence of chars |
| 06:25 | atc-- | right |
| 06:25 | atc-- | so |
| 06:25 | raek | since your is-capital? expects a string, not a char |
| 06:25 | atc-- | does (first ltrs) return a one-element seq of chars or strings? |
| 06:25 | raek | no |
| 06:25 | atc-- | yes, but ltrs is a seq of strings, so when I (first ltrs) I get a one-element seq of str, now? |
| 06:26 | atc-- | no, I mean, not "now" |
| 06:26 | raek | if a is ("foo" "bar"), a seq of strings, then (first a) is "foo", a string |
| 06:26 | atc-- | agreed |
| 06:26 | raek | in the first case you give filter something like "foo", in the second case you give filter something like ("foo" "bar") |
| 06:27 | atc-- | yet is-capital? expects a string to -- badly done, granted -- convert to a character to then convert to an int |
| 06:27 | atc-- | No matching method found: charAt for class java.lang.Character ----- that's the error at runtime |
| 06:27 | atc-- | I shoujld've clarified that further |
| 06:27 | atc-- | earlier, rather |
| 06:28 | raek | atc--: do you understand why is-capital? receives a character? |
| 06:28 | atc-- | raek, I'm sorry, I don't. |
| 06:28 | atc-- | I am new to clojure so forgive my confusion. |
| 06:28 | raek | do you know that (filter f coll) runs the function for f for each element in coll? |
| 06:28 | atc-- | yes |
| 06:28 | raek | so what type is coll in the first case? |
| 06:29 | atc-- | seq of str, with one element? |
| 06:29 | raek | no, a single string |
| 06:29 | atc-- | OH |
| 06:29 | raek | ltrs is a seq of strings |
| 06:29 | atc-- | I should've RTFM'd on first |
| 06:29 | atc-- | yeah |
| 06:30 | atc-- | so, |
| 06:30 | raek | anyway, using characters rather than one-char-strings should make your code shorter |
| 06:30 | atc-- | (first ltrs) gives me "h" |
| 06:30 | atc-- | and that is then passed to is-capital? |
| 06:30 | atc-- | correct? |
| 06:30 | atc-- | so |
| 06:30 | raek | no |
| 06:30 | atc-- | ok |
| 06:30 | raek | "h" is treated as a sequence of things |
| 06:31 | raek | remember, filter expects a sequence in that position |
| 06:31 | atc-- | yeah |
| 06:31 | raek | and strings can be treaded as sequences in clojure |
| 06:31 | atc-- | and I'm giving it a string |
| 06:31 | atc-- | I get you |
| 06:31 | raek | ,(seq "hello") |
| 06:31 | clojurebot | (\h \e \l \l \o) |
| 06:31 | atc-- | gotcha |
| 06:31 | atc-- | thanks for explaining and for the patience! |
| 06:31 | raek | they are treated as sequences of their characters |
| 06:31 | atc-- | yeah |
| 06:31 | atc-- | which I should be doing in the first place |
| 06:31 | raek | so is-capital? receives \h, not "h" |
| 06:31 | atc-- | but was just curious why my already bad code was misbehaving |
| 06:32 | atc-- | yeah |
| 06:32 | atc-- | got you now |
| 06:32 | atc-- | thanks :) |
| 06:32 | atc-- | I've simplified it all anyhow |
| 06:32 | atc-- | so just using chars |
| 06:32 | raek | but since (first ltrs) is always one element, you could do (if (is-capital? (first ltrs)) 1 0) |
| 06:33 | raek | no need to loop over each element of a seq if the seq is always of length one |
| 06:33 | atc-- | raek, yeah |
| 06:33 | raek | but if you really want that, then you need to make a seq of one element: (filter is-capital? [(first ltrs)]) |
| 06:34 | atc-- | right |
| 06:34 | atc-- | I think we both agree I don't want that! :D |
| 06:34 | atc-- | unless I'm trying to right superfluous code, which I'm not |
| 07:55 | si14 | anyone who wrote big web-apps with CLJS here? |
| 08:45 | antoineB | hello |
| 08:45 | ohpauleez | Hi antoineB |
| 09:30 | si14 | looks like there is a bug in CLJS — ::foobar in ns "test" is actually :user/foobar instead of :test/foobar |
| 09:33 | gfredericks | si14: I don't think that's a CLJS bug; that's a byproduct of cljs using clojure's reader |
| 09:34 | antoineB | how can i extract from a list of number the frequency of each number? |
| 09:34 | antoineB | i need some sort of mutable map |
| 09:34 | gfredericks | ,(frequencies [2 3 3 2 4 2 5]) |
| 09:34 | clojurebot | {2 3, 3 2, 4 1, 5 1} |
| 09:34 | gfredericks | antoineB: mutable map..? |
| 09:35 | raek | antoineB: no, you can use recursion instead of mutation (or use an already available function in the standard library) |
| 09:35 | antoineB | i don't know the frequencies function thanks |
| 09:36 | antoineB | raek: how? |
| 09:36 | gfredericks | antoineB: if you wanted to implement it yourself you should be able to use reduce |
| 09:36 | raek | ,(loop [m {}, coll [2 3 3 2 4 2 5]] (if (empty? coll) m (recur (update-in m [(first coll)] (fnil inc 0)) (rest coll))) |
| 09:36 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 09:36 | raek | ,(loop [m {}, coll [2 3 3 2 4 2 5]] (if (empty? coll) m (recur (update-in m [(first coll)] (fnil inc 0)) (rest coll)))) |
| 09:36 | clojurebot | {5 1, 4 1, 3 2, 2 3} |
| 09:38 | raek | antoineB: it's not the map itself you need to update, it's which map is the current one |
| 09:38 | gfredericks | ,(reduce (fn [m x] (update-in m [x] (fnil inc 0))) {} [2 3 3 2 4 2 5]) |
| 09:38 | clojurebot | {5 1, 4 1, 3 2, 2 3} |
| 09:38 | cshell | hah,t hat's what I was just oging to type! |
| 09:38 | raek | loop/recur and fn/recur provide the basic way of "updating" variables in clojur |
| 09:40 | raek | the most common iteration patterns have already been factored out into higher order functions like map, filter, and reduce |
| 09:42 | antoineB | raek: gfredericks: tanks |
| 09:57 | antoineB | http://pastebin.com/B4y1sDT7 |
| 09:58 | antoineB | it is a function which give the higher element (in term of frequencie) from a frquencies sequence |
| 09:58 | antoineB | is there better way to do it? |
| 09:59 | raek | ,(max-key second {2 3, 3 2, 4 1, 5 1}) |
| 09:59 | clojurebot | {2 3, 3 2, 4 1, 5 1} |
| 09:59 | raek | ,(apply max-key second {2 3, 3 2, 4 1, 5 1}) |
| 09:59 | clojurebot | [2 3] |
| 10:00 | raek | antoineB: also, in you most recent paste you could keep the two components of m as separate variables |
| 10:00 | antoineB | ,(max-key second (frequencies '(1 2 3 2 5 2 3))) |
| 10:00 | clojurebot | {1 1, 2 3, 3 2, 5 1} |
| 10:01 | raek | ,(apply max-key second (frequencies '(1 2 3 2 5 2 3))) |
| 10:01 | clojurebot | [2 3] |
| 10:02 | raek | antoineB: max-key expects the elements as separate arguments |
| 10:02 | antoineB | ok |
| 10:03 | antoineB | raek: i don't understand what you say about my paste |
| 10:03 | raek | antoineB: sorry, I was reading your code wrong |
| 10:07 | si14 | what am I doing wrong? https://gist.github.com/cb2458433ee72b72417d |
| 10:07 | si14 | this code falls to infinite loop |
| 10:07 | si14 | printing "assoc!" all the time |
| 10:08 | jjido | er, reify |
| 10:08 | si14 | yeah |
| 10:08 | si14 | I'm trying to mimic backbone with it's models that emit messages when some field is changed |
| 10:09 | Chousuke | your assoc method implementation calls itself recursively |
| 10:10 | si14 | Chousuke: yeah, I know. there is a similar example in clojuredocs for Clojure, don't think that that one loops too |
| 10:10 | si14 | http://clojuredocs.org/clojure_core/clojure.core/reify here it is |
| 10:11 | raek | antoineB: I was thinking about something like this: https://gist.github.com/2944661 |
| 10:11 | Chousuke | that one doesn't call seq on this, it calls seq on f |
| 10:12 | piranha | hmm.. how do I supply clojurescript externs to cljsbuild? |
| 10:14 | si14 | Chousuke: yeah, I see now, thank you. but if I call (-assoc map k v) in that example I miss reified version of map; how can I avoid loop and keep reified version? |
| 10:14 | Chousuke | si14: call the function that creates the reified map with the updated map as parameter |
| 10:15 | Chousuke | si14: that avoids calling the method, but creates a new reified thing for you |
| 10:15 | si14 | Chousuke: yeah, got it. Thanks a lot! |
| 10:17 | antoineB | raek: i don't understand the meaning of the "let"s specialy the second vector parameter |
| 10:32 | gfredericks | antoineB: you're talking about line 2 in raek's gist? |
| 10:32 | ArvinJA | hello there |
| 10:32 | ArvinJA | Trying out overtone and am new to clojure |
| 10:33 | ArvinJA | there are some clj files |
| 10:33 | ArvinJA | How do I run them outside of REPL? |
| 10:33 | si14 | Chousuke: if I reify one of protocols, others are lost? |
| 10:33 | Chousuke | si14: lost? |
| 10:35 | ArvinJA | seems like "java -cp clojure.jar clojure.main scriptname.clj" should work |
| 10:35 | si14 | Chousuke: https://gist.github.com/209b5b7fead972e01296 |
| 10:35 | antoineB | gfredericks: i am talking about the 2 "let" sexpression |
| 10:35 | antoineB | i don't understand the bindings |
| 10:36 | antoineB | so line 2 and 8 |
| 10:37 | gfredericks | antoineB: it is using destructing; the expectation on line 2 is that (first coll) is a seq with at least 2 elements |
| 10:37 | ArvinJA | E:\overtone\examples>java -cp clojure.jar clojure.main blues.clj |
| 10:37 | ArvinJA | Error: Could not find or load main class clojure.main |
| 10:37 | antoineB | gfredericks: ok |
| 10:37 | gfredericks | (let [[first-value first-freq] (first coll)] ...) is equivalent to (let [foo (first coll), first-value (first foo), first-freq (second foo)] ...) |
| 10:38 | si14 | Chousuke: looks like I'm missing something :) |
| 11:04 | si14 | dnolen: ping |
| 11:42 | dnolen | ohpauleez: ping, yesterday - no protocol method -hash error, is that still a problem, we have default now in master |
| 11:42 | dnolen | si14: pong |
| 11:43 | si14 | dnolen: hi. first of all — recently saw a record of your talk on dispatch, it's amazing :) |
| 11:44 | ohpauleez | dnolen: I haven't seen it for awhile now, it was my most common error |
| 11:44 | dnolen | ohpauleez: k good to hear - yeah should no longer occur |
| 11:44 | dnolen | si14: thanks! |
| 11:45 | si14 | dnolen: and here is a question: how would you implement a modification of map that calls something on each modification of it's field? I'm speaking about CLJS |
| 11:46 | dnolen | si14: hard to say without knowing what you are trying to achieve. |
| 11:46 | si14 | I've tried something like this https://gist.github.com/cb2458433ee72b72417d , but reify returns a new class; extend-type is nice, but I can't call a "super-method" from there, can I? |
| 11:47 | dnolen | si14: there's no inheritance of any kind in CLJS, if that's what you mean. |
| 11:47 | si14 | dnolen: I'm trying to build something like Backbone, because currently I'm not aware of any kind of useful framework in CLJS. |
| 11:48 | dnolen | si14: so I take it you're thinking about the data binding problem? |
| 11:48 | si14 | dnolen: yeah. the idea is pretty simple: just generate an event (using Closure's PubSub, for example) every time when some field is changed |
| 11:49 | ohpauleez | si14: I do that almost exact thing in Shoreleave's PubSub system |
| 11:49 | si14 | it can be achieved with atom and watcher, but unfortunately the only way to check what particular field was changed is comparing old and new map, I don't think that it's reasonable |
| 11:49 | ohpauleez | but I have a Function deftype that I abuse |
| 11:50 | ohpauleez | it's a generic decorator for shaping functions, at the heart of it |
| 11:50 | si14 | ohpauleez: what's Shoreleave? |
| 11:50 | ohpauleez | si14: A group of utilities to make CLJS apps |
| 11:51 | ohpauleez | with a focus on security, HTML5 feature sets, and CLJS's capabilities |
| 11:51 | ohpauleez | Embedded workers, a removing package, and a pub sub system to declaratively bind it all together |
| 11:51 | dnolen | si14: there's a few people interested in this problem space. Including Kevin Lynagh (C2), Chris Granger (Light Table), Kovas Boguta (Session) |
| 11:51 | ohpauleez | We've all taken slightly different approaches |
| 11:52 | ohpauleez | but they all complement each other |
| 11:52 | ohpauleez | I don't think any of us have the final answer |
| 11:52 | dnolen | si14: I think a new official abstraction is warranted if people can agree upon something. |
| 11:52 | si14 | ohpauleez: found your repo at github. is there any example of it? |
| 11:53 | dnolen | ohpauleez: yes, but it seems like a missed opportunity to create a new reference type, data structure, protocol - no idea what it should look like of course. But it seems like we have enought smart people to figure this out :) |
| 11:53 | ohpauleez | dnolen: For sure |
| 11:54 | ohpauleez | si14: I'm cutting shoreleave up right now. Then I'm moving in the few example apps I have |
| 11:54 | ohpauleez | Tutorspree has built some serious client-side apps |
| 11:54 | si14 | ohpauleez: there is a nice thing called "todo mvc" here: http://addyosmani.github.com/todomvc/ |
| 11:54 | ohpauleez | I worked on that example last night |
| 11:55 | si14 | the problem is that I didn't find anything even close to https://github.com/addyosmani/todomvc/blob/master/architecture-examples/backbone/js/todos.js |
| 11:55 | ohpauleez | I'm going to do a TODO app and a client-side only searching app |
| 11:55 | si14 | in terms of conciseness at least. |
| 11:55 | ohpauleez | I feel like I've nailed the conciseness |
| 11:56 | ohpauleez | Also you have to realize a lot of these client-side only apps make no assumptions about security |
| 11:56 | ohpauleez | you need to bolt it all on as an after thought |
| 11:56 | ohpauleez | it's baked into Shoreleave |
| 11:56 | si14 | ohpauleez: can you share your results? |
| 11:56 | si14 | ohpauleez: I mean TODO |
| 11:57 | ohpauleez | It'll be pushed as soon as I finish cutting Shoreleave up and putting up the new repos (in the Shoreleave organization on github) |
| 11:59 | ohpauleez | dnolen: I think we're all close on the binding piece - but definitely something worth talking about over beers on Wednesday |
| 11:59 | dnolen | ohpauleez: sounds good! |
| 11:59 | si14 | kinda sad. we are just in the middle of the "maybe we should just rewrite it to Coffee instead of messing with framework invention" moment, so your example can change the final decision. |
| 12:00 | dnolen | si14: I will say I'm not a fan of any of the JS MVCs, Backbone.js included. |
| 12:00 | ohpauleez | I also agree with that si14 ^ |
| 12:00 | si14 | dnolen: me neither, but sometimes we just need some stuff done. |
| 12:00 | dnolen | si14. for sure. |
| 12:01 | si14 | dnolen: at least I wouldn't try CLJS if I like JS :) |
| 12:01 | ohpauleez | si14: Are you in the NYC area? |
| 12:01 | si14 | ohpauleez: nope, Russia |
| 12:01 | si14 | unfortunately :) |
| 12:01 | ohpauleez | Ahh, if you can hold off for a little longer, I'll have Shoreleave examples up and probably a screencast of a build out |
| 12:02 | ohpauleez | But that's two or so weeks out |
| 12:02 | si14 | ohpauleez: I'm sorry if I was a little too persevering :) |
| 12:03 | ohpauleez | haha nah |
| 12:07 | si14 | ohpauleez: did you see "static" templates in Enfocus? |
| 12:07 | si14 | sorry, "compiled" |
| 12:07 | ohpauleez | si14: Yeah - definitely cool stuff |
| 12:08 | ohpauleez | I use enfocus in all of my CLJS apps, but I haven't used the compiled templates |
| 12:08 | ohpauleez | For me, my apps look like this: |
| 12:09 | ohpauleez | Build some static HTML and CSS. Write a bunch of pure functions. Wire the functions up with my pub sub system. Use enfocus' listeners as entry points into the pub sub system. Use Enfocus' actions as exit points in the pub system |
| 12:10 | ohpauleez | SL's pub sub allows for Local Storage to be published too, so that solves a lot of problems |
| 12:10 | si14 | ohpauleez: why not Closure's PubSub? |
| 12:11 | ohpauleez | You can subscribe to atoms, workers, and functions |
| 12:11 | ohpauleez | si14: It's built on top of that, but as a implementation of a protocol |
| 12:11 | ohpauleez | because you might need cross doc or an xpc bus |
| 12:11 | ohpauleez | and Closure's pub sub isn't crossdoc |
| 12:11 | ohpauleez | also it only supports strings as topics |
| 12:12 | ohpauleez | and I want to use it to declaratively bind my entire app |
| 12:12 | ohpauleez | So two protocols - one to describe buses. One to describe publishables |
| 12:12 | ohpauleez | And you can extend the system ala carte to anything that comes along |
| 12:13 | si14 | ohpauleez: sounds great. bad for us that we didn't start like 2 month later :) |
| 12:14 | ohpauleez | si14: It's definitely the wild west |
| 12:14 | ohpauleez | "wild west" with CLJS |
| 12:19 | bobry | wild west indeed :) |
| 13:06 | jayunit100_ | how integrated is the clojurescript ui tools. Do we have to use jquery ? Id like to do some GWT style development with clojurescript if possible (i.e. have it do my layouts and stuff for me, convention over configuration style). |
| 13:08 | jayunit100_ | I mean, I know its just a JS generator, at its core, but I'm assuming the goal is to wrap JS in a lisp style of GWT, like A DSL for JS web apps. But maybe I'm wrong. |
| 13:11 | cshell | do you mean that since GWT compiles to JS, that CLJS is similar as it takes Clojure and compiles to JS? |
| 13:13 | dnolen | jayunit100_: you have Google Closure if you want a widget library. being like GWT is a non-goal. |
| 13:13 | cshell | yeah, I am missing the GWT/CLJS connection |
| 13:16 | jayunit100_ | cshell: yeah, thats what i meant. |
| 13:16 | jayunit100_ | but also - |
| 13:16 | jayunit100_ | that GWT looks "good" out of the box :) Convention over configuration. |
| 13:18 | jayunit100_ | So, clojurescript and GWT are BOTH compilers to JS. But GWT is convention over configuration, I believe, whereas ClojureScript is not. I'd like a ClojureScript framework that was convention over configuration, like GWT, SproutTools, ExtJS…. |
| 13:19 | jayunit100_ | of course, if the only goal of CLJS is to wrap JS, than my question is quite silly. |
| 13:19 | cshell | My understanding is that CLJS helps you write javascript code via clojure - if you want those things, you could just leverage the EXTJs libraries |
| 13:19 | gelvaos | hi! |
| 13:19 | cshell | I tihink the goal is to wrap js and then you can leverage the native libraries |
| 13:19 | cshell | call the extjs libraries from clojurescript |
| 13:20 | cshell | you could build a clojure idiomatic wrapper library over ext-js |
| 13:20 | jayunit100_ | cshell: thats a good idea. |
| 13:20 | cshell | just like they do with all the java libraries in the jvm |
| 13:20 | gelvaos | does anybody had experience with setup and usage of hypermedia.video.OpenCV in clojure? |
| 13:23 | jayunit100_ | arg web guis got so complicated while i was away |
| 13:31 | ohpauleez | jayunit100_: Rather than fight upstream, I'd take some time and see how people are generating CLJS ui's now |
| 13:31 | ohpauleez | you might like another approach better |
| 13:32 | ohpauleez | otherwise, you could generate JS with GWT, make an externs file, and wrap it all up with CLJS. But that'd be a headache |
| 13:33 | jayunit100_ | ohpauleez: yeah, i see what you mean. where are the best CLJS apps. Are there any good CLJS app templates out there ? |
| 13:33 | jayunit100_ | (client only, i already have a backend) |
| 13:34 | ohpauleez | jayunit100_: ClojureScript One, Take a look at Kevin Lynagh's C2 demos, dig through some of Chris Granger's gists |
| 13:34 | ohpauleez | Take a look at the enfocus demos |
| 13:36 | jayunit100_ | ohpauleez: ok thanks |
| 13:36 | ohpauleez | np |
| 13:42 | uvtc | How does one get started with editing the confluence wiki? I've created an account there, but there doesn't seem to be any way to edit pages. |
| 13:44 | ohpauleez | uvtc: You need to request for a bump in permissions on the dev mailing list |
| 13:44 | uvtc | ohpauleez, Does editing the confluence wiki require signing/mailing-in the CA? |
| 13:44 | dnolen | uvtc: yes |
| 13:45 | uvtc | Thanks! |
| 14:25 | muhoo | c2? |
| 14:27 | gfredericks | d3! |
| 14:29 | muhoo | gfredericks: you sunk my battleshiip! |
| 14:29 | muhoo | wtf is c2? probably the most ungoogleable abbrev evah |
| 14:31 | gfredericks | oh I see. I did not look far enough back in the conversation |
| 14:32 | muhoo | nm, found it http://keminglabs.com/c2/ |
| 14:33 | gfredericks | perhaps it is an inelastic compute cloud? |
| 14:34 | muhoo | naw, data visualization, clojure version of d3 |
| 14:34 | muhoo | so your guess was really good |
| 14:54 | pipeline | for some reason it bothers me |
| 14:54 | pipeline | that slime still tells me that lemonodor fame is only a hack away |
| 14:54 | pipeline | since lemonodor has so long left us |
| 15:21 | gfredericks | writing clojure.core/map in core.logic takes some thinks |
| 15:26 | lynaghk | si14: there's a C2-implementation of todo mvc here: https://github.com/lynaghk/c2-demos/tree/master/todoMVC |
| 15:27 | lynaghk | Haven't had time to give serious thought to doing more knockout.js-like two-way data binding abstraction between cljs structures and DOM elements (e.g., same interface for reading/writing DOM checkboxes or text areas or some such) |
| 15:28 | lynaghk | this demo is basically single direction binding from data -> UI, with manual event handlers that alter the data in response to user actions. |
| 15:34 | Jack57 | ciao |
| 15:50 | jayunit100 | hmmm |
| 15:50 | jayunit100 | No matching field found: contains for class java.lang.String |
| 15:50 | jayunit100 | ,(.contains "AA" "A") |
| 15:50 | clojurebot | true |
| 15:50 | gfredericks | ,(.contains "AA" :foo) |
| 15:50 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.CharSequence> |
| 15:51 | gfredericks | ,(.contains "AA" :foo :bar) |
| 15:51 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: contains for class java.lang.String> |
| 15:51 | jayunit100 | I would assume that there should always be a (.contains…) |
| 15:51 | jayunit100 | its a JVM method, not a clojure one. |
| 15:51 | gfredericks | jayunit100: are you passing the wrong number of args? |
| 15:52 | jayunit100 | must be an extra / missing paren ! |
| 15:52 | jayunit100 | gfredericks: good catch :) |
| 16:36 | ohpauleez | lynaghk: chopped it like a surgeon: https://github.com/shoreleave |
| 16:39 | pipeline | i have a fencepost error that is just killing me |
| 16:39 | pipeline | and i can't seem to see what i'm doing wrong |
| 16:39 | pipeline | http://cljbin.com/paste/4fde404be4b0815a95f5a8fb |
| 16:39 | pipeline | confusingly if i drop the "if" and just use "take 4" i get my desired result so i'm really puzzled about my bad recursion here |
| 16:41 | brehaut | pipeline: random probably unrelated comment, i its more idiomatic to test (seq collection) rather than (empty? collection) |
| 16:41 | brehaut | pipeline: and it will let you ditch the 'nil' clause by switching to a when too |
| 16:42 | pipeline | yep that is how the original function in clojure.core works |
| 16:42 | pipeline | but i don't understand why my independently mangled version is fencepostin' |
| 16:45 | brehaut | pipeline: why are you def'ing a fn ? |
| 16:46 | pipeline | brehaut: so i can copy and paste out of emacs and into 4clojure |
| 16:46 | brehaut | ah right |
| 16:46 | pipeline | in my interactive repl i like to have names for things |
| 16:49 | pipeline | brehaut: now that i have solved it with when-let, as in the source, i see how my solution SHOULD have worked |
| 16:49 | pipeline | brehaut: "(if (not-empty c)" with no false return value |
| 16:49 | brehaut | pipeline: you are fence posting because if you take the rest of [1] you get nil, and a head of 1 |
| 16:49 | lynaghk | ohpauleez: damns. |
| 16:50 | ohpauleez | I need to merge in the local storage stuff, but it'll all be up on clojars soon. Plus the super project: shoreleave |
| 16:50 | brehaut | pipeline: i you are cheating by looking at the source, i guess you can see that in the real version, the cons is outside the when |
| 16:50 | lynaghk | ohpauleez: one suggestion; if you're going to maintain remotes, you should decouple them from noir. At the very least, make sure you talk with Chris about the shared namespace "noir". |
| 16:50 | pipeline | brehaut: yeah i discovered that problem also |
| 16:50 | ohpauleez | Already decoupled |
| 16:50 | ohpauleez | and already talked to chris |
| 16:51 | lynaghk | ohpauleez: but it isn't hard at all to make it accessible from just ring or compojure, and that would make it much more general and useful to a lot of people (myself included) |
| 16:51 | ohpauleez | I'll define a shoreleave-remote-compojure |
| 16:51 | ohpauleez | just for you :) |
| 16:52 | brehaut | pipeline: in future, it can help to remember that fn bodies have implicit do's |
| 16:52 | brehaut | pipeline: so you can jam a (prn …) in before your actual behavior |
| 16:53 | pipeline | yeah a common-lisp-ism i appreciate |
| 16:55 | lynaghk | ohpauleez: Don't go copy/pasting into a whole new repo just for me; my suggestion would be to sit down and think about how you could make the same codebase work with both. Also in the docs mention why this should be used over fetch (you patched some XSS stuff, yeah?) |
| 16:56 | ohpauleez | I mention CSRF and remote-ns |
| 16:56 | ohpauleez | I'll make it more explicit, thanks |
| 17:02 | bbloom | ohpauleez: looks like a nice collection of libraries you got there |
| 17:02 | ohpauleez | Thanks man. Docs and demo projects are just around the corner |
| 17:02 | ohpauleez | bbloom: ^ |
| 17:02 | bbloom | ohpauleez: you using this stuff in prod? |
| 17:03 | ohpauleez | yeah, it was built in parallel as we were building apps |
| 17:03 | ohpauleez | so, in C/Unix fashion … but because of protocols, it's all bottom-up in true Lisp fashion |
| 17:04 | bbloom | ohpauleez: cool. https://github.com/shoreleave/shoreleave-core/blob/master/src/shoreleave/common.cljs#L13 does that work with maps of more than 32 keys? |
| 17:04 | ohpauleez | it needs a lot of scrubbing up though |
| 17:05 | ohpauleez | clj->js is crutch - so I would only use it if you really have to |
| 17:05 | bbloom | ohpauleez: was just skimming the code. looks bugged to me, it relies on the internal implementation of ObjMap, which gets promoted to a PersistentHashMap after some number of updates or size |
| 17:06 | ohpauleez | Where at? |
| 17:06 | ohpauleez | You mean -strobj? |
| 17:06 | bbloom | yeah |
| 17:07 | ohpauleez | That doesn't work on PersistentHashMap? |
| 17:07 | ohpauleez | (I've never encountered a moment where that failed) |
| 17:08 | ohpauleez | but I also don't use it very much |
| 17:08 | ohpauleez | What would be the generic protocol call replacement? |
| 17:08 | ohpauleez | just str? |
| 17:09 | bbloom | try this: |
| 17:09 | bbloom | (.-strobj (into {} [])) |
| 17:09 | bbloom | vs (.-strobj {}) |
| 17:09 | bbloom | you'll notice the former is nil |
| 17:09 | bbloom | you can check for strobj as an optimization, if you want |
| 17:10 | bbloom | but really you should (doseq [[k v] map] ...) |
| 17:11 | bbloom | ClojureScript:cljs.user> (type (loop [m {} i 0] (if (< i 10) (recur (assoc m (str i) i) (inc i)) m))) |
| 17:11 | bbloom | cljs.core.ObjMap |
| 17:11 | bbloom | ClojureScript:cljs.user> (type (loop [m {} i 0] (if (< i 100) (recur (assoc m (str i) i) (inc i)) m))) |
| 17:11 | bbloom | cljs.core.PersistentHashMap |
| 17:12 | ohpauleez | Ahh there you have it |
| 17:12 | ohpauleez | Ok, I'll make a ticket, thanks man |
| 17:13 | bbloom | np |
| 17:18 | ohpauleez | bbloom: https://github.com/shoreleave/shoreleave-core/compare/master...cljsjs |
| 17:19 | ohpauleez | uh, variable names, hang on |
| 17:19 | bordatoue | which one is good for emacs inferior lisp or swank clojure |
| 17:20 | ohpauleez | bbloom: ok, fixed. Look good to you? |
| 17:20 | bbloom | ohpauleez: lgtm |
| 17:21 | bordatoue | can anyone advise on the pros and cons for inferior lisp and swank clojure mode |
| 17:24 | antares_ | bordatoue: compared to what? |
| 17:24 | antares_ | swank kinda uses inferior lisp approach, no? |
| 17:25 | antares_ | and at least for clojure, swank is more widely used than bare inferior lisp |
| 17:31 | bordatoue | antares_: thanks, I just wanted to know which one was widely supported for clojure emacs |
| 17:31 | mattmoss | ,postwalk |
| 17:31 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: postwalk in this context, compiling:(NO_SOURCE_PATH:0)> |
| 17:32 | antares_ | bordatoue: clojure-mode's clojure-jack-in uses swank-clojure under the hood |
| 17:32 | mattmoss | ,clojure.walk/postwalk |
| 17:32 | clojurebot | #<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk, compiling:(NO_SOURCE_PATH:0)> |
| 17:32 | bbloom | ,(ns-aliases *ns*) |
| 17:32 | clojurebot | {} |
| 17:33 | antares_ | mattmoss: http://clojuredocs.org/clojure_core/clojure.walk/walk |
| 17:33 | mattmoss | antares_: I'm looking at postwalk there now, trying to understand the example. |
| 17:33 | mattmoss | On http://clojuredocs.org/clojure_core/clojure.walk/postwalk |
| 17:34 | mattmoss | If I use their example on [:a :b], I get [2 [[0 :a] [1 :b]]] |
| 17:34 | antares_ | yeah, the example there is confusing |
| 17:34 | mattmoss | But the same example on {:a :b}, I get [3 {2 [[0 :a] [1 :b]]}] |
| 17:34 | mattmoss | Trying to understand the reason for the difference. |
| 17:34 | bbloom | ,(filter #(.contains (str %) "walk") (ns-refers *ns*)) |
| 17:34 | clojurebot | () |
| 17:35 | bbloom | mattmoss: apparently not available in clojurebot :-) |
| 17:35 | antares_ | mattmoss: because iteration over maps vs vectors is slightly different, perhaps? |
| 17:35 | mattmoss | antares_: I guess... I suppose I need to dig into the source for walk/postwalk and see where the difference occurs. |
| 17:36 | mattmoss | It just seems like it's doing an extra evaluation for the map compared to the vector. |
| 17:36 | mattmoss | Or, perhaps, one less for the vector compared to the map. |
| 17:37 | Bronsa` | ,(do (in-ns 'clojure.walk) postwalk) |
| 17:37 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: postwalk in this context, compiling:(NO_SOURCE_PATH:0)> |
| 17:37 | antares_ | mattmoss: that's because iterating (e.g. doseq) over a map yields pairs and for vectors, only values |
| 17:37 | Bronsa` | &(do (in-ns 'clojure.walk) postwalk) |
| 17:37 | lazybot | java.lang.ClassNotFoundException: clojure.walk |
| 17:37 | Bronsa` | derp |
| 17:37 | mattmoss | lol |
| 17:37 | Bronsa` | i was pretty sure it was going to work |
| 17:38 | mattmoss | antares_: I guess that makes sense... iteration over a map "adds" an extra form, in a sense... the pairing |
| 17:40 | mattmoss | Not that any form is truly being added, but it just seems like that because [:a :b] looks so much like {:a :b} in the editor. |
| 17:41 | replcated | Let me start by saying I'm not flamebaiting. Did anyone here that really loves and makes regular use of clojure start out hating it? I'm struggling to get beyond what-the-hell-was-he-thinking and actually start on the project I had in mind. |
| 17:43 | Raynes | I might have, but Rich Hickey has been very clear in numerous presentations and talks what the hell he was thinking. :> |
| 17:43 | zomg | replcated: I didn't like the syntax |
| 17:43 | zomg | I always found lisp syntax stupid |
| 17:43 | zomg | Still do kind of, but I can live with it :P |
| 17:46 | Raynes | It still surprises me that people concern themselves with parentheses. |
| 17:46 | brehaut | ive never loved a new syntax for a programming language i dont understand |
| 17:46 | replcated | Raynes, I understand. I've actually watched a number of his talks. |
| 17:47 | replcated | I'm actually coming from a CL background, so the parens don't bother me. |
| 17:47 | zomg | Raynes: it's just that every time I move some lines of code or such I always need to check them when in most other languages you don't need to bother with such things |
| 17:47 | zomg | Of course paren matching in the editor helps with that but it's still something you need to do |
| 17:47 | brehaut | zomg: no its not |
| 17:47 | Raynes | I don't have to do it. |
| 17:47 | replcated | zomg: A "real" editor helps a lot. |
| 17:47 | Raynes | paredit does it for me. |
| 17:48 | zomg | I guess you're using emacs or something then |
| 17:48 | brehaut | zomg: structural editing removes the need completely |
| 17:48 | Raynes | Even counterclockwise has some paredit support these days. |
| 17:48 | brehaut | CCW has had paredit support for at least 2 yeard |
| 17:48 | Raynes | And besides, with paren matching, I don't understand how you have to pay any more attention than you would with another language. |
| 17:48 | zomg | Using vim myself, and tbh it's mostly an issue when I'm being lazy and using dd and not d% or such :P |
| 17:49 | Raynes | When I used Vim, I used paredit.vim and lots of da( |
| 17:49 | Raynes | I actually do the same thing in Emacs because I use evil-mode |
| 17:51 | antares_ | hey Raynes |
| 17:51 | Raynes | antares_: Hey thar |
| 17:52 | antares_ | Raynes: pretested pull requests on travis-ci.org are on for your projects (fs, bultitude, conch — everywhere we could find a travis file) |
| 17:52 | Raynes | antares_: clojail is a flatland project |
| 17:53 | Raynes | That's probably why you didn't see it. |
| 17:53 | Raynes | Anyways, awesome! |
| 17:53 | Raynes | Now I just need people to send me pull requests. |
| 17:53 | antares_ | Raynes: turning it on for clojail, too |
| 17:54 | antares_ | I have forgotten about it |
| 17:56 | antares_ | Raynes: can you please log in on travis-ci.org so we can sync your repos? |
| 17:56 | antares_ | flatland/clojail is not in our database |
| 17:57 | Raynes | antares_: Logged in. |
| 17:58 | antares_ | Raynes: do you see flatland/clojail on your profile page? |
| 17:58 | antares_ | if you do, that's all we need |
| 17:58 | Raynes | Yes. |
| 17:58 | Raynes | None of these are 'on' though, because I added all the hooks manually (because this page was broken before). |
| 17:59 | antares_ | Raynes: that's fine |
| 17:59 | antares_ | as long as our database has the repo |
| 19:19 | brooksbp | hello |
| 19:19 | brooksbp | newbie question |
| 19:19 | brooksbp | is there a way to conj to the end of a map? |
| 19:20 | brooksbp | I want to do this: (conj {:a 1} [:b 2]) => {:a 1 :b 2} |
| 19:21 | Raynes | You can't rely on the ordering of maps. |
| 19:27 | brooksbp | Raynes: I see.. I guess it doesn't matter in my case. It's just easier to read when I evaluate the map in repl to view contents.. would like it to be ordered |
| 19:27 | gfredericks | brooksbp: clojure maps don't really have an 'end'; semantically they're unordered |
| 19:28 | brooksbp | I'm guessing it's for implementation efficiency? |
| 19:29 | bbloom | brooksbp: and because, semantically, what order do you want? |
| 19:29 | bbloom | ,(doc sorted-map-by) |
| 19:29 | clojurebot | "([comparator & keyvals]); keyval => key val Returns a new sorted map with supplied mappings, using the supplied comparator." |
| 19:29 | bbloom | brooksbp: if you just want orderd keys for debugging sake, you can use something like: |
| 19:29 | brooksbp | semantically I don't care |
| 19:30 | bbloom | ,(into (sorted-map) (conj {:a 1} [:b 2])) |
| 19:30 | clojurebot | {:a 1, :b 2} |
| 19:34 | brooksbp | I am coming from an imperative language background. Does clojure have some way to use debug flags in expressions? Something to the effect of #ifdef DEBUG ... #endif |
| 19:35 | brooksbp | Like... if I wanted to write that function, but have two cases where debug would use (sorted-map) version and non-debug wouldn't |
| 19:35 | brooksbp | Would that require passing around a debug var to every stinkin function? |
| 19:40 | Hodapp | somehow I'd think you could make use of a global. |
| 19:50 | miclorb | I am trying to look up what "->" really does - not the easiest thing to search for - anyone got a link to the doc? |
| 19:50 | bhenry | ,(doc ->) |
| 19:50 | amalloy | &(doc ->) |
| 19:50 | lazybot | ⇒ "Macro ([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc." |
| 19:51 | clojurebot | "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc." |
| 19:53 | amalloy | see also http://clojuredocs.org/clojure_core/clojure.core/-%3E |
| 19:53 | arohner | miclorb: (-> a (foo 1) (bar 2) (baz 3)) = (baz (bar (foo a 1) 2) 3) |
| 19:55 | miclorb | amalloy: arohner: thanks ! |
| 19:55 | miclorb | I can see will see will take some practice to internalise, but looks really handy |
| 19:55 | amalloy | though tbh lines 15-38 of the first example on that page should be thrown in the trash |
| 19:57 | arohner | amalloy: what's wrong with that example? |
| 19:57 | amalloy | (-> foo :x :y :z) is *not* the same as (((foo :x) :y) :z) |
| 19:57 | amalloy | it is the same as (:z (:y (:x foo))), which just happens to usually evaluate to the same result in most clojure programs |
| 19:58 | arohner | right. though that seems to be a bug w/ line 34 then, not a problem with having the example |
| 19:58 | amalloy | further, -> is only known as the "thrush operator" by people who read about thrushing and think it's cool. thrush is a function, which does something sorta similar to what -> does as a macro, in most cases |
| 19:58 | arohner | and IMO, if (foo :x) is not the same as (:x foo) in your program, you have other bugs |
| 19:59 | amalloy | i also |
| 19:59 | amalloy | er |
| 19:59 | amalloy | arohner: (= x nil) |
| 19:59 | gfredericks | arohner: or you are using records |
| 19:59 | amalloy | or foo is nil |
| 19:59 | amalloy | or a record |
| 19:59 | gfredericks | can you use (:x foo) for a j.u.Map? |
| 20:00 | gfredericks | ,(let [m (java.util.Map.)] (.put m :foo 7) (:foo 7)) |
| 20:00 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: No matching ctor found for interface java.util.Map, compiling:(NO_SOURCE_PATH:0)> |
| 20:00 | gfredericks | ,(let [m (java.util.HashMap.)] (.put m :foo 7) (:foo 7)) |
| 20:00 | clojurebot | nil |
| 20:00 | gfredericks | ,(let [m (java.util.HashMap.)] (.put m :foo 7) (:foo m)) |
| 20:00 | clojurebot | 7 |
| 20:00 | amalloy | as a matter of taste, i also don't want anyone to be told that you should use -> to get values from a nested data structure - that's exactly what get-in is for, and -> doesn't make it readable |
| 20:00 | amalloy | but i realize that's not a universally-shared opinion |
| 20:01 | arohner | amalloy: yes. :-) |
| 20:01 | arohner | I think -> is more readable once you're used to it, and I like the flexibility of being able to use things like first & last in the -> expr |
| 20:02 | amalloy | arohner: i love ->. but not for mundane data-structure drilling |
| 20:02 | brehaut | i like -> for unpacking stuff like that only if im chucking an (or …) as the last term |
| 20:02 | amalloy | brehaut: (get-in m [a b c] default) |
| 20:02 | amalloy | i think |
| 20:02 | brehaut | oh true |
| 20:02 | amalloy | &(doc get-in) |
| 20:02 | lazybot | ⇒ "([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied." |
| 20:03 | gfredericks | but there's no substitute for (-> m :foo :bar fn1 fn2 (try (catch Exception e e))) |
| 20:03 | arohner | I still prefer (-> m a b c (or default)) |
| 20:03 | amalloy | doesn't work if your value is nil or false |
| 20:03 | arohner | shrug. doesn't happen often enough for me to say "never use ->" for nested structures |
| 20:04 | brehaut | amalloy: who are you replying to there? |
| 20:04 | amalloy | to arohner |
| 20:04 | amalloy | i didn't say never use it. i use it when it's appropriate. but i don't want it held up as a primary example usage of -> |
| 20:05 | amalloy | but i doubt if i'll ever make any changes to clojuredocs, so my opinion doesn't matter much |
| 20:05 | brehaut | oh phew. my use of (-> … (or …)) has fns as well as keywords |
| 20:06 | bbloom | brooksbp: regarding your question about a debug flag. you can just use any old var: (def foo 123) |
| 20:14 | gfredericks | you could use a macro to do the debug testing at compile time |
| 20:15 | akhudek | interesting, it seems that sqlkorma insert statements need select permissions in the database |
| 20:24 | akhudek | has anyone encountered this? Do I really need to drop down to raw jdbc just to do a pure Insert? |
| 20:26 | bbloom | akhudek: what query gets generated? |
| 20:26 | akhudek | bbloom: using sql-only prints out a query that is just a normal looking insert. |
| 20:26 | akhudek | it works direclty in psql |
| 20:27 | akhudek | but not via korma |
| 20:27 | akhudek | if I add select permission to the user, then the korma version starts working |
| 20:27 | bbloom | akhudek: have you tried logging all queries on your server to see if any ADDITIONAL queries get run? i know that rails's active record often queries extra stuff, like table shapes |
| 20:28 | akhudek | I'll try that |
| 20:28 | bbloom | akhudek: can also look at the norma source more carefully for calls to whatever it is that does the query execution |
| 20:28 | bbloom | korma* dopey osx autocorrect |
| 20:29 | akhudek | ah, in the logs it has a "RETURNING *" at the end |
| 20:29 | akhudek | I'm assuming that's the problem |
| 20:30 | bbloom | akhudek: probably :-) |
| 20:30 | akhudek | now to figure out how to get korma not to do add that! |
| 20:30 | bbloom | akhudek: curious: why don't you allow select permissions? are you exposing the sql db directly without any sort of API or anything in between? |
| 20:31 | akhudek | it's a table that logs transactions in a write only fasion |
| 20:31 | gfredericks | https://www.refheap.com/paste/3202 |
| 20:31 | bbloom | akhudek: that i assumed |
| 20:31 | gfredericks | ^ a with-foo macro-writing macro |
| 20:32 | akhudek | it aggregates data from separate databases; the databases are separate for security concerns |
| 20:32 | bbloom | akhudek: ok gotcha |
| 20:32 | bbloom | gfredericks: heh. nice. |
| 20:33 | gfredericks | bbloom: dangit I don't think it works |
| 20:33 | bbloom | gfredericks: now make it support multiple different arities ;-) you'll need a multi-arity macro-defining-macro |
| 20:33 | gfredericks | bbloom: it's supposed to |
| 20:33 | gfredericks | you should be able to (def-wrapper-macro [x y z func] (prn x y z) (func)) |
| 20:33 | gfredericks | but I think that fails |
| 20:34 | bbloom | gfredericks: i mean (def-wrapp-macro ([x] (prn x)) ([x y] (.... |
| 20:34 | gfredericks | bbloom: I can't even get my head around what that means |
| 20:35 | bbloom | gfredericks: heh nevermind then |
| 20:35 | gfredericks | bbloom: also it might not make sense here |
| 20:35 | gfredericks | certainly the resulting macro is already vararged |
| 20:35 | gfredericks | since it wraps them up in the body func |
| 20:36 | gfredericks | yeah I'm going with that doesn't make sense here |
| 20:36 | bbloom | gfredericks: *looks again* oh yeah you're right :-P |
| 20:38 | akhudek | if anyone ever needs this, you can disable returning of results by simply removing the :results key from the query record |
| 20:39 | kmicu | gfredericks: what are these 3 asterisks? |
| 20:39 | gfredericks | kmicu: ...three asterisks? |
| 20:40 | kmicu | gredericks: ***gfredericks debugs |
| 20:40 | gfredericks | oh; that must be your IRC client |
| 20:40 | gfredericks | kmicu: try typing "/me tries this out" |
| 20:41 | akhudek | https://gist.github.com/2946182 |
| 20:42 | bbloom | akhudek: does that work? |
| 20:42 | akhudek | yep |
| 20:42 | bbloom | cool! glad you got it :-) |
| 20:42 | bordatoue | when i load clojure-jack-in it never load clojure.core or clojure.repl , is there any reason for it |
| 20:45 | bordatoue | hello |
| 20:45 | tmciver | bordatoue: it *should* load clojure.core, but not clojure.repl. |
| 20:46 | bordatoue | tmciver: you are right it loaded clojure.core but not clojure.repl |
| 20:47 | bordatoue | tmciver: as a result i don't have doc fn working |
| 20:47 | tmciver | bordatoue: yeah, it's a pain but you always have to 'use' clojure.repl manually. |
| 20:47 | bordatoue | tmciver: then wat is the point of this clojure-jack-in |
| 20:47 | tmciver | bordatoue: I think there might be a way to get it to 'use' it automatically but I haven't spent the time to figure out how. |
| 20:49 | bordatoue | tmciver: thanks, i will investigate this |
| 20:49 | tmciver | bordatoue: there's a lot of benefit. Check out https://github.com/technomancy/swank-clojure if you haven't already. |
| 20:50 | bordatoue | tmciver: any idea how you test your private method |
| 20:50 | tmciver | bordatoue: for example, I often C-c C-l a file to load the current buffer into the repl and then C-c M-p to change the repl's ns to that file's ns. |
| 20:50 | bordatoue | tmciver: private fns from repl |
| 20:51 | bordatoue | tmciver: thats handy |
| 20:51 | tmciver | bordatoue: Yep. And M-. is another good one. |
| 20:51 | bbloom | bordatoue: you can also use the var object, which is invokable |
| 20:51 | bbloom | (#'somens/somefn arg1 arg2) |
| 20:51 | bordatoue | tmciver: when i am creating a executable jar, should i explicity mention gen-class in all clj file or just the project.clj file |
| 20:54 | tmciver | bordatoue: I don't know much about it but I think you can get away without AOT but using TimMc's lein-otf: https://github.com/timmc/lein-otf |
| 20:55 | bordatoue | tmciver: what does M- do, i am using aquamacs and can't see any binding to it |
| 20:55 | tmciver | bordatoue: mind the period: M-. |
| 20:55 | bordatoue | tmciver: oh.. |
| 20:56 | tmciver | bordatoue: Jumps to a definition of the var under point. |
| 21:26 | calvados | is there a way to get request headers in ring without using middleware ? |
| 21:26 | weavejester | calvados: In Ring? They're in the request map |
| 21:27 | weavejester | calvados: (fn [req] (do-something-to (:headers req))) |
| 21:27 | calvados | yes but how to get req without middleware |
| 21:27 | weavejester | calvados: It's the argument passed to the handler |
| 21:27 | brehaut | calvados: in _ring_ or some other lib on top like compojure? |
| 21:28 | calvados | actually what i want to do is |
| 21:28 | weavejester | That was going to be my next question :) |
| 21:28 | calvados | i want to change the content-type dynamicly i will check Request:headers:accept part and will change content-type |
| 21:29 | weavejester | calvados: What library or framework are you using? Are you just using Ring straight off? |
| 21:30 | calvados | so lets say a got (defn - response [resposne] {:status 200 :body "something" headers: *i-need-to-get-request-headers-here* }) |
| 21:30 | calvados | yes ring stuff |
| 21:31 | calvados | i just need to get request in (response [response]) |
| 21:31 | weavejester | calvados: The request is passed as the argument to the handler function |
| 21:31 | weavejester | calvados: So your handler looks like (defn handler [request] …) right? |
| 21:31 | weavejester | calvados: The headers are in the request map passed to the handler function. |
| 21:31 | calvados | hm |
| 21:31 | brehaut | calvados: you might be overthinking this |
| 21:32 | calvados | well i am quite new |
| 21:32 | brehaut | calvados: look down at "Request Map" https://github.com/mmcgrana/ring/blob/master/SPEC |
| 21:32 | calvados | my brain still refuses to get it :) |
| 21:32 | weavejester | calvados: In ring you have a request, pass it to a function called a handler, which returns a response. |
| 21:33 | calvados | yes |
| 21:33 | calvados | i mean i got more than one handler because of routes thought |
| 21:33 | calvados | each route goes different handler i beleive |
| 21:33 | brehaut | what library are you using for your routes? |
| 21:34 | brehaut | ring doesnt do routes itself |
| 21:34 | calvados | :ring {:handler project./map-routes} |
| 21:34 | calvados | it should be ring |
| 21:35 | brehaut | calvados: ring is the lowest level api in the clojure web stack. lots of things are part of the ring ecosystem, but are not ring itself |
| 21:36 | weavejester | calvados: Routes might indicate you're using Compojure |
| 21:36 | calvados | (defroutes map-routes) |
| 21:36 | weavejester | calvados: That's Compojure |
| 21:36 | calvados | ok |
| 21:36 | calvados | yes it is sorry |
| 21:36 | weavejester | calvados: You can use destructuring to access the request |
| 21:36 | brehaut | calvados: you might find http://brehaut.net/blog/2011/ring_introduction helpful |
| 21:37 | weavejester | calvados: Like (GET "/" request …) or (GET "/" {:as request} …) or (GET "/" [:as request] ...) |
| 21:39 | calvados | weavejester: than i need to write it to every route thought |
| 21:39 | weavejester | calvados: That's usually an indication you want middleware |
| 21:39 | calvados | weavejester: i used middleware but the problem |
| 21:39 | weavejester | calvados: Doing some operation to multiple routes = middleware |
| 21:40 | cshell | isn't middleware analogous to a filter? |
| 21:41 | calvados | yes i used middle ware lets says client a visited page content-type changed to a but he got nil , client b visited and he got content-type a and it content-type set to b , when client a revisits he gets content-type response as b |
| 21:41 | weavejester | cshell: It's more like something that modifies the behaviour of a function in a general way. |
| 21:41 | calvados | i thought it is not the correct place to modify it, because i am modifying and next request its getting active |
| 21:41 | calvados | let me paste bin |
| 21:42 | mmarczyk | dnolen: ping |
| 21:44 | weavejester | calvados: The request is immutable. If you alter it for one handler, it's not going to be altered for another. |
| 21:44 | weavejester | All data structures in Clojure are immutable. |
| 21:46 | cshell | after middleware returns, is there any code that runs after middleware that could alter the result? |
| 21:46 | brehaut | cshell: any other middleware that wraps that middleware |
| 21:46 | cshell | or does middleware wrap handlers on both entry and exit |
| 21:47 | calvados | http://pastebin.com/1thhJE9a |
| 21:47 | cshell | brehaut: ah okay, thanks! |
| 21:47 | brehaut | cshell: it pays not to draw to stark a line between middleware and handlers |
| 21:47 | cshell | ah |
| 21:47 | calvados | weavejester: i guess its not the best way i am using but i got it so far |
| 21:47 | cshell | calvados: you shouldn't def inside a function |
| 21:47 | cshell | use let |
| 21:47 | cshell | that will slow you down a lot |
| 21:47 | brehaut | cshell: with something like compojure its possible that your handlers are middelware themselves |
| 21:48 | weavejester | calvados: Yes, don't def inside functions - you're using Clojure like an imperative language. |
| 21:48 | cshell | brehaut: I'm using noir - have been injecting the friend middleware in |
| 21:48 | calvados | weavejester: i told i am newbie |
| 21:48 | brehaut | cshell: my noir knowledge is extremely limited |
| 21:49 | cshell | brehaut: I considered moving back to plain ring, but it seems like noir is just a bunch of helper functions that help to use ring |
| 21:50 | weavejester | calvados: I'd like to help, and usually I would, but I'm almost out of time. I need to get to bed! |
| 21:50 | weavejester | calvados: But in a nutshell... |
| 21:50 | brehaut | cshell: theres a big drop off to go back to 'plain ring' but stepping back to plain compojure isnt a huge change. i suspect you could still use a bunch of noir's helpers from compijure anyway |
| 21:50 | calvados | weavejester: ok thanks anyway, i need to search abit more. |
| 21:51 | brehaut | cshell: however, i would recommend learning about how ring and compojure work as they are the underpinnings anyway, and they arent hard to grasp |
| 21:51 | weavejester | calvados: If you get rid of the defs and use lets instead, that should be your starting point... |
| 21:51 | cshell | brehaut: yeah, that's a good idea - i've been going through their apis in the last couple of days |
| 21:51 | cshell | i'm so close to getting friend to work |
| 21:52 | brehaut | cshell: good plan. i think looking at how routes and GET etc interact is a great place to start. it embodies the spirit of compojure without having to grok a huge amount of code |
| 21:52 | calvados | weavejester: yes but test is out of it so i cant use let, as i read let is local |
| 21:52 | cshell | calvados: oh no |
| 21:53 | weavejester | calvados: Yes, but there's nothing you're doing that isn't local |
| 21:53 | cshell | brehaut: thanks! |
| 21:54 | gfredericks | ,'<o>.<o> |
| 21:54 | clojurebot | <o>.<o> |
| 21:54 | brehaut | cshell: weavejester might disagree ;) |
| 21:55 | cshell | brehaut: he doesn't ahve time to, tonight :) |
| 21:56 | ibdknox | some enterprising individual could fairly easily create the wrap-noir-around-compojure middleware :) |
| 21:57 | cshell | what would the code for that look like? ;) |
| 21:57 | weavejester | Goodnight all |
| 21:57 | brehaut | night weavejester |
| 21:57 | cshell | night, wj |
| 21:59 | brehaut | ibdknox: i cant imagine that would be very much code? |
| 21:59 | ibdknox | yeah, not much at all |
| 21:59 | brehaut | ibdknox: is there an noir equivalent to the context macro in compojure? |
| 21:59 | ibdknox | no |
| 22:00 | ibdknox | though that's another thing that could be added fairly easily |
| 22:00 | ibdknox | not as easily as wrapping compojure though |
| 22:00 | brehaut | heh, added that would effectively make it trivial to drop compojure in |
| 22:01 | ibdknox | yeah |
| 22:10 | akhudek | ibdknox: is noir-cljs not intended to be used with uberjar or war files for production use? |
| 22:10 | ibdknox | I guess it could be |
| 22:11 | xeqi | is that just (fn [h1 h2] (fn [r] (if-let [res (h1 r)] res (h2 r)))) ? |
| 22:12 | ibdknox | akhudek: you'd have to do some trickery to make it work |
| 22:12 | Raynes | ibdknox: What is context vs :base-url? |
| 22:12 | ibdknox | Raynes: potentially nothing, I didn't know about context |
| 22:13 | ibdknox | Raynes: until much later |
| 22:13 | Raynes | ibdknox: BTW, did you see https://github.com/Raynes/refheap/issues/87 |
| 22:14 | brehaut | ibdknox: i think context was new around the time you released noir |
| 22:14 | ibdknox | Raynes: what's the canonical host thing for? |
| 22:14 | ibdknox | brehaut: I think it came a bit after |
| 22:14 | brehaut | in that sort of ballpark anway |
| 22:14 | ibdknox | yeah |
| 22:14 | ibdknox | if it serves the same purpose, I'm all for consolidation |
| 22:14 | brehaut | it wasnt particurly well known about when it was out too |
| 22:15 | Raynes | ibdknox: For web apps that have numerous hosts. For example, refheap is refheap.com, www.refheap.com, and refheap.herokuapp.com. It's a way to redirect to whatever the canonical host is (in refheap's case, www.refheap.com) at an application level, since you can't do it at a server level in Heroku (and I imagine other scenarios). |
| 22:15 | xeqi | Raynes: friend also has a similar force-ssl fn https://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L46 |
| 22:16 | ibdknox | Raynes: I see |
| 22:16 | Raynes | ibdknox: Note that I'm not claiming any of this to be useful in general, just some guy mentioned it. |
| 22:16 | Raynes | So I figured it worth asking what you thought. |
| 22:16 | ibdknox | Raynes: they all sound reasonable to include in noir. They could use comments though :) |
| 22:17 | Raynes | Of course. :P |
| 22:17 | Raynes | xeqi: His is bigger than mine. |
| 22:17 | ibdknox | that is an epic name |
| 22:18 | Raynes | Mine also handles the case where the scheme is there too. |
| 22:19 | xeqi | yah, thats his require-scheme |
| 22:20 | akhudek | ibdknox: I think I'll just switch over to cljsbuild for now since it supports pre-compilation. Noir-cljs is pretty nice during dev work though. |
| 22:20 | ibdknox | akhudek: hm? |
| 22:20 | xeqi | just mentioning since it looks like that concept is useful to move to a higher spot |
| 22:20 | ibdknox | if you run the server in prod mode |
| 22:20 | ibdknox | akhudek: and then uberjar it will be precompiled to advanced |
| 22:21 | akhudek | I had to disable aot compilation for it to work though |
| 22:21 | akhudek | also, it needs to compile before it packages the jar |
| 22:22 | akhudek | I suppose I could run it once in prod mode, re-enable aot, then run uberjar |
| 22:22 | ibdknox | yeah, admittedly not something I ever do |
| 22:22 | ibdknox | I just use lein to run my apps |
| 22:25 | brehaut | ibdknox: what a cowboy :P |
| 22:32 | akhudek | ls |
| 22:32 | akhudek | whoops |
| 22:36 | arohner | how do I write a literal plus in a regex? |
| 22:36 | brehaut | [+] ? |
| 22:36 | brehaut | \+ ? |
| 22:37 | arohner | those aren't working for me |
| 22:37 | arohner | neither is \\+ |
| 22:37 | arohner | I'd like something like #"^[a-zA-Z0-0/_-+]+$" |
| 22:37 | brehaut | , (re-find #"\+" "a+b") |
| 22:37 | clojurebot | "+" |
| 22:38 | arohner | java.util.regex.PatternSyntaxException: Illegal character range near index 14 ^[a-zA-Z0-0/_-+]\++$ |
| 22:38 | brehaut | ah |
| 22:38 | brehaut | its the hyphen |
| 22:38 | arohner | oh right |
| 22:38 | brehaut | it defines a range unless its the first character in the character class |
| 22:39 | arohner | right, forgot about that |
| 22:39 | arohner | thanks! |
| 22:40 | brehaut | no problem |
| 23:07 | ghadishayban | does anyone know how to force AOT to be 1.6 JDK compatible, when running 1.7? |
| 23:07 | ghadishayban | is there a lein flag? |
| 23:08 | antares_ | ghadishayban: yes |
| 23:08 | antares_ | ghadishayban: what version of lein? |
| 23:08 | ghadishayban | 2-preview |
| 23:08 | antares_ | :javac-options ["-target" "1.6" "-source" "1.6"] |
| 23:09 | ghadishayban | that affects clojure AOT as well? I thought it's just for .java |
| 23:09 | antares_ | it is only for Java sources |
| 23:09 | ghadishayban | oh |
| 23:10 | ghadishayban | I uberjarred a project using OpenJDK 1.7, ran it on a 1.6 hadoop cluster...had a bad time |
| 23:11 | ghadishayban | received checksum errors on map input files, all sorts of unknown badness. took a while to track down |
| 23:11 | gfredericks | does the clojure compiler actually vary its bytecode output? |
| 23:12 | ghadishayban | that's the thing. i doubt it, doesn't clojure use an old version of ASM? |
| 23:12 | antares_ | ghadishaybangh: from what I see, lein only sets up some system properties Clojure compiler uses |
| 23:13 | antares_ | so maybe there is a property for that |
| 23:13 | antares_ | ghadishayban: actually, I remember doing something similar and I think :javac-options helped me (but I also have java sources in that codebase) |
| 23:16 | ghadishayban | interesting (i am not using any java in this project) |
| 23:16 | ghadishayban | well it's running like a champ now that I figured it out |
| 23:16 | antares_ | ghadishayban: what did you do? did :javac-options help? |
| 23:17 | ghadishayban | i compiled on 1.6 and deployed *that* (update-java-alternatives in ubuntu) |
| 23:17 | antares_ | ghadishayban: yeah but that's a workaround, not a solution :) |
| 23:18 | ghadishayban | exactly |
| 23:18 | gfredericks | the difference between a workaround and a solution is how tired you are |
| 23:19 | ghadishayban | i was about to give up on hadoop forever =) |
| 23:19 | ghadishayban | the job was only calling (read-string) on about 150GB, feeding it into Cascalog and sorting/reducing... |
| 23:20 | ghadishayban | this was my baptism with hadoop, it seems to me to be help duct tape |
| 23:21 | ghadishayban | i'd much rather work using only the clojure reader for my purposes |
| 23:39 | antares_ | gfredericks: :) |