#clojure logs

2013-04-20

00:19gfrederickstieTYT: that also checks that it's not false
00:20tieTYTright
00:38Raynesibdknox: http://dl.dropbox.com/u/23745600/Screenshots/oNCd.png How did my vim end up with light table's icon?
01:57RaynesYou're all boring.
01:57azkane:(
02:32sztamas\quit
04:08Netfeedwhat's the best way to do "raw" sql in clojure? is there a library where i don't have to work with abstractions and can work directly with the sql?
04:10callen_Netfeed: jdbc or korma.
04:14nopromptoh m'god. media queries...
04:15Netfeediv'e looked into jdbc, but i've not really got how i should best do stuff like custom insert and such, best thing i've found is do-commands and i'm not really sure if i can use the parameterized things with it. (i'm not sure how to explain it, i more or less want to do something like (do-commands "insert into foo (bar) values (?)" "baz") but a bit more advanced
04:17ddellacostaNetfeed, check out the tests for some examples if you haven't already: https://github.com/clojure/java.jdbc/blob/master/src/test/clojure/clojure/java/test_sql.clj
04:18ddellacosta(for jdbc at least)
04:18ddellacostamaybe that'll give you what you need…maybe not.
04:20Netfeedmaybe, i'll take a look, jdbc seems to be nice until you need to do some custom things
04:20ddellacostaoh, sorry, I guess you saw that, you were talking about do-prepared
04:20ddellacostaI was just checking this out too
04:20ddellacostahttps://github.com/clojure/java.jdbc/blob/master/src/test/clojure/clojure/java/test_jdbc.clj
04:21ddellacostait looks like you can do parameterized stuff from the examples there, but not sure again if it's enough for what you want.
04:22Netfeedoh, yeah, do-prepared might be what i need
04:22Netfeedthank you
04:23ddellacostahope it helps.
04:30Netfeedyeah, that worked, only thing it doesn't seem to do is RETURNING
04:32Netfeedah, might be another function for that
04:33Netfeedyeah, there was, great
05:45noprompte
05:58clj_newbHi, to perform N function execution, which is better, dotimes?
05:59naegGuess that depends on what your functions are doing? e.g. do they have side effects, etc.
06:00clj_newbyeah, are sending signals to external systems
06:01naegsounds like dotimes to me
06:02clj_newbcool, I also think is the more appropriate but just wondering it there was a more suitable way
06:03clj_newbthansk naeg
06:09naegam I the only one who thinks a visualization of code debugged with tools.trace.deftrace would be great? here's what I mean: http://i.imgur.com/qOiiXdE.png
06:09naegit's very ugly right now, but wondering whether there is something to that others could need to
06:09naegtoo*
07:06iamdrw@noprompt what's wrong with media queries?
10:05kmicJak tasiemiec.
10:14clj_newbHi, anyone using langohr? By merely following their examples messages don't get publish in rabbitmq
10:15clj_newbno errors, and in logs (rabbitmq) I can see that the connection is performed
10:20gdev,(contains? :a [])
10:20clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.Keyword>
10:25gdev,(clojure-version)
10:25clojurebot"1.5.0-RC6"
10:25kmic, (contains? [1] 0)
10:25clojurebottrue
10:26ejackson (use 'tradedesk.bootstrap)
10:26ejacksonooops
10:31gdev,(contains? {:doo "doo"} :poo)
10:31clojurebotfalse
11:42Jambatohi, I wanted to know whether you can access some global variables in a function
11:42Jambatoif yes, does it involve some namespace tricks?
11:43naegJambato: just put a def on the top of the file and you can access it from within that file with no problem
11:43naegalso from outside with namespace/var
11:43Jambatovery well
11:44Jambatothank you naeg
11:44naegnp
11:45naegjust ask again if you can't get it to work
11:46ziltiI'm currently trying to use Friend with Compojure, but all I get is "Exception in thread "main" java.io.FileNotFoundException: Could not locate ring/util/request__init.class or ring/util/request.clj on classpath".
11:47naegthis basically means it can't find ring - did you add it to the dependencies of your project and :require it in the file you're accessing it?
11:49ziltinaeg: I've added compojure as a dependency which requires ring, and when removing the require-statement from my core.clj I can run the application using lein-ring
11:49ziltiSo, no, currently I haven't explicitly declared or required ring anywhere.
11:52naegnever used Friend or ring, so dunno
11:55cemerickThis is cute: https://gist.github.com/cemerick/5426430
11:55cemerick(Only the first type specified in extend-protocol can be specified by an expression...)
11:56ebaxtis there a way to "invert" a vector [:foo :bar :baz] => :foo :bar :baz?
11:57no7hing?(reverse [:foo :bar :baz])
11:57Bronsacemerick: I'm more surprised by the fact that it works even just for the first type than that it doesn't work for the others
11:57no7hing@ebaxt: ah sry, i understood reverse
11:58cemerickBronsa: a must for array types *shrug*
11:58tmciverebaxt: if you're trying to use the vector contents as args to a fn, use apply.
11:58ziltiHmm I now explicitly added ring-core to my dependencies and explicitly required ring.util.request, but even then it seems to be unable to find that one...
11:59cemerickoddly, the broken sample is in some code I wrote *years* ago that used Clojure 1.3, but I can't get it to work with 1.3 now.
11:59ebaxttmciver: Thanks, I know how to do it in a function, but I'm trying to share some parameters on the calling side (does that make sense?)
12:00weavejesterzilti: Have you included ring-core 1.2.0-beta2?
12:01Bronsacemerick: right, but I think it's more likely that it works by accident rather than it being a bug
12:01ziltiweavejester: I manually included ring-core 1.1.8, but I just deleted ~/.m2 and re-fetched the dependencies for that project, and something seems to fetch 1.2.0-beta1
12:01Bronsacemerick: it would be difficoult to distinguish between protocol function implementation and expressions to evaluate in order to get a class
12:01weavejesterzilti: It might be Friend doing that
12:02Bronsadifficult*
12:02weavejesterzilti: ring.util.request is only available in 1.2.0
12:02ziltiweavejester: Isn't that paradox? Since it's friend complaining that ring.util.request is missing
12:02cemerickBronsa: not it's not: they're pairs
12:02ebaxtI have an enlive template and I want to use the same selector/fn pair in a deftemplate and in a macro (deftemplate …. [:p] (h/content "foo")) and (some-macro (html/at nodes [:p] (h/content "foo")))
12:02cemerickoh, oh, nm
12:03weavejesterzilti: No. The latest Friend depends on Ring 1.2.0. The ring.util.request namespace is only in Ring 1.2.0. If you've forced the dependency to Ring 1.1.8, then when Friend tries to get ring.util.request, it won't find it.
12:03cemerickanyway; that code definitely worked at some point. Maybe in 1.2? I don't remember the timelines of Clojure releases back that far
12:04ziltiweavejester: Thanks, now I've placed friend as first dependency right after clojure itself, and now it works.
12:05Bronsacemerick: not necessarily, it could be done by partitioning each (inc (count (keys (:sigs the-protocol)))) but then you're forcing users of extend-protocol to implement every function of the protocol
12:09ebaxttmciver: Here is what I'm trying to do https://www.refheap.com/paste/13791
12:14Jambatowhen trying to apply nth on a vector of vectors I get the following error : UnsupportedOperationException nth not supported on this type: core$init_gamearea clojure.lang.RT.nthFrom (RT.java:798)
12:14Jambatosaid vector is bound to a global variable
12:14BronsaJambato: can you nopaste the code you're using?
12:14Jambatosure
12:15Jambatohttp://pastebin.com/c5stPg4U
12:16BronsaJambato: line 19
12:16Bronsayou probably want (def gamearea (init-gamearea))
12:17Jambatoduh of course it is a function -_-
12:17Jambatoso stupid
12:17Bronsaalso, assoc doesn't work the way you're using it in line 29 and 30
12:17Bronsait has no side effect
12:17Bronsaso you're not modifying list-of-players or gamearea
12:18Jambatoit isn't modifying any copys?
12:18Bronsayou probably want list-of-players and gamearea to be atoms
12:18Bronsaand then swap! gamearea assoc instead of assoc gamearea
12:19Bronsa,(let [x {}] (do (assoc x :a 1) x))
12:19clojurebot{}
12:19JambatoI'll try that, thanks bronsa
12:19Bronsa,(let [x (atom {})] (do (swap! x assoc :a 1) @x))
12:19clojurebot{:a 1}
12:25JambatoBronsa: so the maps I'm using and whta's inside must all be atoms?
12:25Bronsano
12:26Bronsaall clojure collections are immutable Jambato
12:26Bronsaassoc and friends returns copies of the collection, they don't modify it
12:26Bronsaif you want to modify something, you generally want to put it inside an atom
12:27Jambatoah so I swap the modified copy
12:27Bronsaswap! is a function that takes an atom, a function and optiona arguments
12:28Bronsaapplies the function to the current state of the atom and sets the atom's value to the return value of the function
12:30Jambatowhat if I have to swap several atoms? must I wrap them within a specific form?
12:31recursor94Does anybody know of any good opensource projects that are relatively easy for a beginner to understand and learn from?
12:32recursor94For clojure.
12:37joegalloJambato: no, atoms are independent. if the swapping that you want to do is intended to be synchronized, then you're looking for a different data type, refs.
12:38joegallorecursor94: is there any particular domain that would be especially interesting to you?
12:39Jambatojoegallo: there isn't any concurrency involved
12:39JambatoI just need to sequentially update 2 different atoms
12:40BronsaJambato: just using swap! on each atom will be sufficient
12:40Jambatook
12:40joegalloJambato: that's fine, of course. if you were worried about something else reading from a bad old value from atom b during the fraction of a second between the write to atom a and the write to atom b, then what you'd want is refs.
12:41joegallobut since there isn't any such reader that you're worried about, then atoms are just fine, i suppose.
12:42joegallo(like for instance if atom a represented a debit into an account, and atom b represented the credit to another account -- that'd probably be refs then)
12:46recursor94joegallo: Hard to say, I suppose the most interesting thing I can think of is artificial intelligence. Second would probably be databases, and third games. Most of the open source projects I have seen on github are web frameworks.
12:46joegalloyou need a database-driven game with an AI component! :D
12:47recursor94Do such things exist XD?
12:48joegalloi doubt it, but it's a big world out there
12:51joegalloi can't speak for the quality of this (it may very well be excellent, but who knows) http://stevelosh.com/blog/2012/07/caves-of-clojure-01/
12:52recursor94Cool, thanks!
12:53joegallothe code for that lives in a series of tags, here: https://github.com/sjl/caves/
12:53joegallomight be a neat place to start with something
13:04Jambatohttp://pastebin.com/zieSRwp9 > now I got a IllegalArgumentException Key must be integer clojure.lang.APersistentVector.invoke (APersistentVector.java:265)
13:05Jambatoprobably wasn't a good idea to use numbers as keywords
13:07jjidoare you using assoc correctly
13:07Jambatooh litteral keywords don't change anything
13:07Jambatojjido: I have no idea I'm a beginner
13:08jjidowhat is the third argument? the key?
13:08Jambatothere is no third argument
13:09Jambatoonly two
13:09jjidoyou used [np]
13:09jjidoyes I can't count
13:10jjidoanyway is [np] the key? try without brackets.
13:10Jambatonp is the key yes
13:11Jambatonope no better
13:11Jambatowithout brackets
13:11IamDrowsyyou should look at your swap! calls... swap! takes an atom and a fn of min 1 args.. calls (f @atom-stat .. rest-args) ... and swaps the result "into the atom"
13:11jjidowhat's the error?
13:11JambatoIllegalArgumentException Key must be integer clojure.lang.APersistentVector.invoke (APersistentVector.java:265)
13:12IamDrowsyso last line should be (swap! gamearea #(assoc % nga newstack)
13:12IamDrowsy)
13:12jjidoyes IamDrowsy knows his/her stuff
13:13Jambatook I see
13:13Jambatofuncitons not values
13:13Jambato*functions
13:14edlothiolor even (swap! gamearea assoc nga newstack), since you can pass additional parameters to swap!
13:15Jambatoholy mackerel it works
13:16JambatoI'm so happy
13:16JambatoI had so many troubles with the haskell version
13:16Jambatothanks IamDrowsy and edlothiol
13:21jjidoJambato: clojure has lower entry threshold than Haskell
13:22ziltiIMO Haskell-syntax is totally unreadable
13:22Glenjamini'd say clojure is has a lower barrier to actually producing something real than haskell
13:22Glenjaminbasic haskell is pretty simple
13:24Jambatojjido: my haskell version involved the State monad
13:24Jambatobut stuf is quite unwieldy
13:25Jambatoto use that is
13:29konrIs there some meta-information I could add to a defn in cljs to compile it in whitespace mode, reglardless of what project.clj says?
13:31gfrederickskonr: that would surprise me
13:32ziltiFriend's documentation is so incredibly bad, if I had used the time otherwise I had written my own authentication system by now.
13:35ziltiIt does not even bother calling my credential-fn
13:36ziltiIt simply responds with login_failed.
13:47Morgawrhello.. I've been reading some clojure code and in one code snippet there's a call to a "some" function.. since it has a very ambiguous name I can't properly find its definition on google (or whatever), can someone tell me what it is and how to find it?
13:48morphling,(doc some)
13:48clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
13:48Morgawrmorphling: thanks!
13:50xeqizilti: do you have a snippet you need help with?
13:52ziltixeqi: https://www.refheap.com/paste/13794 That's what I have by now. Registration works flawless, so does the auth/validate-user function, but it never gets called by Friend.
13:55mebigfatguyexit
13:56xeqizilti: what do you mean registration works flawless?
13:56xeqithat when a user posts the the /register page the user gets added to the db?
13:57ziltixeqi: The stuff gets stored in my db the way it should. Yes, that's what happens
13:58xeqiI notice you don't have wrap-session
13:58xeqiis that on purpose?
13:58ziltino
13:59ziltibut I kinda expected Friend to do that stuff
14:01xeqisince you are using compojure, you might want to use compojure.handler/site or compojure.handler/api to setup the standard middleware
14:02xeqithe ring middleware ecosystem assumes you've setup and requied ones before hand. In general having each middleware setup what it needs doesn't compose well
14:03xeqithough it could be possible for them to declare they're prerequisites and have a system solve that... hmm...
14:03ziltiWell, anyway, that shouldn't be the reason stopping Friend from calling my validate-user function
14:05asalaaakhey mates
14:05asalaaak(- 465 200) (* 70)
14:05asalaaaki want to calculate 465 - 200 * 70
14:05asalaaakbut
14:05asalaaakthis expression only calculates 465 - 200
14:05asalaaakhow can i fix this
14:05asalaaakplease help
14:05asalaaak(- 465 200) (* 70)
14:05asalaaakthis doesnt calculate * 70
14:05Bronsa,(* (- 465 200) 70)
14:05clojurebot18550
14:06xeqi,(- 465 (* 200 70))
14:06clojurebot-13535
14:06Aim_Here,(- 465 200)(* 70)
14:06clojurebot265
14:07ziltiWhy does that even work?
14:07Aim_Here,(* 70)
14:07clojurebot70
14:07Aim_HereI'd have thought it would eval to 70
14:07zilti,(do(- 465 200)(* 70))
14:07clojurebot70
14:08ziltiIt does. Clojurebot only takes the first expression I gues
14:08zilti*guess
14:08asalaaakthx matesss
14:09ziltixeqi: I tried to include all the middleware defined there and found out that wrap-multipart-params is broken (It wants assoc-conj which doesn't exist)
14:12ziltiSeems like ring 1.1.8 and ring 1.2.0 are too incompatible for Friend to work. Well, I guess I just wasted a whole afternoon.
15:03tacomanis there a relatively simple way to use a C library from either Clojure or Clojurescript? Or am I going to be stuck doing something like JNI/JNA manually, then making Clojure bindings to that?
15:05tacomanI know I'm probably going to have to write wrappers eventually, but I'd prefer not to be writing two sets if I can avoid it
15:06Aim_HereI'm under the impression that until now, Clojurists figured that Java got them all the libraries they'd ever need, so they've never needed bindings and shims for native code before.
15:07arkhI haven't heard of a way to call native code outside of JNA but I don't have any first-hand experience with that
15:08tacomanI'm looking to use libtcod, but unfortunately it's a C lib
15:09arkhsweet : )
15:09tacomanno Java bindings iirc
15:09tacomanactually... hmm, looks like someone *started* work on some since the last time I looked this up
15:10tacomanclj, even, but only one commit, and a month ago
15:14bordatouehello could anyone tell me if there is any equivalent for python's dir in clojure, say if want to list all the functions available in clojure's list what would be the best way to do it
15:16joegallobordatoue: you mean functions that operate on lists?
15:17joegallolists don't really have functions... they're a datastructure
15:17gfredericksbest bet is a combo of the clojure cheatsheet and clojure.repl/dir
15:18bordatoueokay
15:18joegallohttp://clojuredocs.org/quickref/Clojure%20Core is pretty good
15:18gfredericksyeah if you had pressed me on a third thing it woulda been clojuredocs
15:19gfredericksoh also lazybot's $findfn can be nice
15:19bordatouejoegallo: i meant fns that operate on list
15:19gfredericks$findfn 3 4 7
15:19lazybot[clojure.core/bit-or clojure.core/bit-xor clojure.core/+ clojure.core/unchecked-add clojure.core/+' clojure.core/unchecked-add-int]
15:20bordatouegfredericks: how do it get this findfn in repl
15:20joegallobordatoue: okay, that's what i figured -- that's the issue, though. if you want a list of all the methods that a String has, you can look at the documentation for String, or you can use reflection to list them.
15:20arkhbordatoeu: also, http://stackoverflow.com/questions/2747294/how-to-list-the-functions-of-a-namespace
15:20gfredericksbordatoue: you don't really; much easier to have a PM with lazybot
15:20joegallobut with list, it doesn't have any functions -- there are other (disembodied) functions that happen to operate on lists, but they're not tied to list directly
15:20bordatouethats cool
15:20joegalloso you just gotta look 'em up ;)
15:21gfrederickswell i can't say for sure that getting the lazybot code and doing it from the repl is necessarily difficult
15:43Morgawrhey guys.. I'm playing around with ClojureScript.. since there's not a lot of available resources, I am copying this code http://nakkaya.com/2012/01/31/clojurescript-canvas-a-simple-breakout-implementation/ for a breakout clone but the program seems to be hanging on goog.Timer creation
15:43Morgawrthe code is exactly the same (at least, I hope) and yet with the goog.Timer declaration (At the end, last snippet of code) the code simply doesn't go past that let statement
15:44bordatouegfredericks: where can i get the information on how to interact with lazybot
15:44Morgawrif I remove that statement the code works but nothing happens (no timer, duh)
15:44Morgawranyone knows what might be wrong?
15:45gfredericksbordatoue: no idea; the README on github might help
15:46bordatouecan you show me an example on how you would interact with lazybot, I am not getting any response from it
15:46bawrHello. Which clojre repl do I want? Preferably a console version.
15:48arkhMorgawr: what does firebug / chrome dev tools say about it?
15:49arkhbawr: leinengen's?
15:49Morgawrarkh: it says "TypeError: goog.Timer is not a constructor"
15:49bawrarkh: ah, right, forgot all about lein
15:50bawrthis is what I get for taking a year break from clojure xD
15:50arkhbawr: : )
15:50arkhbawr: you'll find leinengen has some nice improvements from a year ago
15:51arkhbawr: *refinements
15:51bawrExcellent, looks like I'm in for a treat.
15:51arkhMorgawr: do you have your code up somewhere?
15:52Morgawrarkh: http://nakkaya.com/2012/01/31/clojurescript-canvas-a-simple-breakout-implementation/ it's the same as this one, literally copypasted (I typed it by hand but I also made sure this part is exactly the same)
15:52Morgawrthe last snippet
15:52Morgawrbasically (let timer (goog.Timer. (/ 1000 60)))
15:52bawrJust as a general point of interest - if I want to keep a biggish data structure in memory (say a small tree of big lists) and I want to back it up sensibly every now and then... what do I want to read? :)
15:52Morgawrthat's the part that causes error
15:55bawrmostly I don't want the backup to grind my process to a halt, so obviously persistent data structures are a win
15:55arkhMorgawr: it runs in the compiler in my head : ) maybe try that part at a repl
15:56Morgawryeah I'm still struggling with integrating the repl with the browser code
15:58arkhbawr: you may want to try http://clojuredocs.org/clojure_core/clojure.core/print-dup but I thought there was another way ... it's just not coming to me right now
15:59arkhMorgawr: I'd try it myself but I just haven't dug into clojurescript much and I'm currently working on a datomic project - sorry!
15:59Morgawrarkh: it's alright, thanks anyways
16:00Morgawrthe problem is that it says goog.Timer is not a constructor, maybe I'm missing somethin from clojure syntax (I'm still learning), what defines a constructor in Clojure?
16:00Morgawrthe call is "(goog.Timer. 1000)", if I remove the '.' at the end the error complains about Timer not being a function (rightfully so)
16:01arkhMorgawr: the constructor it refers to is (in this case) javascript interop with that google closure library
16:02Morgawr goog.Timer(opt_interval, opt_timerObject) <-- this is how the constructor is defined in the clojure doc
16:03Morgawrclojurescript doc *
16:04arkhI was looking at that (old now) twitterbuzz app rich made after the initial announcement of clojurescript - it uses goog.Timer in the same way: https://github.com/clojure/clojurescript/blob/master/samples/twitterbuzz/src/twitterbuzz/core.cljs
16:05Morgawryeah, same
16:05arkhMorgawr: double check for typos is all I can think of
16:06Morgawrarkh: oh damn! I think I found the problem.. I didn't have the correct require
16:06Morgawrcurse me, sorry for the trouble ^^
16:06arkhhaha - I've done the same - it's all good
16:11recursor`,(println "Hello clojure programmers!")
16:11clojurebotHello clojure programmers!\n
16:11recursor`SWEET
16:13Morgawris there a ,(quit) ? :D
16:14recursor`Hopefully not XD
16:15Bronsait should be disabled
16:15Bronsa,(System/exit)
16:15clojurebot#<CompilerException java.lang.NoSuchFieldException: exit, compiling:(NO_SOURCE_PATH:0:0)>
16:16Bronsa,(System/exit 1)
16:16clojurebot#<SecurityException java.lang.SecurityException: denied>
16:16Bronsayeah
16:16recursor`,(def my-name "recursor94")
16:16clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:17recursor`,(let [my-name "recursor94"]
16:17recursor`(println my-name))
16:17clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:17recursor`,(let [my-name "recursor94"] (println my-name))
16:17clojurebotrecursor94\n
16:19recursor`,Math/PI
16:19clojurebot3.141592653589793
16:40tacomandoes anyone here actually use Ritz? Everything I've seen suggests the normal nrepl client is used by everyone, but I'm not sure if there's any advantages/disadvantages to switching
16:46tacomanactually, it's in addition to, not instead of, on closer look. silly question, that
16:48technomancytacoman: if you are lucky, you will never need a stepping debugger because you never have to deal with buggy code that's excessively deep or stateful. but if you find yourself needing one, ritz seems like your best bet.
16:49tacomanyeah, I'm hoping so. now that I'm out of school and had a few months off, I'm looking at finally doing some actual work in Clojure in some of my downtime
16:49tacomanhoping it's both an enlightening and entertaining experience :)
16:53weavejesterzilti: Just noticed your earlier message. Ring 1.2.0 is backward compatible with 1.1.8, so any code you have that can run with 1.1.8 can run with 1.2.0
16:54ziltiweavejester: It seems to me like it's not since compojure didn't like it at all. Anyway I wrote my own authentication now ;)
16:54weavejesterzilti: Compojure is definitely compatible with Ring 1.2.0
16:55weavejester1.2.0 doesn't change any existing functions. It follows semantic versioning pretty strictly.
17:45Glenjaminis there a nice way to conditionally put things into -> ?
17:47bbloomGlenjamin: see also cond-> and as->
17:47bbloomgenerally, (find-doc "->")
17:48Glenjaminah, that's a good tip
17:48Glenjamini've got 4 forms, and only one is conditional
17:50bbloom,(-> 5 (* 2) (as-> x (if (even? x) (dec x) x)) (- 3))
17:50clojurebot6
17:52Glenjaminheh, the docstring for as-> does not make that obvious
17:52bbloom(doc as->)
17:52clojurebot"([expr name & forms]); Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form."
17:52Glenjaminreading it again after seeing the example, i get it
17:53bbloomyeah, needs an example
17:53Glenjaminshame about clojuredocs being out of date
17:53bbloomagreed
17:54Glenjaminand the clojure.org cheatsheet - it's missing a bunch of 1.5 niceities
17:55bbloomdnolen: in addition to some cljs hacking, i'm interested in linear problems & optimization w/ core.logic, we should add that to the infinite list of projects to work on
17:58mthvedt,(keyword "")
17:58clojurebot:
17:58mthvedt,(: {})
17:58clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :>
17:58mthvedthmm
17:59bbloommthvedt: yeah, most core functions do not check their arguments b/c it would have a perf penalty
17:59bbloommthvedt: ##(keyword "////////+!@#$%^&*()~`=\\123")
17:59lazybot⇒ :////////+!@#$%^&*()~`=\123
18:01mthvedt,(print-dup (keyword "") *out*)
18:01clojurebot:
18:02mthvedthaving keywords in memory that you can't write and read again
18:02mthvedtseems like a violation of some principle or other
18:03bbloommthvedt: yeah, so don't do that :-P
18:03TimMcI don't like programs that make keywords out of arbitrary strings/
18:03mthvedtplaying with a json parser
18:04mthvedtproblem happens when you have "" as a json key
18:04TimMcJSON libs are OK, I guess, as long as you're using JSON with a known schema...
18:04bbloom(inc TimMc) ; fixed schemas when keywordizing json
18:04lazybot⇒ 37
18:04bbloompersonally, i don't think there is anything wrong with strings for keys, other than you can't do (:keyword map)
18:05bbloom(map "string") is pretty reasonable
18:10Glenjaminpresumably keywords are basically interned strings with nice syntax
18:11Glenjaminbetter memory usage and faster lookup / comparison would make them preferrable to strings as map keys - no?
18:13bbloomGlenjamin: in general, yes. however, when parsing from strings, you'd need to do an extra lookup from string -> keyword, which is virtually the same as string key -> val. so you'd only really get a win if you are doing a lot of reads from the json structure. and even then it won't matter at all if your map is relatively small
18:13Glenjaminah, i see
18:14bbloomGlenjamin: also, if you've got an algorithm, odds are that some JSON serialization shape is not a 1 to 1 match to your internal data structures for the algorithm, so you can convert to keywords when preparing those data structures
18:15bbloomthe bigger issue is one of semantic sanity: json does not have keywords.
18:16bbloomif i give you some json w/o an agreed upon schema, you have no way of knowing whether or not keys will contain valid keyword identifiers, nor will you know if it would even make sense to view them as such... like a mapping of user names to profiles or whatever
18:16bbloomyou might want {"bbloom": {"first_name": "Brandon", "last_name": "Bloom"}} which would be most reasonably interpreted as {"bbloom" {:first-name "Brandon" :last-name "Bloom"}}, but that would require a schema
18:17Glenjaminmm, any sort of data interchange needs an agreed schema
18:17bbloomdoesn't *need* it
18:17bbloombut it's often nice
18:18Glenjaminwell, you need to know what you're getting - which requires at least an informal schema
18:18bbloomyup
18:18Glenjaminwhether you make that a formal schema, and whether it should actually be validated against the schema i'm not sure
18:19bbloomdepends on many factors: do you trust the data source your loading? do you expect it to change? how can it change with or without breaking you? do you have a variety of services that need to interoperate and you want to validate them?
18:20bbloomjust like you write tests to make sure your code is correct, you can write schemas to make sure your data is correct
18:20bbloomjust like you write defense assertions & throw errors on bad input, you can validate a schema to keep clients honest & valid
18:21Glenjamini guess it comes down to how often you expect it to fail, and then weighing up the cost of validating each payload via a schema, or just having it fail when you try and read the missing data
18:21Glenjaminat this moment i'm writing a test which asserts an api payload i'm sending matches an xsd schema, but I wouldn't run it at runtime in this case
18:22bbloomyeah, if you trust the client not to send pathological documents that will put your code into an infinite loop or something, then you're good :-)
18:22Glenjaminand related, java api docs are really annoying - they use a bunch of classes without saying which namespace they exist in :(
18:22bbloomindeed.
18:27Glenjamincan't seem to find an existing clojure example of xsd validation either :(
18:28bbloomGlenjamin: rely on the java libs
18:28bbloomthat's what they are there for!
18:28Glenjaminmm, but they're awful! DocumentBuilderFactory.newInstance().newDocumentBuilder();
18:29bbloom(defn doc-builder (.newDocumentBuilder (DocumentBuilderFactory/newInstance)))
18:29bbloomboom. wrapped.
18:29bbloomget back to work :-)
18:29Glenjaminheh, cheers - not quite got the hang of the java interop yet
18:34bbloombtw, i forgot []
18:34bbloomheh
18:55bttfwhere can i find a list of lein templates? i am looking for one with ring/compojure bootstrapped
18:56Glenjaminis there a neat way to filter a sequence of maps to those which are supersets of a given map?
18:59gfredericksselect-keys would help
18:59gfredericks(let [ks (keys m)] (filter #(= m (select-keys % ks)) maps))
19:00Glenjaminseems reasonable, cheers
19:00bttflein new compojure did_it_for_me_thanks
19:01Glenjaminis there a logical reason why filter takes [pred coll], seems fairly arbitrary having to use ->> over ->
19:02bbloomGlenjamin: it's to facilitate partial application
19:02bbloom(def evens (partial filter even?))
19:02Glenjaminmm, i see
19:04bbloomas a bonus, you get less stacking close parens w/ literal functions
19:04Glenjaminhrm, is there a better way of writing (->> coll (filter pred) first) then?
19:04bbloom(filter #(f (g %)) coll) vs (filter coll #(f (g %)))
19:05bbloomGlenjamin: that will work fine
19:05Glenjaminyeah, just feels a tad messy for some reason
19:05bbloomif a function takes 1 argument, then there isn't really a difference between -> and ->> is there?
19:05bbloomit's not messy
19:06Glenjaminhrm, not so much messy, as repetitious - selecting the first matching item from a collection seems fairly common
19:07Glenjaminmaybe i should be using some
19:07bbloomsome is better for that specific case, yes
19:08Glenjaminright, i knew something was bugging me about the construction
19:08Glenjaminthanks
20:07neilmockclojurescript folks: anyone had success running a client-side repl outside of hosted html page, eg chrome extension.
20:10bbloomneilmock: currently, you need a server to run the production-quality cljs repl. it depends on java
20:11bbloomneilmock: there is at least one cljs port that runs fully in cljs, so in theory could work in a chrome extension. however, that fork was made a while ago, so it's probably kinda out of date & definitely does no optimizations in the absence of google closure compiler
20:12neilmocksorry, I meant connecting to server repl via browser repl. in the same way opening http://localhost:9000 with (repl/connect "http://localhost:9000/repl&quot;) in the generated js
20:12neilmockafaik there are some protocol issues when not loading html from server
20:13bbloomno theoretical issue with that to the best of my understanding. probably just a "simple matter of programming"
20:14neilmockgotcha. "Uncaught Error: URI chrome-extension://jlnmhnikmhdpmmhlajecejebdecghgpf/robots.txt is invalid for field ppu " is my current nemesis
20:14bbloomneilmock: turn off all closure optimizations, so you won't have strange field names like ppu & you can maybe make sense of it
20:15bbloomif you find a particular thing that blocks you, you can propose a patch to cljs
20:15neilmockbest i could find is a google groups post stating "Loading the file directly in your browser will not work. The Closure transport we use does not support that anymore."
20:15neilmockwhich led me to believe dealing with a chrome extension would be problematic
20:16neilmockalso don't have optimizations enabled at the moment
20:17bbloomthe repl transport probably assumes http
20:17bbloomdo chrome extensions not offer an http scheme for access resources?
20:18neilmockprobably so. I think I understand the issue so far I'll dig into it a bit. many thanks for the feedback
20:19bbloomdid you look at the stack trace of that error? is it coming from google closure http handling code?
20:22neilmockbbloom: I think it is originating from Chrome. re: http://comments.gmane.org/gmane.comp.java.clojure.user/60605
20:24bbloomneilmock: ok, gotcha. dnolen already clearly understands all this stuff :-P have you looked at src/cljs/clojure/browser/net.cljs ? there is an IConnection protocol
20:24bbloomyou can implement one that is chrome extension friendly
20:24bbloomyeesh that's an ungly protocol tho....
20:25bbloomugly*
20:25neilmockheh yeah, was taking a look...
20:25neilmockisn't the end of the world, was just seeing if possible
20:25bbloomlike i said: no theoretical blockers
20:25bbloom(that i know of)
20:48Morgawrguys, I am using repl with lein and clojurescript (using web repl), is there a way to use up/down arrows to cycle through commands?
20:53bbloomMorgawr: use rl_wrap
20:53bbloomor rlwrap or whatever it is called
20:53Morgawrhow does it work? is this a plugin?
20:53bbloomit's a command line tool that gives rudimentary readline support to any other command line tool
20:55Morgawrbbloom: this is great! Thank you very much it works like a charm
20:55bbloomrlwrap is magic. love it
20:55Morgawryeah :D
20:55Morgawranyhow, thanks and goodnight
21:31blrhey there, anyone happen to know if lighttable has a fuzzy file finder feature similar to ctrlp in vim?
21:36mynomotoblr: it has. You need to include the directory in the workplace. Then, ctrl+o and type away.
21:45blrmynomoto: awesome thank you!
22:43TimMcThe Clojure Conj 2013 email says "Save the Date!" but doesn't say which date.
22:44xeqiNov 14-16
22:44xeqiits in the image
22:44TimMcOh, OK.
22:44TimMcMy mail client doesn't do well with images sometimes.
22:44TimMcand it's certainly not in the text version
22:44xeqiagreed, -1 for not being in the text
22:54gfredericksTimMc: that issue tripped me up a couple times as well
23:59technomancyheh; oops