2013-04-26
| 04:13 | sleetdrop | is there a newer textmate bundle for clojure, the one I find on github still use cake, cake is merged in to lein now |
| 04:17 | clgv | sleetdrop: why dont you use one of the big three dev environments for Clojure: Emacs, Eclipse+Counterclockwise or Vim? |
| 04:17 | ucb | clgv: surely you means emacs, emacs or emacs? </troll> |
| 04:17 | Raynes | Well, probably because he doesn't want to use any of those editors. |
| 04:17 | clgv | ucb: nope. I am an active CCW user ;) |
| 04:18 | ucb | :) |
| 04:18 | clgv | Raynes: very likely, but he will get himself in trouble with an unmaintained plugin (or similar) for another editor ;) |
| 04:18 | Raynes | sleetdrop: Unfortunately no, all the textmate bundles out there are horrible. The best you can do with those kinds of editors is Sublime Text 2 with the sublime-lispindent plugin/hack/baaaaah |
| 04:20 | sleetdrop | clgv:thanks for your advice |
| 04:21 | amalloy | clgv: your same argument applies to anyone using an editor that's not in the Big One as to one that's not in the Big Three. it's just a difference of degree; if he's familiar with textmate he might as well use it |
| 04:21 | Raynes | amalloy: Go to bed, dude. |
| 04:22 | sleetdrop | Raynes:I am a newbie of clojure, just want to try it a little. so I can edit the code with TM, and run it from command line with lein. |
| 04:23 | amalloy | sleetdrop: yes, that's a good approach |
| 04:23 | amalloy | it'd be a good idea even if you were already a whiz at an editor with good clojure integration; you want to know how things really work before you learn some shortcuts |
| 04:39 | silasdavis | on this topic... what canned emacs configs would people recommend for clojure. I have installed https://github.com/overtone/emacs-live, but am yet to use it |
| 04:39 | silasdavis | it may be what I want.. |
| 04:40 | scottj | silasdavis: not sure if they have anything clojure specific, but there's also prelude and emacs-starter-kit |
| 04:40 | silasdavis | I'm currently a vim user, and I am lead to believe clojure support is nicer in emacs across the board, although paredit which is my chief desire is available.. |
| 04:42 | noprompt | alexbaranosky: you still around? |
| 04:52 | amalloy | silasdavis: emacs support is better, but vim's is quite reasonable as i understand it |
| 04:52 | clgv | amalloy: I won't forbid him to use it - I just would not advice him to use a dev environment that does not support the language he wants to develop in for productive every day usage |
| 04:53 | clgv | amalloy: for the purpose of just learning the language pick any editor you like and use the leiningen repl ;) |
| 04:56 | noprompt | is the discussion about vim's clojure support? |
| 04:58 | scottj | noprompt: appears so |
| 04:58 | noprompt | because if that's an issue with the developer in question, i've found a combination of evil-mode and key-chord with emacs can prove to be a much more hospitable experience for working with clojure for those coming from vim. |
| 04:59 | clgv | noprompt: not my posts. I just suggested to use Emacs, CCW or vim for Clojure dev ;) |
| 05:00 | noprompt | vim can be a nice environment for most languages, and tooling has gotten much better for lisp, but it's simply pales in comparison to what you get with emacs. |
| 05:01 | silasdavis | I intend to use both editors |
| 05:01 | silasdavis | I'm also learning to write with my left hand |
| 05:02 | babilen | silasdavis: You have to give vim-fireplace (and related tooling such as vim-redl) a try. tpope did some great work with other people and it is nice to use. |
| 05:03 | noprompt | babilen: totally agree. |
| 05:03 | babilen | silasdavis: One problem you will encounter is that /other/ people target emacs and, for example, ship specific modes for their software. Midje does that and there is simply nothing comparable for vim (the situation here got better ever since we have the wonderful repl functionality) |
| 05:04 | silasdavis | babilen, thanks for those looks interesting |
| 05:04 | silasdavis | does the break point feature allow you to inspect variable subsitutions line-by-line? |
| 05:05 | silasdavis | really missing this in my clojure work |
| 05:06 | babilen | silasdavis: Another example would be https://github.com/technomancy/slamhound -- It is perfectly usable outside of your editor, but ships a elisp for nice integration into Emacs. |
| 05:07 | babilen | silasdavis: To be honest: I use and used both editors and quite often prefer vim (textobjects are a huge factor in that) and the tooling is certainly mature enough to be usable. I haven't played too much with vim-redl yet so I can't comment on that particular functionality, but it is definitely worth a try. |
| 05:08 | noprompt | i also use both editors, and i came to emacs from vim through evil-mode, and must say i prefer emacs much more. |
| 05:09 | noprompt | part of that stems from my frustration with viml. |
| 05:10 | silasdavis | babilen, I'm quite fond of text objects too, particularly for things like vim-surround, is there anything comparable in emacs? |
| 05:10 | noprompt | silasdavis: there's evil-surround. |
| 05:10 | noprompt | silasdavis: have you tried evil-mode at all? |
| 05:11 | silasdavis | noprompt, I'm not a fan of VimL (hand't heard that before), seems much nicer to have lisp config |
| 05:12 | babilen | silasdavis: There is no direct equivalent of text objects in Emacs AFAICT, but I am more proficient in vim than in Emacs. I think it is one of the main differences in culture between Emacs and vim (in that vim has the "do something to object k times" philosophy that works with everything) |
| 05:12 | silasdavis | noprompt, I haven't I was sort of planning to take the plunge and go native though |
| 05:13 | noprompt | silasdavis: i'm not sure "native" emacs is worth it. in fact, it's what kept me from using the editor at all. if the vim key bindings have taken root in your muscle memory, trying to learn the emacs bindings coming from vim is much like trying to learn dvorak coming from qwerty. |
| 05:13 | babilen | noprompt: I use(d) both and prefer vim, but I guess that everyone has to figure it out him/herself ... All I wanted to say is that vim is a perfectly usable development tool for Clojure and there might even be reasons to prefer it over alternatives. |
| 05:15 | silasdavis | babilen, I appreciate the info, would't have found it otherwise |
| 05:15 | noprompt | babilen: sure it's quite usable. heck, i used it for several months with VimClojure, fireplace, etc. i've even contributed to the vim-clojure-static runtime files. but at the end of the day the experience was kind of frustrating. |
| 05:15 | babilen | why? |
| 05:15 | clojurebot | Why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone |
| 05:16 | babilen | clojurebot: shush! |
| 05:16 | clojurebot | Huh? |
| 05:16 | silasdavis | noprompt, I'm sure you're right, and in fact I'm coming at from the perspective that a bit of mental plasticity is good for you. In fact I'm planning to learn colemak... |
| 05:17 | noprompt | babilen: well VimClojure would crash randomly, but i really liked the repl and the way it looked up documentation, etc. (when it wasn't crashing). fireplace was nice too but i really missed the VimClojure style of development. |
| 05:17 | noprompt | i saw what the emacs environment had to offer, heard about evil-mode and tried it out. |
| 05:19 | babilen | noprompt: Okay, sounds as if vim-redl is what you want then ;) -- I agree that VimClojure had its problems (e.g. buffer handling), but the experience is not really comparable to vim-fireplace. I perceive the latter as a well thought-out and stable/usable tool that just lets me work. I personally also /prefer/ being able to use/connect to my "normal" nrepl REPLs, but that is definitely personal preference. |
| 05:20 | babilen | noprompt: In the end it is not so much different from what Emacs does in that you connect to an nrepl REPL. I don't need my editor to also handle the window management (I have a window manager or tmux or ... for that), but I even could run it in a vim shell) |
| 05:21 | noprompt | babilen: maybe, but vim doesn't let me have an IRC chat session open (which i'm using now), or let me run a shell (that isn't qwerky). |
| 05:21 | babilen | There was also a time were the Emacs tooling was working worse than vim-fireplace -- (just google for install problems of slime, ...) |
| 05:22 | babilen | noprompt: And why should it? (but lets not get into this, please) -- I am using irssi in a wonderful shell running inside tmux ... I can switch to my editor and arrange all this with tmux's or my window manager's functionality. |
| 05:22 | noprompt | there's something very nice about never having to leave your editor, and if vim had subprocesses and viml was decent i would never look back. |
| 05:23 | noprompt | babilen: that's fine and i've actually got a fair bit of customization for that in my vimrc. but i just felt like it was a bit hackish and error prone. |
| 05:24 | noprompt | btw, i don't think vim is a bad editor at all. in fact, i've found editing code in emacs very frustating in some cases. |
| 05:24 | babilen | noprompt: The approach to this is *the* underlying cultural difference. If you want Emacs then you simply want it, but that has little to do with the Clojure tooling in itself. |
| 05:25 | silasdavis | is tmux better than screen? |
| 05:25 | babilen | much |
| 05:25 | noprompt | indeed. |
| 05:26 | silasdavis | can it run daemonised |
| 05:26 | babilen | silasdavis: sure |
| 05:26 | silasdavis | like 'screen -dmS session-name <command to run unattended>' |
| 05:27 | babilen | haha |
| 05:28 | silasdavis | because I should probably know about this stuff |
| 05:28 | noprompt | babilen: i'm not so sure. i think the core philosophies of modal editing are sound. indeed it's why i love vim so much. but at the end of the day if it's just modal editing you want, and the editor you have is sufficiently equipped to handle such a task *and* give you more in return, then why use vim? |
| 05:29 | noprompt | silasdavis: ha! i had a day like that today! someone sent me a stack overflow post about programming jokes and it ate up nearly an hour of my time. |
| 05:30 | babilen | noprompt: Well, you also lose things. it's not that emacs+evil-mode is vim. And I wasn't referring to modal editing but to the "unix philosophy of doing one thing well" vs "do everything in Emacs OS" |
| 05:30 | noprompt | babilen: point well taken. |
| 05:32 | silasdavis | this perhaps links to the tension between elegant powerful tools and integrated possibly compromised tools |
| 05:32 | noprompt | babilen: emacs + evil mode is certainly not vim, i'll give you that. |
| 05:32 | silasdavis | for example visual studio with the resharper plugin really is quite powerful in its code intelligence |
| 05:33 | silasdavis | it's editor is just about good enough, and there is a vim plugin, but there is enough friction that you end up turning it off |
| 05:33 | silasdavis | I'm interested to see what happens with lightbox |
| 05:33 | silasdavis | lighttable rather: http://www.lighttable.com/ |
| 05:33 | noprompt | the unix philosophy is certainly the right philosophy in many cases, but i think if you built every tool/library/program with that intent you might be doing more harm than good. |
| 05:34 | babilen | noprompt: I am simply more productive in vim and thats what counts in the end, doesn't it? Emacs just doesn't "feel" right and I missed a lot of little things all the time. (textobjects for example) ... And given that Clojure tooling on vim is excellent now and gets /a lot/ of attention by gifted developers its just wonderful |
| 05:34 | noprompt | silasdavis: so am i. i think light table might turn out to be a real nice place between emacs and vim. |
| 05:34 | babilen | yeah |
| 05:35 | silasdavis | you've probably come across this, but in case not: http://blog.sanctum.geek.nz/series/unix-as-ide/ |
| 05:36 | noprompt | babilen: it took me one week to return to same level of productivity w/ emacs + evil-mode coming from vim. |
| 05:37 | noprompt | on top of that i've been able to pick up emacs lisp far more rapidly than viml. filling in the missing blanks has been almost trivial. |
| 05:38 | babilen | noprompt: I tried it for longer than that, but went back and am more than happy. Lets conclude with that. All I wanted to point out is that Clojure tooling is good and is getting better by the minute on vim and that picking an editor is /much/ more specific to capabilities of the Editor itself and your needs .. |
| 05:39 | babilen | (or preferences) |
| 05:39 | silasdavis | hmm I managed unbalance my parenthesis with emacs paredit |
| 05:39 | noprompt | babilen: i won't disagree with you there. and will agree to leave it up to personal preference/philosophy. |
| 05:40 | silasdavis | but using 'kill region' |
| 05:40 | silasdavis | should that be possible..? |
| 05:40 | babilen | silasdavis: Can you reproduce that in vim ;) |
| 05:40 | noprompt | silasdavis: sure that can happen. it can happen with vim's paredit too. |
| 05:41 | noprompt | nothing's stopping you from hitting 'x'. |
| 05:42 | babilen | x won't unbalance paranthesis (or delete a pair) |
| 05:42 | noprompt | or 'r', 'R', 'cw', etc. |
| 05:43 | babilen | that's simply not true .. there might be bugs (and I'm sure there are), but in general you cannot unbalance paranthesis. I mean that's one of the main points of paredit :) |
| 05:43 | noprompt | babilen: oh yeah, you're right. |
| 05:44 | silasdavis | I am using some weird heavily customised emacs config |
| 05:44 | noprompt | what's not true? you can use 'r', 'R', and 'cw' on a ')'. |
| 05:44 | silasdavis | <noprompt> silasdavis: sure that can happen |
| 05:44 | noprompt | silasdavis: did you customize it? |
| 05:45 | silasdavis | no: https://github.com/overtone/emacs-live |
| 05:45 | silasdavis | if I do C-w |
| 05:45 | noprompt | then throw it in the trash and customize it yourself :) |
| 05:45 | silasdavis | it will delete until the end of line it seems |
| 05:45 | silasdavis | and will unbalance parens |
| 05:45 | noprompt | yeah, hang on. i think i know what you want. |
| 05:45 | silasdavis | noprompt, but it's so... colourful |
| 05:46 | babilen | silasdavis: Please read http://clojure-doc.org/articles/tutorials/emacs.html (it's based on technomancy's starter kit IIRC) |
| 05:46 | noprompt | there's a way to kill an sexp w/o fucking the whole thing up. |
| 05:46 | babilen | silasdavis: but then: use vim! |
| 05:46 | babilen | </end> |
| 05:49 | babilen | silasdavis: fwiw, there is also http://clojure-doc.org/articles/tutorials/vim_fireplace.html which will walk you through a sensible vim setup (throw in vim-redl https://github.com/dgrnbrg/vim-redl if you require that functionality) |
| 05:50 | rodnaph_ | lazyirc... someone recently released a library with some handy macros for doing things like if-let with mutiple bindings, and an if-when... did anyone else see this i can't find it now... :( |
| 05:50 | rodnaph_ | i'm sure it was cgrand... but can't see anything on his github. |
| 05:51 | rodnaph_ | hehe, well ping me if you remember first, thanks :) |
| 05:52 | silasdavis | babilen, do they package paredit or shall I have that too? |
| 05:52 | rodnaph_ | babilen: i've been meaning to try vim-redl for a while, will give it a go now (i'm still using VimClojure) |
| 05:54 | noprompt | salisdavis: paredit-kill-sexps-on-whole-line, which is a mouthful, but i think it's what you're looking for. |
| 05:57 | noprompt | whoops, my bad it's simply paredit-kill-sexps-on-line. |
| 05:58 | noprompt | i have that bound to "D" in my evil normal state. it won't screw up the balance. |
| 05:59 | babilen | rodnaph_: Oh, you /have/ to switch to vim-fireplace from VimClojure. It is much better :) |
| 06:00 | babilen | silasdavis: paredit is available, sure ... https://bitbucket.org/kovisoft/paredit/ |
| 06:04 | noprompt | fwiw, the maintainer of vim's paredit plugin is a very good guy. |
| 06:04 | noprompt | he fixed several bugs i discovered while working with the plugin and was quick to fix the issues. |
| 06:05 | noprompt | the plugin is excellent. |
| 06:05 | noprompt | slimv actuall isn't bad either considering vim's lousy support for that sort of thing. |
| 06:06 | noprompt | off topic, does anyone use korma? |
| 06:10 | rodnaph_ | babilen: ogm i have a semi-decent repl in vim! :D |
| 06:10 | silasdavis | noprompt, yes but I only picked it up about a week ago |
| 06:10 | babilen | rodnaph_: I'm using "lein repl" but yay! |
| 06:11 | rodnaph_ | i was using lein repl, with slimv (which worked pretty well tbh). gonna give this a go for a bit. |
| 06:12 | rodnaph_ | actually... i don't seem to be able to send stuff to the repl... |
| 06:13 | noprompt | http://f.cl.ly/items/3w0E1A420H043r383p2G/Screen%20Shot%202013-04-26%20at%203.09.59%20AM.png |
| 06:13 | rodnaph_ | noprompt: if only i could get used to emacs... have given it a go a few times, but always come back to vim. |
| 06:14 | noprompt | rodnaph_: i only came to it via evil-mode and key-chord. |
| 06:15 | borkdude | hmm, if a function expects arguments like :foo "bar" :foo2 "bar2" instead of a map, what is the best way to pass the arguments if you have already a mp |
| 06:15 | noprompt | i also had to add a few small things https://github.com/noprompt/matilde/blob/master/emacs.d/noprompt-evil.el#L7-L29 |
| 06:16 | noprompt | borkdude: i'm assuming the fn does something like (fn foo [& {:as opts}]? |
| 06:17 | borkdude | noprompt yes, the arglist looks like this: [& {:keys [weeknr year description budget name] :as k}] |
| 06:17 | rodnaph_ | borkdude: you can use apply if u can flatten your map to a list... ? |
| 06:18 | silasdavis | babilen, I'm trying to enable paredit mode in a running vim with let g:paredit_mode = 1 |
| 06:18 | silasdavis | doesn't seem to wrok |
| 06:18 | borkdude | rodnaph_ I was thinking of things that could go wrong since order is not guaranteed, but yeah, only the order of mapentries is not guaranteed of course |
| 06:18 | silasdavis | It should auto close a '(' right? |
| 06:18 | silasdavis | I'm in an empty buffer |
| 06:18 | noprompt | borkdude: this might be ugly but, (apply f (-> {:foo "bar" :baz "quux"} seq flatten)) |
| 06:18 | rodnaph_ | silasdavis: in a clojure file? it'll probably use the filetype |
| 06:19 | borkdude | noprompt or maybe I just have to change the other function to expect a map ;) |
| 06:19 | noprompt | borkdude: that's what i've tended to do. |
| 06:20 | silasdavis | rodnaph, I'm not in a clojure file but I think that command should be turning it on |
| 06:20 | babilen | silasdavis: Are you editing a .clj file? Can you run ":call PareditToggle()" ? |
| 06:20 | noprompt | borkdude: [& {:as opts}] looks nice but it can throw a wrench in the composability machine. |
| 06:21 | silasdavis | oh it works in a clj file |
| 06:21 | silasdavis | babilen, the toggle function works |
| 06:21 | silasdavis | g:paredit_mode = 1 doesn't |
| 06:21 | silasdavis | even in vimrc |
| 06:21 | silasdavis | perhaps it only works to disable it (it is listed in docs) |
| 06:21 | babilen | silasdavis: Yeah, it uses the filetype or you have to activate it explicitly for other filetypes. That is documented in its documentation IIRC and easily customisable. |
| 06:21 | noprompt | borkdude: [& {:as opts}] is kinda like having an implicit hash in ruby - it's no fun and confusing. |
| 06:22 | noprompt | reduce the cognitive load by avoiding that kind of thing. |
| 06:22 | babilen | silasdavis: You can disable it for the filetypes it is activated in by default with that setting AFAIUI -- If you want it for other filetypes you have to add them to the supported filetypes. |
| 06:23 | borkdude | noprompt I think I read somewhere (in the style guide?) that (foo :a 1 :b 2) was more idiomatic than (foo {:a 1 :b 2}) |
| 06:25 | noprompt | it can be in some cases. i guess it really depends on what you're trying to do. also, idioms, while good to adhere to, are like rules - at times they're meant to be broken. |
| 06:27 | noprompt | to muddy things, that's just my opinion. :) |
| 06:27 | noprompt | personally i prefer explicit over implicit. |
| 06:28 | tomoj | how do you untie a nom? :( |
| 06:28 | noprompt | when you start dabbling in implicit styles of coding you're just asking for it. |
| 06:30 | noprompt | borkdude: i'd say this: if having an implicit map is causing you enough trouble to have to bend over backwards in several places in your code then go for the explicit map. |
| 06:34 | clgv | borkdude: if you want to pass on optional parameter maps and also want transitive documentation for optional parameters, then checkout https://github.com/guv/clojure.options |
| 06:34 | mindbender1 | is there a function to remove a thing from vector |
| 06:35 | clgv | mindbender1: yep, for the last element: ##(pop [1 2 3]) |
| 06:35 | lazybot | ⇒ [1 2] |
| 06:35 | mindbender1 | (remove [1 2 3] 3) |
| 06:35 | mindbender1 | what of (remove [1 2 3] 2) => [1 2] |
| 06:36 | mindbender1 | what of (remove [1 2 3] 2) => [1 3] |
| 06:36 | clgv | if you want to keep the vector datatype you can only add to and remove from its end |
| 06:37 | mindbender1 | is there a structure supporting this wsh |
| 06:37 | mindbender1 | wish |
| 06:38 | borkdude | you can also use subvec (but personally I've never needed it) |
| 06:38 | noprompt | ,(doc subvec) |
| 06:38 | clojurebot | "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done." |
| 06:38 | clgv | right. but you cant compose two subvecs into one vector again efficiently |
| 06:39 | mindbender1 | I think this will be a convinience |
| 06:40 | clgv | removing efficiently works with sets and hash-maps. |
| 06:41 | clgv | maybe you need an hash-map with sorted keys |
| 06:41 | clgv | *removing arbitrary elements efficiently |
| 06:42 | mindbender1 | though based on arrays => https://www.refheap.com/paste/13980 |
| 06:42 | mindbender1 | but looks convinient |
| 06:43 | svedubois | How can you write these clojurescript lines in a short way? |
| 06:43 | svedubois | https://www.refheap.com/paste/13979 |
| 06:47 | clgv | mindbender1: is this a real array underneath? if so there are worst case O(n) elements to shift. |
| 06:48 | clgv | mindbender1: just in case this code happens to be part of a bottleneck |
| 06:49 | clgv | svedubois: is there a `doto` macro in clojurescript? |
| 06:49 | noprompt | clgv: yes. |
| 06:50 | clgv | hmm do-set would be more appropriate since the expressions are nested |
| 06:52 | noprompt | well i think i'm out for the night. take care everyone. :) |
| 07:02 | mindbender1 | what the cost of this => (defn remove [v o] (vec (filter #(not= % o) v))) |
| 07:04 | mindbender1 | clgv: sorry I didn't see ur ping |
| 07:05 | mindbender1 | the doc says it's array like |
| 07:06 | mindbender1 | I don't what the author meant but it probably runs fast enough for goog |
| 07:06 | silasdavis | babilen, is there a better alternative to ctags for use with clojure? |
| 07:21 | svedubois | I have tested the defmacro set-all! from: |
| 07:21 | svedubois | http://stackoverflow.com/questions/4579679/factor-clojure-code-setting-many-different-fields-in-a-java-object. |
| 07:21 | svedubois | (defmacro set-all! [obj m] |
| 07:21 | svedubois | `(do ~@(map (fn [e] `(set! (. ~obj ~(key e)) ~(val e))) m) ~obj)) |
| 07:21 | svedubois | But it doesn't work. Any advice? |
| 07:26 | svedubois | Perhaps, ClojureScript does support macros, but only in .clj files that are imported with require-macros. |
| 07:42 | noidi | svedubois, yes, you can only write macros in Clojure, not ClojureScript |
| 07:44 | silasdavis | will that change? |
| 07:44 | silasdavis | this refers to clojurescript macros: http://blog.getprismatic.com/blog/2013/1/22/the-magic-of-macros-lighting-fast-templating-in-clojurescript |
| 07:45 | mpenet | it's clojure macros generating clojurescript really |
| 07:45 | silasdavis | ah yes I see https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure |
| 07:45 | mpenet | this could change with "cljs in cljs " or something |
| 09:07 | melipone | hello |
| 09:07 | melipone | I am using the memoize function. How can I clear the cache and start again without restarting the repl? |
| 09:08 | ucb | melipone: what cache? |
| 09:08 | melipone | I mean whatever is memoized by the function |
| 09:08 | ucb | I'd say just create a new memoised function |
| 09:09 | ucb | e.g. if you do (def memo-f (memoize f)) just redef memo-f in your repl |
| 09:09 | melipone | ha, okay, thanks |
| 09:13 | clgv | melipone: you can do that with core.memoize an additional library |
| 09:16 | silasdavis | does anyone know of a declarative database dsl for clojure |
| 09:16 | silasdavis | so you can just write a definition |
| 09:17 | silasdavis | and have it magically update your database schema to want you want |
| 09:18 | jcromartie | is there a generic HOF that reverses the arguments to a function |
| 09:18 | clgv | silasdavis: maybe korma is what you want - check for yourself |
| 09:18 | jcromartie | (defn reverse-args [f] (fn [& args] (apply f (reverse args)))) |
| 09:18 | clgv | jcromartie: nut built-in |
| 09:19 | cmdrdats | silasdavis: I've written http://www.github.com/yuppiechef/macaron which does that |
| 09:19 | clgv | *not |
| 09:19 | cmdrdats | silasdavis: I do need to add some examples though - it's not entirely obvious when you look at the code |
| 09:20 | silasdavis | clgv, I think korma allows you to specify the relations (I intend to use it), but I don't think it will create the tables etc for you |
| 09:21 | silasdavis | cmdrdats, interesting thanks, I've also found: https://github.com/budu/lobos |
| 09:21 | silasdavis | It seems he intends to provide declarative definitions too: https://groups.google.com/forum/?fromgroups=#!topic/lobos-library/CE4itjz-yPo |
| 09:21 | nDuff | (all macros! can't compose!) |
| 09:22 | silasdavis | if you play with (analyze-schema) it outputs a sort of abstract database language |
| 09:22 | clgv | nDuff: no idea, I just read the advertisement pages ;) |
| 09:23 | silasdavis | cmdrdats, can macaron deal with databases with stuff in them already? |
| 09:23 | nDuff | silasdavis: see its update-table call. |
| 09:24 | nDuff | clgv: Really does depend on what your style is. If you tend to code more compositionally, though... korma isn't fun. |
| 09:24 | jcromartie | I have not been a big fan of any of the db libraries though |
| 09:24 | jcromartie | actually ClojureQL seemed really nice |
| 09:25 | jcromartie | I think it would be better to start with some abstraction around database tables |
| 09:25 | jcromartie | treat them as references |
| 09:26 | jcromartie | nested/tree inserts and updates are really hard though |
| 09:26 | jcromartie | I think people are used to the Rails way, which is pretty good, and so they try to make Clojure do that |
| 09:28 | silasdavis | nDuff, cmdrdats looks like it would try and alter a table, although it would die with a not null constraint - that is sort of tricky problem though. Also I see it's bound to mysql at the moment |
| 09:29 | nDuff | silasdavis: Doing It Right is a quite hard problem. I'm trying to remember the name of the toolkit I used for managing database migrations on Django, but it was a several-years-of-history / still-actively-involving kind of deal. |
| 09:29 | silasdavis | jcromartie, lobos seems to have ambitions to solve this in quite a general way, updating via diff |
| 09:30 | silasdavis | nDuff, sql server/database projects actually do some of this reasonably well. Obviously they are digusting |
| 09:30 | jcromartie | you need a declarative way to specify what to do under certain differences |
| 09:30 | silasdavis | but you can do a reasonably full sort of diff |
| 09:30 | jcromartie | it's simpler to just say "step 1, do this; step 2 do that" |
| 09:30 | jcromartie | I wrote a migration tool which worked |
| 09:32 | silasdavis | jcromartie, I think one way to avoid the update problem is to have a wipeable database, but store your test/bootstrap data as fixtures (I think that's what rails calls them in a testing context) that are loaded after schema creation |
| 09:32 | jcromartie | I've got a real solution for this, of course :) |
| 09:32 | jcromartie | store all changes to the system as events, and then cache them in a DB or in memory or however you want |
| 09:33 | jcromartie | I mean cache the results |
| 09:33 | jcromartie | so you handle schema changes by dropping and recreating the DB with the new schema and replaying events |
| 09:33 | jcromartie | the DB speed tends to be a bottleneck though, and the downtime required is pretty unrealistic |
| 09:34 | jcromartie | it only makes sense if you're going to use the DB for reporting and keep the "current" system state in memory |
| 09:35 | cmdrdats | silasdavis: sorry, got pulled away - yes, it deals with tables that already have data |
| 09:35 | cmdrdats | silasdavis: it's currently bound to mysql - but I'm planning to abstract it out so that I can use it with datomic |
| 09:36 | gdev | cmdrdats:) what does? sorry I just got here and this conversation seems relevent to what I'm doing at the moment |
| 09:36 | cmdrdats | gdev: https://github.com/Yuppiechef/macaron - a little db abstraction library I wrote a while ago |
| 09:36 | silasdavis | cmdrdats, perhaps you should keep an eye on lobos/lobo mailing list too, you have similar aims |
| 09:38 | silasdavis | although I just realised that post I linked to was 2011 |
| 09:38 | cmdrdats | silasdavis: Lobos looks interesting, but my aim with macaron is to define 'entities', generate the CRUD functions off that and have the underlying db automatically adapt when the schema changes |
| 09:38 | cmdrdats | so there's no 'migration' path |
| 09:39 | cmdrdats | also, it doesn't concern itself with query language, the named query support is in the native underlying db language (so SQL for mysql, and eventually datalog for datomic) |
| 09:39 | gdev | cmdrdats:) i saw an example of someone adapting their code to deal with schema changes by using defrecord, can't seem to find the article though |
| 09:41 | silasdavis | cmdrdats, he notes somewhat vaguely on the wiki and more explicitly on the mailing list that his desire was to automatically generate the migration, which sounds liek what you'd have to do to have the db adapt |
| 09:42 | silasdavis | also if you're going for CRUD/entities, perhaps you could use sqlkorma's relational dsl to generate/adapt the tables |
| 09:42 | silasdavis | it seems they contain the necessary information |
| 09:44 | cmdrdats | silasdavis: sounds interesting - I'll definitely take a look |
| 09:45 | gdev | silasdavis:) i'm using korma for my little project and I didn't see anything in the docs about creating a table, besides exec-raw of course |
| 09:46 | mynomoto | gdev: It doesn't create tables. Or drop, or alter them. |
| 09:46 | gdev | mynomoto:) ohhai, I know, I know, it's not an orm, that's what I was getting at =) |
| 09:47 | gdev | I was up in the wee hours of the morning trying to update rows in a database from clojure with no luck |
| 09:49 | mynomoto | gdev: gfredericks solution did'n work? It should have. |
| 09:49 | gdev | I think the dataset is too large so it's like saying (update everyone-in-the-world (set-field {:is_cool true (where {:name "gary"})) |
| 09:51 | mynomoto | gdev: but can you do the select part alone? You you can, it shouldn't be a problem. |
| 09:52 | gdev | mynomoto:) Yeah, I can do the select part, but doing gfredericks solution just made it hang |
| 09:52 | gdev | mynomoto:) so I tried just doing a simple update with a hardcoded number and that hung too |
| 09:53 | gdev | not sure if database was having issues but writing to it seemed to be a problem |
| 09:53 | mynomoto | gdev: but one simple update work? |
| 09:54 | mynomoto | gdev: can you write to the db at all? |
| 09:54 | gdev | mynomoto:) no, that's why I was thinking it might have been db issues; i was at home on VPN since the db is on company network |
| 09:54 | gdev | now that I'm at work on the company lan I'm trying it again |
| 10:04 | pl6306 | Why won't this "(map #(% (str "|" %)) ("A" "B" "C"))" work? |
| 10:05 | pl6306 | I just want to make a list with 2 string elements |
| 10:05 | dnolen | pl6306: ("A" "B" "C"), you're invoking a function called "A" |
| 10:05 | matthavener | pl6306: what's output are you expecting? |
| 10:05 | pl6306 | Yes but how do I quote it inside the function def |
| 10:05 | matthavener | (list (% (str "|" %))) |
| 10:06 | pl6306 | (("A" "=A") ("B" "=B")("C" "=C")) |
| 10:07 | matthavener | err, wait, i was totally wrong |
| 10:07 | dnolen | ,("A" "B" "C") |
| 10:07 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn> |
| 10:07 | dnolen | ,'("A" "B" "C") |
| 10:07 | clojurebot | ("A" "B" "C") |
| 10:07 | dnolen | ,["A" "B" "C"] |
| 10:07 | clojurebot | ["A" "B" "C"] |
| 10:07 | dnolen | ,(map #(str % "|" %) ["A" "B" "C"]) |
| 10:07 | clojurebot | ("A|A" "B|B" "C|C") |
| 10:07 | matthavener | ,(map #(list % (str "=" %)) '("A" "B" "C")) |
| 10:07 | clojurebot | (("A" "=A") ("B" "=B") ("C" "=C")) |
| 10:08 | pl6306 | Thanks matthavener |
| 10:08 | matthavener | be sure to understand the diff between (list a b c) and '(a b c) because its something that tripped me up at first |
| 10:09 | gdev | mynomoto:) it works! |
| 10:09 | matthavener | ,'(1 (+ 1 1) 3) |
| 10:09 | clojurebot | (1 (+ 1 1) 3) |
| 10:09 | matthavener | vs |
| 10:09 | matthavener | ,(list 1 (+ 1 1) 3) |
| 10:09 | clojurebot | (1 2 3) |
| 10:11 | mynomoto | gdev: good. No vpn next time. ;) |
| 10:12 | gdev | gfredericks:) mynomoto thanks for your help, yeah vpn is bad |
| 10:13 | svedubois | Is this conversion from js to clojurescript correct? |
| 10:13 | svedubois | cube.intersect(sphere).subtract(cylinder1.union(cylinder2).union(cylinder3)); |
| 10:13 | svedubois | (.substract (.union cylinder2 cylinder3 cylinder1) (.intersect sphere cube)) |
| 10:15 | dnolen | svedubois: hmm |
| 10:16 | dnolen | svedubois: I think the .intersect needs to come before the union |
| 10:16 | dnolen | svedubois: and you can't write union that way. |
| 10:31 | svedubois | Do you think this is correct? |
| 10:31 | svedubois | (-> cube (.intersect sphere) (.subtract (-> cylinder1 (.union cylinder2) (.union cylinder3)))) |
| 10:39 | sparkjoy | Not sure if this is the right place to ask Datomic questions, but is anyone actively working on a .NET client for the REST API? If so, we'd like to contribute. |
| 10:41 | florianover | is there a chance to do long-polling get requests with clj-http ? |
| 10:43 | dakrone | florianover: what do you mean by "a chance to do" ? |
| 10:43 | florianover | well, is it possible? |
| 10:43 | florianover | oh hi! dakrone personal! |
| 10:43 | dakrone | what do you mean by a long-polling request? how long? I don't think there's anything preventing you from doing it if that's what you're asking |
| 10:44 | dakrone | florianover: hi! :) |
| 10:44 | florianover | http://developers.box.com/using-long-polling-to-monitor-events/ |
| 10:45 | florianover | maybe it is just a problem with the api... |
| 10:45 | dakrone | hmm... I think it's possible, you'd have to send {:as :stream} with the original request, and handle parsing it yourself, since the connection wouldn't be completed for every response |
| 10:46 | florianover | ok, thx. Will try :) |
| 10:47 | dakrone | florianover: good luck, let me know how it turns out |
| 10:50 | `fogus | florianover: I'd be interested to see what you come up with too. |
| 10:51 | florianover | will respond :) |
| 10:55 | mduerksen | is there any possibility to define a default implementation for a protocol? |
| 10:57 | florianover | @dakrone it worked. i just had the wrong URL :D |
| 10:57 | dakrone | florianover: :) |
| 10:57 | dakrone | glad to hear it |
| 10:57 | florianover | i didn't had to use as stream |
| 11:02 | mduerksen | ok my bad, i can use Object :/ |
| 11:02 | borkdude | Objection your honor. |
| 11:04 | akells` | has anyone ever had issues importing java.nio.file.Paths into a clojure project? |
| 11:12 | NeedMoreDesu | Lolwut, no abs for rational numbers? |
| 11:15 | borkdude | ,-3/4 |
| 11:15 | clojurebot | -3/4 |
| 11:16 | borkdude | ,3/-4 |
| 11:16 | clojurebot | #<NumberFormatException java.lang.NumberFormatException: Invalid number: 3/-4> |
| 11:17 | AimHere | NeedMoreDesu, isn't that just because clojure's rational numbers are clojure's and Math/abs (or whatever) is wrote by java |
| 11:17 | silasdavis | any recommendation for GPG/OpenPGP signing from clojure? |
| 11:27 | NeedMoreDesu | AimHere: Oh, well, that makes sense. |
| 11:54 | ppppaul | talk |
| 12:01 | ucb | ...amongst yourselves... |
| 12:04 | silasdavis | any suggestions on where to set up a globally readable environment name like ':development', ':production', etc |
| 12:04 | silasdavis | may be sourced from environment variable in future |
| 12:04 | silasdavis | for now just want to define it in one place |
| 12:06 | justin_smith | you could (System/setProperty "environment" "production"), and better yet only set it if it does not yet exist (found via System/getProperty) |
| 12:09 | technomancy | silasdavis: I use environ for that |
| 12:14 | silasdavis | technomancy, perfect thanks |
| 12:17 | tbaldridge | hey, I have 3 namespaces a, b and c. b refers a and c refers b. Is there a way to make a's defs show up in any namespace that refers b? |
| 12:17 | arrdem | tbaldridge: not idiomatically no |
| 12:17 | tbaldridge | so far it seems refer only brings in vars that are defined inside the namespace being refered. |
| 12:18 | arrdem | tbaldridge: yes that is expected behavior |
| 12:18 | tbaldridge | how about not idiomatically. |
| 12:18 | arrdem | tbaldridge: I mean you can (def foo bar/foo) |
| 12:18 | arrdem | tbaldridge: and there is an oft-bashed library which automates that |
| 12:18 | tbaldridge | yeah, I thought of that, but that looses doc strings, |
| 12:18 | arrdem | tbaldridge: lemme dig this moster out for you hang on |
| 12:19 | justin_smith | you could pull in the meta too, no reason not to |
| 12:19 | arrdem | tbaldridge: potemkin is the tool you want... |
| 12:19 | arrdem | tbaldridge: but that's a huge code smell and amalloy et all would tell you to rework your api rather than use it |
| 12:19 | tbaldridge | I'll take a look, thanks. An yes, I know I shouldn't be doing this :-P |
| 12:20 | silasdavis | tbaldridge, what's the use case out of interest? |
| 12:21 | silasdavis | sounds like a sort of delegation pattern |
| 12:21 | silasdavis | only I wouldn't want to do it through namespaces |
| 12:21 | silasdavis | but I don't know much about metaprogramming in clojure |
| 12:22 | tbaldridge | no, I have one namespace that includes many functions, the supporting code for those functions is quite large. Thus, I'd like to keep all protocols in one namespace, and the common implementations of those namespaces in another. |
| 12:22 | tbaldridge | So yeah, I'm going to figure out a better way. |
| 12:26 | arrdem | tbaldridge: I guess it depends on how big your "common case" implementation is, but I would say try to group the common case with the protocols and then provide the special cases elsewhere. |
| 12:27 | ppppaul | i have an orange. i would like to somehow use agents to help me devour this orange, but i haven't used them before and i'm wondering if there is something i should read first... some sort of agent tutorial possibly related to oranges |
| 12:27 | silasdavis | and what will you call your agent? |
| 12:28 | no7hing | :D |
| 12:28 | arrdem | silasdavis: IFruitEater, FrutEatingAgent |
| 13:01 | daydreamt | Does irclj support connections to irc servers that use ssl? |
| 13:53 | MarcoPolo | ,(println "test") |
| 13:53 | clojurebot | test\n |
| 13:55 | MarcoPolo | ,(let [x |
| 13:55 | MarcoPolo | (for [x (range 10) ] |
| 13:55 | MarcoPolo | (do (println "Evaling" x) |
| 13:55 | MarcoPolo | [x]))] |
| 13:55 | MarcoPolo | (first x)) |
| 13:55 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 13:56 | MarcoPolo | &(let [x |
| 13:56 | MarcoPolo | (for [x (range 10) ] |
| 13:56 | MarcoPolo | (do (println "Evaling" x) |
| 13:56 | MarcoPolo | [x]))] |
| 13:56 | MarcoPolo | (first x)) |
| 13:56 | lazybot | java.lang.RuntimeException: EOF while reading, starting at line 1 |
| 13:56 | MarcoPolo | ,(let [x (for [x (range 10) ] (do (println "Evaling" x) [x]))] (first x)) |
| 13:56 | clojurebot | Evaling 0\nEvaling 1\nEvaling 2\nEvaling 3\nEvaling 4\nEvaling 5\nEvaling 6\nEvaling 7\nEvaling 8\nEvaling 9\n[0] |
| 13:58 | MarcoPolo | So my understanding of for was that it returned a lazy seq, so when I do first I expect it to just run enough code to give me 0 (in the example), why is it running the code for 1-9? |
| 13:59 | dnolen_ | MarcoPolo: putting side effects into lazy seqs is generally a bad idea. |
| 13:59 | dnolen_ | MarcoPolo: and you'll run into issues because of chunking |
| 13:59 | clojurebot | I don't understand. |
| 13:59 | beaky | hello |
| 14:00 | dnolen_ | unless you stop using range and use something like (take 10 (iterate inc 0)), or wrap range in something that forces actual one by one evaluation |
| 14:01 | pl6306 | How do I and a number of entries into a map? I think it is probably apply assoc any one have simple example? |
| 14:02 | dnolen_ | pl6306: into |
| 14:03 | pl6306 | thanks |
| 14:05 | MarcoPolo | @dnolen_ I just have the side effect in there to see when it is being evaluated, and what do you mean by chunking? |
| 14:05 | dnolen_ | ,(into {} [[:foo 1] [:bar 2]) |
| 14:05 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 14:05 | MarcoPolo | Doesn't range return a lazy seq as well? |
| 14:05 | MarcoPolo | ,(type (range 10)) |
| 14:05 | clojurebot | clojure.lang.LazySeq |
| 14:05 | dnolen_ | MarcoPolo: it's lazy when/how it evaluates is a mostly implementation detail if your code is pure. |
| 14:06 | dnolen_ | MarcoPolo: as an optimization some types returns chunked sequences when seq'ed to reduce allocation/step overhead |
| 14:07 | MarcoPolo | dnolen: Okay, that makes sense. Thanks |
| 14:07 | MarcoPolo | ,(let [x (for [x (take 10 (iterate inc 0)) ] (do (println "Evaling" x) [x]))] (first x)) |
| 14:07 | clojurebot | Evaling 0\n[0] |
| 14:07 | MarcoPolo | yup :) |
| 14:08 | goza | hi everyone, is there a way of replacing specific elements of a tree (as nested seqs)? I've tried using clojure.walk, but I'm not sure how to use it with the nesting. |
| 14:10 | MarcoPolo | goza: This might be what you are looking for: http://clojuredocs.org/clojure_core/clojure.core/update-in |
| 14:10 | MarcoPolo | goza: or if you don't want an update function and just replace a value you can use assoc-in http://clojuredocs.org/clojure_core/clojure.core/assoc-in |
| 14:11 | goza | MarcoPolo: thanks, I'll look into it. |
| 14:12 | goza | MarcoPolo: ok, so is it recommended to represent the trees with maps instead of seqs? |
| 14:13 | gdev | ,(doseq [even [2 4 6] odd [3 5 7]] (print (- odd even))) |
| 14:13 | clojurebot | 135-113-3-11 |
| 14:14 | asteve | ,(= 1 nil) |
| 14:14 | clojurebot | false |
| 14:14 | asteve | ,(= 1 'nil) |
| 14:14 | clojurebot | false |
| 14:14 | asteve | hah |
| 14:15 | gdev | ,(doseq [even [2 4 6] odd [3 5 7]] (print (- even odd))) |
| 14:15 | clojurebot | -1-3-51-1-331-1 |
| 14:15 | gdev | ,(doseq [even [2 4 6] odd [3 5 7]] (print (* even odd))) |
| 14:15 | clojurebot | 61014122028183042 |
| 14:15 | gdev | ,(doseq [even [2 4 6] odd [3 5 7]] (prn (* even odd))) |
| 14:15 | clojurebot | 6\n10\n14\n12\n20\n28\n18\n30\n42\n |
| 14:17 | MarcoPolo | goza: I feel like it's easier to use when you use maps, but it depends on what you are using the tree for |
| 14:18 | goza | MarcoPolo: ok, cool. When should I use other structures? |
| 14:30 | gdev | so in emacs i evaluate a doseq and it just returns nil instead of printing out the values |
| 14:30 | gdev | ,(doseq [x [1 2 3] (prn x)) |
| 14:30 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 14:30 | gdev | ,(doseq [x [1 2 3]] (prn x)) |
| 14:30 | clojurebot | 1\n2\n3\n |
| 14:33 | gdev | nvmnd, it was printing out in the nrepl buffer instead of the message buffer |
| 14:35 | gdev | prn prints to the nrepl buffer and everything else prints to the message buffer |
| 14:36 | rlb | what's a reasonable choice these days for xml manipulation -- say I need to read an xml document, make some modifications, and write it back out? |
| 14:36 | chronno | gdev: the message buffer gets the result of the form you evaluate |
| 14:37 | chronno | gdev: hence the nil of the doseq |
| 14:37 | MarcoPolo | goza: I'm still relatively new at this, so anyone else feel free to correct me. I use vectors where I would usually want an array is most other languages, but I write code to work with seqs so it won't matter if it is a vector or list (or lazyseq). hashmaps ar helpful when you want to represent attributes of something or most trees. I think it actually uses trees on the backend |
| 14:37 | rlb | (I've used data.zip a bit in the past, but didn't know if that was still a good choice.) |
| 14:39 | gdev | chronno:) yeah, I just realized that the doc for doseq says it returns nil thanks |
| 14:41 | justin_smith | gdev: also, prn returns nil |
| 15:02 | gdev | if you evaluate an sexpression in emacs with C-x C-e and the message buffer just sits there saying "C-x C-e" that means that the evaluation is still taking place? |
| 15:03 | nDuff | gdev: Typically, yes. |
| 15:04 | gdev | nDuff:) thanks, does it time out if it takes too long? I just realized this expression updates 18 thousands rows in the database |
| 15:05 | gdev | 18 thousand I meant, not 18 1000s |
| 15:05 | nDuff | gdev: No, but you should be able to interrupt it yourself. Unfortunately, I don't remember the keybindings offhand. |
| 15:06 | gdev | nDuff:) she doesn't seem to be responding to C-x g |
| 15:07 | gdev | or C-g rather |
| 15:07 | justin_smith | C-c C-c should send an interrupt iirc |
| 15:07 | justin_smith | but not kill the shell, just stop the current calculation |
| 15:08 | gdev | justin_smith:) thanks, now "C-c C-c" is hanging out in my buffer, how long does it take to kill it? |
| 15:08 | justin_smith | lol |
| 15:08 | justin_smith | no idea |
| 15:08 | howdynihao | hi guys regarding lazy sequences, i have a question about how take-nth or take-last work |
| 15:08 | justin_smith | it could be trying to roll back now |
| 15:08 | howdynihao | does clojure actually compute every item in the sequence when it's "skipping" ? |
| 15:09 | howdynihao | for instance (take-nth 10 (range 100)) does it actually compute 1,2,3,4,5,6,7,8,9 ? |
| 15:10 | gdev | justin_smith:) okay, well C-x C-c seems to have done the trick |
| 15:10 | justin_smith | that's one way to do it |
| 15:13 | justin_smith | howdynihao: different lazy seqs obey different rules, some know how to jump straight to an element without computing the previous. range would pretty much be guaranteed to be one of them |
| 15:15 | justin_smith | for example iterate needs to do all the calculations at least once, and is also a lazy seq, but map only needs to know the value of the inputs at that index to get the value for the ouput at that index |
| 15:16 | justin_smith | so if the inputs to map can jump to an index, map can too |
| 15:16 | dnolen | justin_smith: howdynihao: range doesn't work that way as far as I know, nor any of the seqs operations that I'm aware of. |
| 15:17 | justin_smith | doesn't work which way? |
| 15:18 | dnolen | justin_smith: there is no "skipping", take will seq it's argument and it must step through each element of the seq, chunking allows some seqs to move 32 elements at time, but you still have to go through everything. |
| 15:18 | justin_smith | ok, good to know |
| 15:19 | justin_smith | yeah, based on (time (last (range x))) it really is generating all the intermidiaries, which surprises me greatly |
| 15:19 | dnolen | howdynihao: but note take-nth is lazy so it won't actually compute 1-9, until it needs to |
| 15:20 | howdynihao | right ok |
| 15:20 | howdynihao | i was curious if it had some magical / cool implementation for 'skipping' |
| 15:29 | lynaghk | ping: seancorfield |
| 16:02 | danneu | if you don't need to share state across threads (independent computations), are you back to just doing Java Thread dispatches? |
| 16:03 | gdev | quick code review: (doseq [row results] (update table (set-fields {:total (+ (rand-int 100) (:subtotal row))}) (where {:dept [= 1 10]}) (where {:prod_id (:prod_id row)})))) |
| 16:04 | gdev | that's a pretty complex statement but I think it does good enough row mapping |
| 16:04 | danneu | gdev: prob be easier to post the gist link |
| 16:04 | gdev | danneu:) good call, thanks |
| 16:07 | danneu | gdev: i personally like to separate the computations from the function i'm actually trying to write |
| 16:08 | danneu | i.e. i'd use `let` |
| 16:08 | danneu | (let [total (+ (rand-int 100) (:subtotal row))] ...) |
| 16:13 | danneu | and yeah i know you were prob looking for some higher level help, but that's all ive got |
| 16:13 | tieTYT2 | maybe one of you swing experts could help me with this: http://stackoverflow.com/questions/16229526/how-do-you-remove-the-ctrlc-action-on-a-jfilechooser |
| 16:16 | jcromartie | whenever I do "C-u 8 0 ;" I know it's time to make a new namespace |
| 16:20 | gdev | heres my gist for the code above https://gist.github.com/gdeer81/c9d3ea6d4db3036aa2d5 |
| 16:25 | gdev | why is that gist not showing up, wtf github |
| 16:33 | gdev | okay, since gist is being funny, here is my code in pastebin http://pastebin.com/9HLZUD5t |
| 16:34 | Raynes | refheap.com |
| 16:34 | kencausey | Lighttable on Win7/64bit: I try to eval-in-editor a defn and I get "ich number35 nz- octagon Odinodin Okasu OlegYch omaciel omarkj â arohner |
| 16:34 | kencausey | | ordnungswidrig oriig Orva othiym23 owengalenjones OwenOu ozataman ozzloy pandeiro pendlepants pepijndevos PeregrinePDX pinupgeek pisketti pjstadig pl6306 pmaes ppppaul prip prismatictrail â arrdem |
| 16:35 | kencausey | | prof-freud przl pyrtsa pyykkis qfrstory quackv4 quuxman qz racycle raek rafl Ragnor rahcola rasmusto ravster Raynes Raynos rboyd rbranson rbxbx rcarey3 rcg rcj_ rdd redinger reeses reiddraper â AsgardBSD_ |
| 16:35 | kencausey | | reikalus2kka rfgpfeiffer rikur rippy rkneufeld rlb rlr rmarianski rmrfchik robear robink rocco`` rodnaph rotty rowth rpg rplaca russfrank ryanf S11001001 saiam saint_cypher samrat___ saolsen â Ash |
| 16:35 | kencausey | | sattvik saurik scalabl3 scgilardi scode Scorchin scottj seancorfield seangrove SegFaultAX septomin serpent213 sethalves Sgeo shadower Shambles_ SHODAN si14 Sigma silven simcop2387 sjl Sonderblade â astrax |
| 16:35 | kencausey | | sorenmacbeth spjt spligak srcerer sritchie ssedano ssideris st3fan stain stask strax sturner sundbp synfinatic TakeV tali713 tbaldrid_ tboyt tcrawley|away tcrayford technomancy telex terjesb terom â atman |
| 16:35 | kencausey | | TEttinger2 tfnico___ the-kenny TheBusby TheMoonMaster thorguy__ tieTYT tieTYT2 TimMc tippenein tmarble toast tobyp tofflos tolsen tomaw tomku tomoj tos9 ToxicFrog tpope trinary TristamWrk Trystam â atyz |
| 16:35 | Raynes | That;s awesine, |
| 16:35 | kencausey | | Tuna-Fish tvaalen twem2 txdv tyler_ ucb ujihisa vickaita vsayer walter warpy wastrel wdouglas weavejester wei_ whee whilo whoahbot Wild_Cat Wild_Cat` wilfredh wilk wink wolanski wookiehangover â augustl |
| 16:35 | kencausey | | wormphlegm worrelsik wyan xeqi Xorlev xybre yacin yacks Yamazaki1kun yason yastero yazirian yedi yogthos ystael zaargy zaiste zakwilson zaphar_ps zeekay zenoli zerokarmaleft ziman zodiak â averell |
| 16:35 | dakrone | whoa |
| 16:35 | kencausey | | zz_Inoperable] â AWizzArd_ |
| 16:35 | Raynes | That's awesome. |
| 16:35 | kencausey | 15:31:40 -- | Channel #clojure: 608 nicks (1 ops, 0 halfops, 0 voices, 607 normals) â azkane |
| 16:35 | rbranson | wtf |
| 16:35 | technomancy | ops? |
| 16:35 | kencausey | Did any of that go through? Sorry |
| 16:35 | Raynes | I dunno how you managed to just print everything. |
| 16:35 | omaciel | oy |
| 16:35 | technomancy | chouser: ^ |
| 16:35 | rbranson | PRINT ALL THE THINGS |
| 16:35 | Raynes | technomancy: He didn't do it on purpose. |
| 16:35 | technomancy | Raynes: doesn't mean he shouldn't be briefly banned |
| 16:35 | TheMoonMaster | Good job. |
| 16:36 | omaciel | :) |
| 16:36 | arohner | we enforce the death penalty for all crimes here |
| 16:36 | gdev | wow that woke everyone up |
| 16:36 | synfinatic | on the plus side I didn't realize there was someone here with the nick wookiehangover |
| 16:36 | russfrank | awww. |
| 16:36 | wei_ | hi everyone |
| 16:37 | TheMoonMaster | lol |
| 16:37 | gdev | Raynes:) https://www.refheap.com/paste/13989 is that better? |
| 16:39 | wei_ | which has better performance, or are they the same? (first (rsubseq m <= 1)) or (last (subseq m <= 1)) |
| 16:39 | gdev | didn't realize refheap doesn't do line wrapping, grr |
| 16:40 | justin_smith | gdev: http://pastebin.com/UfZ5Jxtc version with formatting and destructuring |
| 16:40 | justin_smith | nothing big |
| 16:42 | gdev | justin_smith:) thanks, it looks a lot nicer, will it perform better? lemme run it and see |
| 16:42 | justin_smith | I dunno, destructuring may perform a little better than inline accesses, but that is just speculation |
| 16:43 | arrdem | when is it idiomatic to use (load)? I'm just looking at how clojure.pprint used to (load) in code to keep the main pprint file small. |
| 16:43 | amalloy | arrdem: "never" is close enough |
| 16:44 | arrdem | amalloy: somehow I figured that was gonna be the answer... |
| 16:45 | arrdem | meh I can imagine a ns layout where I don't need to (ab)use load. use case destroyed. |
| 16:45 | gfredericks | what if pre/post conditions could have metadata with an error message? |
| 16:45 | Bronsa | gfredericks: eh, I often wished they could have |
| 16:46 | gfredericks | I wonder if the core folks would approve of that |
| 16:59 | tieTYT2 | does Bodil Stokke hang out here? |
| 17:00 | tieTYT2 | ah, probably :) |
| 17:00 | tieTYT2 | this language looks like a great idea: https://github.com/bodil/BODOL |
| 17:01 | arrdem | what the... utf8 chars for fn application and lambda declarations? |
| 17:03 | trinary | "If you're discouraged by the curious absence of λ and ƒ on your keyboard, you can substitute Clojure's fn and defn or Common Lisp's lambda and defun respectively." :) |
| 17:04 | tieTYT2 | arrdem: it's optional |
| 17:04 | tieTYT2 | I think it'd give a better first impression if it used fn/defn (or something like that) instead of the function and lambda symbols |
| 17:05 | dnolen | CLJS ObjMap vs. PersistentArrayMap perf update http://dev.clojure.org/jira/browse/CLJS-499 |
| 17:05 | Bronsa | or use emacs and M-x toggle-input-method and write \lambda :) |
| 17:05 | arrdem | Bronsa: or just have pretty-lambda installed :p |
| 17:05 | Bronsa | heh |
| 17:06 | Bodil | tieTYT2: It's been known to happen. :) |
| 17:07 | Bodil | And yeah, I feel the world's pretty much ready for non-ASCII character sets by now. :) |
| 17:07 | tieTYT2 | as an american, I don't even want to go metric yet |
| 17:09 | Bodil | But yeah, it's optional - sadly, keyboards aren |
| 17:09 | Bodil | aren't quite there yet. :( |
| 17:09 | tieTYT2 | yeah |
| 17:09 | yogthos | just have to wait for BCI I guess :P |
| 17:13 | tieTYT2 | Bodil: From the tests and the front page, I don't see any examples of static typing |
| 17:13 | tieTYT2 | but the intro says: Clojure is great, but sometimes I miss static typing. |
| 17:14 | Bodil | tieTYT2: No, it's not implemented yet. I'd say I'm planning to do it over the weekend, but I doubt it's a two day job. :) |
| 17:14 | yogthos | tieTYT2: https://github.com/frenchy64/typed-clojure |
| 17:14 | tieTYT2 | yogthos: did you mean to link me to https://github.com/clojure/core.typed ? |
| 17:15 | yogthos | tieTYT2: indeed :) |
| 17:15 | tieTYT2 | k i'll watch this video |
| 17:19 | nathanic | howdy all, does anyone happen to know of a lib that can parse XML into hiccup-like structures? it looks like clojure.data.xml can go from hiccup-style vector trees to XML (sexp-as-element), but I can't seem to convince it to go the other direction. it just wants to serialize into its own much more lazy tree format. |
| 17:20 | nathanic | s/lazy/verbose/ |
| 17:24 | arrdem | any suggestions for cleaning up this file or would you say it's good as is? https://github.com/arrdem/pascal/blob/master/src/me/arrdem/compiler/symbols.clj |
| 17:25 | arrdem | (199 LoC, mostly (derfrecord) forms) |
| 17:26 | justin_smith | it would be easier on the eyes if you added :as compiler to the :require statement rather than using the full namespace on every reference to it |
| 17:27 | arrdem | justin_smith: oh. herp derp good one. |
| 17:35 | gdev | justin_smith:) so that version of the query takes around 20 minutes |
| 17:35 | justin_smith | as compared to? |
| 17:36 | gdev | compared to nothing, i didn't benchmark the other one since i figured it would be slower |
| 17:37 | gdev | I also realized i didn't need to do two where clauses, since the prod_id was unique identifier for each row |
| 17:37 | justin_smith | code layout can help with things like that |
| 17:38 | gdev | indeed =) |
| 17:41 | ppppaul | i layout my code like a fruit basket |
| 17:45 | doriantje- | I layout my code like spaghetti ._. |
| 17:45 | ppppaul | i love spaghetties |
| 17:45 | justin_smith | with namespacing you can at least aspire to ravioli layout |
| 17:46 | gdev | so I'm not sure if I just need to break the update query out into multiple calls to the database or if I just have my app play some relaxing music while the user waits 20 minutes |
| 17:46 | doriantje- | My code is a poor man's pasta. |
| 17:50 | ppppaul | mock pasts? |
| 17:50 | ppppaul | mock pasta* |
| 17:54 | ppppaul | anyone here experimented with simulant? |
| 17:54 | Okasu | Guys, can you give me a link for awesome talk from one guy whos ancesotor was a convict and was sent to australia? |
| 17:55 | Okasu | I can't remember name of that guy. |
| 17:56 | jorgeu | bad clojure joke: how can you tell if someone is a clojure dev? ......... it doesn't matter he will tell you! |
| 17:56 | arrdem | I suppose there is that... |
| 17:56 | justin_smith | if you work backend, how do you pretend you are a java dev? |
| 17:57 | justin_smith | don't say anything, they will assume you are |
| 17:57 | jorgeu | yup |
| 17:57 | jorgeu | I have seen that trend |
| 18:01 | justin_smith | "backend lisp developer? are you joking? that exists?" |
| 18:02 | ozzloy | https://www.refheap.com/paste/13991 the repl works for simple things, but i'd like to get rid of that error |
| 18:02 | Apage43 | try frontend lisp developer |
| 18:02 | ozzloy | the internet doesn't show much for it |
| 18:03 | arrdem | Apage43: but clojurescript is almost a thing so.. |
| 18:03 | ozzloy | line 15 |
| 18:03 | ppppaul | jorgeu, please, no more jokes |
| 18:03 | Apage43 | ozzloy: your project.clj in that folder probably specified a :main or :repl {:init …} |
| 18:04 | ozzloy | Apage43, this is from the clojure koans |
| 18:04 | justin_smith | ozzloy: does this happen when you use lein new and open a repl there, or only in the clojure koans? |
| 18:04 | ozzloy | i'll see |
| 18:05 | ozzloy | https://www.refheap.com/paste/13992 doesn't happen in a new project |
| 18:09 | abp | ozzloy: Update leiningen. |
| 18:09 | ozzloy | abp, ok |
| 18:13 | ozzloy | https://www.refheap.com/paste/13993 now it looks worse |
| 18:14 | ozzloy | oh the repl appears to work though |
| 18:14 | ozzloy | do i have to do lein project update or something inside clojure-koans? |
| 18:14 | justin_smith | this probably has to do with that wacky thing the koans do where they reload files if you edit them and show you the next koan |
| 18:15 | ozzloy | oh i have the test runner runnign |
| 18:15 | ozzloy | i should kill that maybe. i'll try that and see what happens |
| 18:15 | justin_smith | there is a "lein upgrade" command |
| 18:16 | ozzloy | https://www.refheap.com/paste/13994 |
| 18:17 | ozzloy | justin_smith, i did that already |
| 18:17 | ozzloy | justin_smith, upgraded lein |
| 18:19 | justin_smith | I don't know if the koan run thing would interfere with a repl, but I think the koan project is set up so running lein against it's project.clj will mess up unless you are using the lein koan plugin |
| 18:19 | justin_smith | that is what I meant by "probably has to do with that wacky thing the koans do" |
| 18:19 | ozzloy | i just tried creating a new project and a repl in there since i've updated lein and that worked |
| 18:19 | ozzloy | i'll just use a repl in a different project |
| 18:19 | ozzloy | kinda wonky |
| 18:19 | ozzloy | but the koans are pretty self contained |
| 18:21 | ozzloy | thanks abp justin_smith and Apage43 |
| 18:44 | seancorfield | lynaghk: you pinged me a few hours ago? sorry, was at lunch... |
| 19:09 | gdev | so i just looked at the oracle trace file and my application has a 1 to 1 mapping of sql statements to database records |
| 19:11 | gdev | justin_smith:) yea I don't think I picked the right solution for this one |
| 19:14 | justin_smith | gdev: yeah, data modeling is not a simple thing, and the design can have huge consequences |
| 19:34 | Sgeo | Someone pinged me |
| 19:34 | Sgeo | Are there public logs? |
| 19:34 | ivan | it was a spammer |
| 19:34 | Sgeo | Oh |
| 19:35 | ivan | http://clojure-log.n01se.net/date/2013-04-26.html |
| 19:35 | trinary | I think it was a mis-copy-paste actually :) |
| 19:35 | Sgeo | Shouldn't public logs be in topic? |
| 19:36 | ivan | trinary: no honest man would use an IRC client without paste detection ;) |
| 19:36 | trinary | harsh! |
| 19:36 | justin_smith | I have had erc do that before |
| 19:37 | justin_smith | worst thing, is when it is pasting back the contents of the same buffer, you cannot tell it has happened, because the buffer looks the same |
| 19:38 | ivan | yeah, I'm sure I would leak all of my secrets within a couple hours of ERCing |
| 19:39 | howdynihao | how can i get [1 2 3] [1 2 3] to be [ [1 1] [1 2] [1 3] [2 1] ... ] |
| 19:39 | howdynihao | well actually, how do i put that into words |
| 19:39 | howdynihao | technical term |
| 19:39 | gfredericks | cartesian product? |
| 19:40 | gfredericks | ,(let [as [1 2 3] bs [:c :d :e]] (for [a as, b bs] [a b])) |
| 19:40 | clojurebot | ([1 :c] [1 :d] [1 :e] [2 :c] [2 :d] ...) |
| 19:40 | gfredericks | if you have just two sequences, that'll work. If the number varies, I think there's a contrib library with combinatorics functions |
| 19:40 | gfredericks | also you could write your own and it's lots of fun |
| 19:41 | gfredericks | (fn cp [& colls] (if (empty? colls) [[]] (for [x (first colls), xs (cp (rest colls))] (cons x xs)))) |
| 19:42 | gfredericks | that doesn't work and I don't know why and I'm going to make tacos |
| 19:42 | howdynihao | yum tacos |
| 19:42 | trinary | hah |
| 19:44 | gfredericks | oh I forgot an apply I think |
| 19:45 | technomancy | apply tacos |
| 19:45 | justin_smith | yeah, that or you can change cp to take a single arg |
| 19:45 | Bronsa | gfredericks: math.combinatorics |
| 19:47 | gfredericks | [org.clojure/math.tacos "0.1.0"] |
| 19:48 | Bronsa | tacos everywhere |
| 19:49 | justin_smith | (map (comp eat taco) [:asada :pollo :barbacoa]) |
| 19:52 | justin_smith | throw a (juxt identity identity) in there and double your tacos |
| 21:21 | lynaghk | Is it worth trying to do things like ETag/not-modified in my ring/compojure app, or would it be easier to throw nginx in front of it? |
| 21:24 | benkay | i have a tiny helper function in my codebase, and given that functions should be readily passable, I would like to pass this function into a transaction to be run on my transactor in Datomic. wat do? |
| 21:24 | gfredericks | benkay: you have to install it on the transactor |
| 21:25 | gfredericks | you can't "pass" it since the transactor isn't in the same process as your normal code |
| 21:25 | benkay | you speak to the problem exactly, gfredericks. so, implementation would be to include function in schema? |
| 21:26 | gfredericks | there's a special mechanism for installing functions |
| 21:26 | gfredericks | I'm not sure about the details |
| 21:27 | corpsan | gfredericks: I am pairing with benkay right now |
| 21:27 | gfredericks | it's in the docs somewherehttp://docs.datomic.com/database-functions.html |
| 21:28 | corpsan | is that mechanism the standard run-a-transaction-with { :db/id (d/tempid :db.part/user) :db/ident :my-function :db/fn … } |
| 21:29 | gfredericks | yeah that looks right |
| 21:29 | corpsan | okay. so i'm a little scared of storing code in my database. sounds like recommended solution is "don't use little helper functions inside transactor. give transactor everything it needs to do what it needs to do" |
| 21:30 | gfredericks | yeah if you can get away with that it's certainly simpler |
| 21:30 | corpsan | well, i don't want to store code that might change any time |
| 21:30 | gfredericks | sure |
| 21:30 | corpsan | in this case the helper function is operating on a brittle data structure |
| 21:30 | benkay | yeah and i r no trust migrations and schema change |
| 21:33 | corpsan | thanks gfredericks! |
| 21:33 | gfredericks | np |
| 23:48 | echo-area | http://pastebin.com/wnuZKRyA |
| 23:48 | echo-area | Hi. |
| 23:49 | echo-area | I see the clojure program takes more than ten times than the corresponding Java program. |
| 23:49 | echo-area | In the disassembled code, the only difference is some more load/save code in every iteration of the clojure program. |
| 23:50 | echo-area | And I see there are more minor pagefaults in the clojure run. |
| 23:50 | echo-area | Can I explain the longer execution time with this? |
| 23:53 | echo-area | Sorry, I meant the only added code was a `pop'. |
| 23:54 | andyfingerhut | A "Hello, world" program in Java takes about 0.2 sec to finish on my machine, whereas in Clojure about 1.1 sec. |
| 23:54 | ivan | I hear you should use criterium for microbenchmarks like that |
| 23:54 | echo-area | andyfingerhut: That's because of the initialization of RT |
| 23:55 | andyfingerhut | Are you not measuring the time taken for a JVM to start, run your code, and then exit? |
| 23:55 | tomoj | how do we get ['lam (nom/tie c ['lam (nom/tie d ['var c])])] from '(lam [c] (lam [d] c)) ? |
| 23:55 | echo-area | andyfingerhut: But I measured the actual two iterations, not the whole program |
| 23:56 | andyfingerhut | I don't see that in your paste anywhere. I saw "time" being used at a shell prompt. |
| 23:56 | echo-area | That's only for seeing pagefaults |
| 23:56 | echo-area | (time (p1)) |
| 23:56 | echo-area | That is. |
| 23:56 | tomoj | there's a pretty obvious non-relational way where you walk through the data and keep a map of symbols to fresh noms, but how can we do it relationally? |