2013-03-24
| 01:06 | chessguy | anybody awake? i'm pretty new to clojure, trying to get a silly data structure working. i'm sure it's way easier than i'm making it.. |
| 01:07 | arrdem | go for it.. |
| 01:07 | arrdem | no rest for the wicked.. or those designing the impossible XP |
| 01:07 | chessguy | https://gist.github.com/arwagner/5230640 |
| 01:07 | chessguy | i'm pretty sure it can be done in about 5 lines. i'm getting a null reference exception right now |
| 01:10 | arrdem | chessguy: sorry it's past my bedtime and I have the attention span of a squirrel on meth. gimme a minute here. |
| 01:10 | chessguy | arrdem: no worries, i know it's terrible code |
| 01:11 | arrdem | chessguy: it actually isn' |
| 01:11 | arrdem | t bad... just not something there's really a reason to do. hang on. |
| 01:11 | arrdem | new emacs instance.. |
| 01:11 | arrdem | nrepl... |
| 01:11 | arrdem | and code. |
| 01:11 | arrdem | okay. |
| 01:13 | arrdem | first thing.. I would write similar (map key) as similar (key map) |
| 01:13 | arrdem | that way it's a little less confusing with clojure.core/map |
| 01:13 | arrdem | but that's correct so it's not your error. |
| 01:14 | chessguy | hm, ok. i know that a lot of functions that operate on collections take the collection as the first argument |
| 01:14 | chessguy | so i was trying to follow that |
| 01:14 | chessguy | but i see your point |
| 01:14 | arrdem | I mean.... |
| 01:14 | arrdem | ,(extends? IFn {}) |
| 01:14 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: IFn in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 01:14 | arrdem | goddamnit clojurebot. |
| 01:14 | arrdem | anyway {} is a function... |
| 01:14 | chessguy | yes |
| 01:15 | chessguy | and so are its keys |
| 01:15 | tbaldridge | ,(ifn? {}) |
| 01:15 | clojurebot | true |
| 01:15 | arrdem | (inc tbaldridge) |
| 01:15 | lazybot | ⇒ 2 |
| 01:15 | tbaldridge | (fn? {}) |
| 01:15 | tbaldridge | ,(fn? {}) |
| 01:15 | clojurebot | false |
| 01:15 | chessguy | ,(ifn? :foo) |
| 01:15 | clojurebot | true |
| 01:15 | chessguy | ,(fn? :foo) |
| 01:15 | clojurebot | false |
| 01:16 | tbaldridge | fn? is only true for clojure functions, trivia fact. |
| 01:16 | tbaldridge | ,(fn? #()) |
| 01:16 | clojurebot | true |
| 01:16 | chessguy | makes sense |
| 01:17 | tbaldridge | yeah, but it'll trip you up sometimes, so use ifn? most of the time. :-) |
| 01:18 | chessguy | so, arrdem, you were saying there's no reason to do this? |
| 01:19 | arrdem | chessguy: I mean it's a cute exercise in the language.. but we have {} as you clearly know |
| 01:19 | chessguy | yes... |
| 01:19 | arrdem | I'm legitimately curious why it's wrong. |
| 01:19 | chessguy | this is more than {}... |
| 01:20 | chessguy | it's a partition |
| 01:20 | bbloom | every time i try to use a zipper, i find them to be more trouble than their worth :-/ |
| 01:20 | chessguy | bbloom: i kinda feel that way too. played with them for a long time in haskell |
| 01:20 | bbloom | s/their/they're/ |
| 01:24 | chessguy | am i missing something obvious? |
| 01:24 | arrdem | chessguy: not that I'm seeing off the bat |
| 01:24 | chessguy | arrdem: i mean in both the approach and the execution |
| 01:26 | arrdem | chessguy: so the approach seems fine... |
| 01:26 | arrdem | trying to debug (contains?) plz hold |
| 01:27 | chessguy | oh i found it |
| 01:27 | chessguy | (keys {}) is nil... |
| 01:28 | chessguy | i was expecting it to be an empty vector |
| 01:28 | arrdem | oh that'd do it. |
| 01:29 | arrdem | ,(contains? nil true) |
| 01:29 | clojurebot | false |
| 01:29 | arrdem | no... |
| 01:30 | chessguy | (vec (keys {})) |
| 01:30 | chessguy | ,(vec (keys {})) |
| 01:30 | clojurebot | [] |
| 01:30 | arrdem | OH |
| 01:31 | arrdem | namespace. |
| 01:31 | chessguy | hm? |
| 01:31 | clojurebot | benchmarking is https://github.com/hugoduncan/criterium |
| 01:31 | arrdem | you define contains? and then expect it to operate recursively. |
| 01:31 | chessguy | oh geez |
| 01:31 | arrdem | you need to specify clojure.core/contains? on line 15 in contains? |
| 01:31 | chessguy | yeah |
| 01:31 | arrdem | ololol that was a cute bug |
| 01:32 | chessguy | yeah, that fixes it |
| 01:33 | arrdem | chessguy: it'd be interesting if you could adapt this to take N partition functions and allow for the nesting case cleanly |
| 01:33 | chessguy | arrdem: nesting case? |
| 01:34 | chessguy | arrdem: like, make a tree out of it? |
| 01:34 | arrdem | yep! |
| 01:34 | chessguy | would be easy to define a BST i suppose |
| 01:35 | arrdem | so the first level uses function F, second G, third H and soforth. |
| 01:35 | arrdem | which are not nessicaraly equivalent. |
| 01:35 | chessguy | hm, this still isn't quite right. |
| 01:35 | arrdem | not sure if it'd be usefull, but it'd be cute. a hashing with bucket implemetation as it were. |
| 01:36 | chessguy | arrdem: i feel like there has to be a more idiomatic way... |
| 01:38 | arrdem | working on a -> based version for my own entertainment.. |
| 01:38 | chessguy | arrdem: there's a bit in this. if you pass in two items that hash to the same key, it fails |
| 01:39 | chessguy | s/bit/bug/ |
| 01:39 | chessguy | man i'm tired... |
| 01:44 | arrdem | chessguy: a simpler contains-any-like? would just be (map ((:hash-function map) item)) |
| 01:44 | arrdem | because if true it'll be the sub-map and if false it'll be nil |
| 01:44 | arrdem | and anything but nil I believe is truthy |
| 01:44 | chessguy | that makes my head hurt... |
| 01:44 | chessguy | i really need to rename that field |
| 01:45 | arrdem | or just use .map.. |
| 01:45 | chessguy | hm? |
| 01:45 | clojurebot | benchmarking is https://github.com/hugoduncan/criterium |
| 01:45 | chessguy | shutup, clojurebot |
| 01:45 | arrdem | ,(doc defrecord) |
| 01:45 | clojurebot | "([name [& fields] & opts+specs]); Alpha - subject to change (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args*] body)* Dynamically generates compiled bytecode for class with the given name, in a package with the same name as the curr... |
| 01:45 | arrdem | yeah cool. |
| 01:46 | arrdem | so your Hashtable compiles to a java class. |
| 01:46 | arrdem | therefore you can use (.map instance) |
| 01:46 | arrdem | as well as (:map instance) |
| 01:46 | arrdem | and (. instance map) |
| 01:46 | chessguy | oh |
| 01:46 | chessguy | meh. i just renamed it to data |
| 01:47 | chessguy | still can't figure out why a second item with the same hash is overwriting instead of conj'ing |
| 01:48 | arrdem | ,(conj #{:foo} :bar) |
| 01:48 | clojurebot | #{:foo :bar} |
| 01:48 | arrdem | ,(conj nil :bar) |
| 01:48 | clojurebot | (:bar) |
| 01:48 | arrdem | ,(set (conj nil :bar)) |
| 01:48 | clojurebot | #{:bar} |
| 01:49 | chessguy | that could replace my if statement, i suppose |
| 01:50 | arrdem | yep that's the idea |
| 01:50 | chessguy | still doesn't work... |
| 01:51 | chessguy | here's the latest version: https://gist.github.com/arwagner/5230640 |
| 01:52 | chessguy | oh, i've still got some :map's in there |
| 01:52 | chessguy | now it works |
| 01:54 | arrdem | I b0rked mine -_- |
| 01:55 | chessguy | ok, it's really time for bed now... |
| 01:56 | chessguy | thanks! |
| 01:59 | arohner | in typed clojure, how do I "get rid of" a (U nil)? |
| 02:00 | arohner | nvm, user error |
| 02:22 | Raynes | arohner: The exception was between the chair and the keyboard? |
| 02:22 | arohner | Raynes: yes |
| 02:22 | Raynes | :p |
| 02:22 | arrdem | darn IO exceptions get me every time |
| 02:22 | arohner | though I also gave up, because the type for datomic.api/q is a bitch |
| 02:23 | arohner | I couldn't convince typed that (q '[:find ?e .. :where [?e ...]]) always returns a long |
| 02:25 | arohner | hrm, though if I sleep on it, I can probably make that happen |
| 02:25 | arohner | hrm, nvm, dealing with :in is going to be a problem |
| 02:41 | Raynes | arrdem: ImADamnedIdiotException |
| 02:42 | arrdem | Raynes: InsufficientCoffeeException |
| 02:43 | Raynes | arrdem: That's genius! |
| 02:44 | arrdem | so I'm working on a math library for rationals, irrationals, (Double is close enough to real) Irrationals, symbols and values with errors. |
| 02:45 | arrdem | is it cheating to allow arithmatic operations to return "expressions" when they cannot be exactly computed due to types or the presence of symbols? |
| 02:55 | paddymahoney | so, when symbols are present, you probably want to return a lambda with those symbols bound? is that correct? |
| 02:55 | arrdem | paddymahoney: when I go to eval with binding yes... but I would like to keep it all symbolic for as long as possible. |
| 02:57 | tomoj | in pedestal, how do you deal with :input events? |
| 02:57 | Raynes | You use compojure. |
| 02:57 | Raynes | ~rimshot |
| 02:57 | clojurebot | Badum, *tish* |
| 02:57 | paddymahoney | I see, so you probably need a function (free-vars symbolic-exp) => (listof symbol) |
| 02:58 | paddymahoney | and then a wrap function...(wrap symbolic-body vars) => lambda vars symbolic-body |
| 02:59 | muhoo | TimMc: thanks! |
| 02:59 | Raynes | Not totally sure what you're trying to do. |
| 03:00 | arrdem | herm... should my eval take a bindings form or assume that all vals are def'd in the current namespace? |
| 03:00 | arrdem | s/vals/symbols |
| 03:00 | Raynes | Oh, I thought he was asking a question, not you. |
| 03:03 | paddymahoney | arrdem: I would have one that takes a symbolic expression tree, and one that takes bindings, and then write the first in terms of the second after reconstructing a full abstract binding tree. |
| 03:04 | danneu | Raynes: i'm learning a lot reading your laser lib's source. it's easy to understand |
| 03:04 | arrdem | paddymahoney: herm I guess that'd work. |
| 03:04 | Raynes | Really? Nice. That's some of the most complicated stuff I've written. Give yourself a solid pat on the back, sir. |
| 03:04 | arrdem | lemme finish the quick demo I'm working on and see what you think. |
| 03:04 | paddymahoney | I'm interested! :) |
| 03:05 | arrdem | paddymahoney: fair warning the second system effect is in full swing as is sleep deprivation. |
| 03:08 | arrdem | (* a (/ b c)) == (/ (* a b) c), yes? |
| 03:10 | Raynes | danneu: Simple and easy to understand was a goal, so I'm happy to hear that at least one person thinks I may have succeeded. |
| 03:11 | Raynes | Not that people think I haven't succeeded. You're just the first person to comment on the code. ;) |
| 03:11 | Raynes | Except for amalloy, but he complains in general. |
| 03:13 | paddymahoney | arrdem: I don't think that is true. |
| 03:13 | amalloy | haven't read the backlog, but i'm sure Raynes has said something wrong recently |
| 03:13 | Raynes | lol |
| 03:17 | arrdem | paddymahoney: no that has to be true because it gives == (* a b (/ 1 c)) which _is_ true. |
| 03:17 | paddymahoney | ah I was confused. a*(b/c) == (a*b)/c. |
| 03:18 | paddymahoney | paddymahoney is sad his is. |
| 03:19 | paddymahoney | my prefix to infix parser is broken :( |
| 03:45 | arrdem | *bed |
| 03:54 | MikeSeth | hmmm |
| 04:01 | MikeSeth | I have [:a :b :c] and a function [e p] where p is some value derived from e's position in the vector, what's the idiomatic way to loop over a list/vector extracting a value and its position? |
| 04:04 | arrdem | ,(group-by #(= (first %1) 3) (vector [1 2 3 5 4 6 7 8 3] (range 9)) |
| 04:04 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 04:04 | arrdem | ,(group-by #(= (first %1) 3) (vector [1 2 3 5 4 6 7 8 3] (range 9))) |
| 04:04 | clojurebot | {false [[1 2 3 5 4 ...] (0 1 2 3 4 ...)]} |
| 04:05 | arrdem | (vector [1 2 3 5 4 6 7 8 3] (range 9)) |
| 04:05 | arrdem | ,(vector [1 2 3 5 4 6 7 8 3] (range 9)) |
| 04:05 | clojurebot | [[1 2 3 5 4 ...] (0 1 2 3 4 ...)] |
| 04:05 | arrdem | ,(map vector [1 2 3 5 4 6 7 8 3] (range 9)) |
| 04:05 | clojurebot | ([1 0] [2 1] [3 2] [5 3] [4 4] ...) |
| 04:05 | arrdem | ,(group-by #(= (first %1) 3) (map vector [1 2 3 5 4 6 7 8 3] (range 9))) |
| 04:05 | clojurebot | {false [[1 0] [2 1] [5 3] [4 4] [6 5] ...], true [[3 2] [3 8]]} |
| 04:05 | MikeSeth | aha |
| 04:05 | arrdem | hah. gross and not lazy but that's one way. |
| 04:05 | SegFaultAX | Ugh, no. |
| 04:06 | arrdem | SegFaultAX: fix my shit. have fun :D |
| 04:06 | SegFaultAX | yogthos: I have to say I didn't like that list video you posted on proggit. |
| 04:06 | SegFaultAX | yogthos: I thought the speaker was awful. :/ |
| 04:07 | SegFaultAX | MikeSeth: What are you really trying to do? |
| 04:08 | MikeSeth | SegFaultAX: terminal emulator has method to the effect of [x y str] |
| 04:08 | MikeSeth | there's no way to move cursor relatively etc |
| 04:08 | MikeSeth | so I have a list of strings each corresponding to a vertical screen position |
| 04:09 | SegFaultAX | MikeSeth: Ok, so what's the problem? |
| 04:10 | Raynes | SegFaultAX: Paul ingles? |
| 04:10 | Raynes | Ingles, even |
| 04:10 | SegFaultAX | Raynes: Yea. |
| 04:10 | Raynes | Why don't you like him? |
| 04:10 | SegFaultAX | It's not him I don't like. The talk is terrible. |
| 04:11 | SegFaultAX | He spends the first 35 minutes haphazardly pasting a half dozen other talks and books together, without giving justice to any of them or the concepts therein. |
| 04:11 | Raynes | I see. |
| 04:11 | Raynes | I haven't actually seen the talk. |
| 04:12 | Raynes | I emailed Paul once so he is one of my closest friends and stuff. |
| 04:12 | SegFaultAX | Basically building up to, at about the 5 minutes left mark, saying "you should use Datomic" and then finally talking about how they used it at uSwitch or whatever. |
| 04:12 | Raynes | Or something. |
| 04:12 | SegFaultAX | Or something. |
| 04:17 | SegFaultAX | MikeSeth: Still looking for help? |
| 04:53 | danneu | Raynes: are you there? |
| 04:56 | Raynes | danneu: Yes. |
| 04:58 | danneu | Raynes: can laser.core/and be rewritten with every-pred: https://gist.github.com/danneu/d2177a9ca4be8d1190be |
| 04:58 | danneu | i found every-pred when looking in stdlib when i was trying to do the same thing |
| 04:59 | danneu | well ive gotta drive home. cya |
| 05:02 | Raynes | For those watching: the answer is yes, and I commented as such. |
| 05:46 | rocco | is there anyone here who'd be willing to answer a question I have? |
| 05:50 | ivan | rocco: you picked the worst freenode time but maybe |
| 05:50 | ivan | (always just ask) |
| 05:50 | rocco | I'll keep that in mind for the future |
| 05:50 | rocco | I'd just like to know how instances of java classes are disposed when I run them in the repl |
| 05:51 | rocco | do I need to dispose them? |
| 05:51 | ivan | nope, the JVM's GC will kick in and garbage-collect them (unless they're still in your *1 *2 *3 REPL vars) |
| 05:51 | rocco | I don't like the idea of leaving garbage behind me so I'd just like to clarify for myself what happens |
| 05:52 | rocco | in the repl vars or otherwise referenced, right? |
| 05:52 | ivan | all you have to do is not leave any references to things you want garbage-collected |
| 05:52 | ivan | yes |
| 05:52 | rocco | ok |
| 05:53 | rocco | I worry about this when I create gui windows and such |
| 05:53 | rocco | I wonder what happens when I close them |
| 05:53 | rocco | but those are classes like any other really |
| 05:54 | ivan | these libraries generally do not have massive leaks, but if you want to make sure, you can attach jvisualvm to your process, trigger a GC, and look at how many instances there are of certain objects |
| 05:55 | rocco | I see |
| 05:55 | rocco | very useful |
| 05:55 | rocco | can you suggest other tools off the top of your head? I'm looking to equip my programmer shed :) |
| 05:56 | ivan | for memory leaks in particular? |
| 05:58 | rocco | I meant in regards to clojure in general but that may be too much.. |
| 05:59 | ivan | recently I learned of java -XX:+PrintFlagsFinal and -XX:+PrintCompilation, those can be useful |
| 05:59 | ivan | https://gist.github.com/rednaxelafx/1165804 scroll down to know what the JVM spends all its time doing |
| 06:01 | ivan | but clojure instead of jvm? you probably already know nrepl.el |
| 06:03 | rocco | actually I didn't |
| 06:03 | ivan | see also http://www.clojure-doc.org/ and Joy of Clojure |
| 06:03 | rocco | I was playing with emacs environ some time back |
| 06:03 | rocco | now I'm looking to start experimenting again with clojure |
| 06:05 | rocco | I've read some joy of clojure |
| 06:05 | rocco | haven't finished it yet |
| 06:06 | rocco | what I read was great |
| 06:07 | rocco | so which is the preferred site currently - clojuredocs or clojure-doc |
| 06:07 | rocco | I'm trying to get a feeling for what has changed while I wasn't paying attention |
| 06:08 | ivan | clojuredocs is mostly abandoned and stuck on 1.3 |
| 06:10 | rocco | good to know |
| 06:12 | ivan | it still has a lot of useful examples that have not been migrated yet |
| 06:13 | arkx | Migrated where? Does clojure-doc.org have API reference section somewhere? |
| 06:14 | ivan | I thought there was a plan to have one but now I read "CDS is not concerned with providing the API reference" https://github.com/clojuredocs/cds |
| 06:14 | arkx | Yeah. :| |
| 06:23 | modulus | Hi there. A couple of questions if anyone's around and wakeful. |
| 06:24 | modulus | i do (require 'clojure.set) (intersection #{} #{}) and the symbol intersection seems not to be defined, any clues why? |
| 06:24 | modulus | the require statement gives me a nice nil, no errors. |
| 06:25 | AimHere | clojure.set/intersection should work |
| 06:25 | modulus | oh damn, i tried clojure.set.intersection but of course it's a / |
| 06:25 | modulus | thanks |
| 07:06 | lpetit | hello |
| 07:07 | fractastical | Can anyone give me advice on frameworks to use for creating a REST API ? |
| 07:07 | fractastical | I've looked at a few tutorials and also discovered liberator |
| 07:07 | fractastical | sometimes hard to see how much certain libraries are being maintained |
| 09:44 | navgeet | Is there any way to get the environment in a function, not like it's available as &env in a macro. |
| 10:41 | edw | I'm tryinh to get nrepl's javadoc support working. Anyone know how to get the javadoc middleware installed? Is it a dev dependency in my project.clj file? A lein plugin? |
| 10:52 | ravster | question about liberator: do the post!, put!, get!, etc. actions only get called if its a POST, PUT, GET, etc request? |
| 10:53 | ravster | well, maybe not get!, but delete! ? |
| 11:06 | technomancy | edw: iirc it's part of ritz |
| 11:07 | edw | Ah. Don't feel like drinking that bowl of Kool-Aid just right now. |
| 11:11 | hugod | edw: should be as simple as the config shown in https://github.com/pallet/ritz/tree/develop/nrepl-middleware#usage |
| 11:12 | ravster | using undocumented apis is always so much fun. *sigh* |
| 11:13 | edw | Ah! Thanks, Hugo. I thought I was going to get sucked completely into Ritz. I'm always trying to limit the number of moving parts in anything I'm doing. |
| 11:23 | gfredericks | ha; clojure.org/special_forms suggests docstrings should be 1-3 lines |
| 11:24 | hyPiRion | gfredericks: But they can be very long. |
| 11:25 | gfredericks | the lines you mean? :) |
| 11:25 | hyPiRion | yeah :) |
| 11:25 | gfredericks | good ole clojure |
| 11:26 | edw | OK, so C-c C-j is working but it's opening a browser window with a search string containing "+javadoc"; any ideas? |
| 11:36 | edw | Ah. I was under the impression that doing a C-c C-j with point over e.g. "Integer/parseInt" would do some magic and map that to java.lang.Integer. |
| 11:37 | edw | A project for another weekend. |
| 13:03 | zakwilson | It seems like it might be of use for Korma to make itself aware of what columns are in a table and select-keys those from the map it's given for an insert/update. |
| 13:39 | chessguy | 'afternoon ya'all |
| 13:39 | satch5150 | hi all - I have a problem, not sure if its the right place, but the problem revolved around clojure, so here goes, when I start an nrepl via eclipse, it runs on an ipv6 address (according to netstat) and so therefore attempts to connect to it from lein via console (outside eclipse) fails |
| 13:41 | satch5150 | I am not to up on ipv6 and I tried to connect via a ipv6 version of the localhost ip, but still fails |
| 13:41 | satch5150 | anyway, what can I do ? |
| 13:43 | satch5150 | anyone ? |
| 13:44 | zakwilson | This is probably the right place to ask the question, but the channel is slow this time of day. Be patient, and someone might answer in a couple hours. |
| 13:44 | satch5150 | thanks |
| 14:05 | tomoj | satch5150: hmm the lein changelog for 2.0.0-preview10 says "Make repl listen on 127.0.0.1 instead of localhost to address IPv6 issues." |
| 14:10 | satch5150 | tomoj: I just turned off ipv6 on my linux machine, nrepl now listening on ipv4, but I still get a connection refused |
| 14:11 | satch5150 | using this to try to connect: lein repl :connect nrepl://localhost:43509 |
| 14:15 | satch5150 | I don't think i'm having firewall issues, iptables reveals no rules, everything set to accept, and I don't 'think' selinux is installed |
| 14:15 | satch5150 | or activated I mean |
| 14:17 | satch5150 | indeed, selinux is disabled |
| 14:17 | satch5150 | what else could be causing this |
| 14:17 | satch5150 | ? |
| 14:20 | MikeSeth | SegFaultAX: sorry for bailing earlier |
| 14:21 | satch5150 | just to recap: I am unable to connect to a nrepl that was started by eclipse using: lein repl :connect nrepl://localhost:43509 - the nrepl is listening on ipv4 now |
| 14:23 | satch5150 | I get a connection refused error, followed the names of java classes with line numbers where they all had trouble |
| 14:28 | MikeSeth | satch5150: can you connect with telnet? |
| 14:28 | satch5150 | not even sure I have a telnet client :) - I'll see though |
| 14:29 | MikeSeth | satch5150: try a browser with http://... |
| 14:30 | satch5150 | telnet connected |
| 14:31 | MikeSeth | satch5150: try lein repl 43509 |
| 14:31 | MikeSeth | w/o hostname |
| 14:31 | MikeSeth | er, lein repl connect 43509 |
| 14:31 | MikeSeth | er, lein repl :connect 43509 |
| 14:32 | satch5150 | MikeSeth: that seems to work :) |
| 14:32 | MikeSeth | satch5150: I dont think you're supposed to give it an URI |
| 14:33 | satch5150 | MikeSeth: I am happy I have it working, but for arguments sake, what if I wanted to connect to a remote server ? |
| 14:33 | MikeSeth | satch5150: host:port |
| 14:33 | MikeSeth | no nrepl:// prefix |
| 14:33 | satch5150 | ah, I see |
| 14:34 | satch5150 | thanks again :) |
| 14:34 | MikeSeth | welcome |
| 14:38 | horseshoe | hi, oss.sonatype.org appears to be down and hence lein deps doesn't work, are there any workarounds ? |
| 14:53 | borkdude | why exactly doesn't have app-handler (wrap-resource "public") and war-handler does in noir.util.middleware? |
| 15:03 | mstang_ | hello |
| 15:03 | mstang_ | I have a kind of conceptual question |
| 15:05 | mstang_ | I have a bunch of functions that all need a "session", so I keep passing it in, what is the recommended way to make a kind of "global" value available all th way down into functions |
| 15:06 | borkdude | mstang_ probably an atom or a ref |
| 15:06 | borkdude | mstang_ unless you mean a browser session |
| 15:07 | borkdude | mstang_ or you can pass all the "global" data from one function to the other as a parameter |
| 15:07 | mstang_ | no, I am "wrapping" a third-party library and they make a connection to a server |
| 15:08 | mstang_ | something similar to a jdbc connection |
| 15:09 | mstang_ | borkdude I am concerned with limiting the library to a single "session" at a time |
| 15:11 | borkdude | mstang_ in clojure.jdbc a dynamic var *db* is used for that and any database operations can be done with with-open |
| 15:11 | borkdude | mstang_ this way, the user of your library has to keep arround the session/connection himself and just feed it to with-open |
| 15:13 | mstang_ | borkdude OK, I saw something similar with another SQL library |
| 15:13 | borkdude | mstang_ are you from NL btw? (your name sounds dutch) |
| 15:14 | mstang_ | borkdude maybe a long time ago, via Germany, family immigrated from Germany, came with the name |
| 15:14 | borkdude | ah |
| 15:15 | mstang_ | borkdude not sure where they got it ;-) |
| 15:16 | mstang_ | bordkdude always wondered, found it meant "bar"... |
| 15:18 | borkdude | mstang_ correct |
| 15:19 | mstang_ | borkdude "steel bar" "tavern bar"? |
| 15:19 | borkdude | mstang_ more like the bar in "behind bars" |
| 15:19 | borkdude | mstang_ so steel |
| 15:24 | borkdude | yogthos|away I see in luminus that (route/resources "/") is added to app-routes but war-handler also adds a wrap-resource… how do they relate? |
| 15:27 | mstang_ | borkdude what if I don't want to close the "session" but leave it open, or maybe I want to have a "session" pool |
| 15:29 | modulus | so say i have lists l1 and l2 and i want to make them into a hash map. is the most reasonable way to go about this (reduce conj (map hash-map l1 l2))? |
| 15:29 | borkdude | modulus probably zipmap |
| 15:30 | borkdude | mstang_ I don't know. maybe keep them around in an atom or smth? |
| 15:30 | modulus | oh lol, that seems exactly what i need. |
| 15:30 | mstang_ | borkdude smth? |
| 15:30 | borkdude | mstang_ something |
| 15:30 | mstang_ | borkdude lol |
| 15:31 | a|i | there is so much inconsistancy in clojure emacs docs. |
| 15:31 | a|i | is this out od date? http://clojure-doc.org/articles/tutorials/emacs.html |
| 15:32 | a|i | does this work? https://github.com/overtone/emacs-live/tree/master/packs/live/clojure-pack/lib/clojure-mode |
| 15:32 | a|i | and what's this one? https://github.com/jochu/clojure-mode |
| 15:33 | jjttjj | that second one was updated 2 months ago so i would assume it does work? |
| 15:33 | jjttjj | |
| 15:33 | jjttjj | and that third one says it's deprecated right at the top |
| 15:33 | a|i | jjttjj: the 2nd one doesn't work. |
| 15:33 | jjttjj | ah |
| 15:34 | a|i | al I wanna do is to open up a repl and evalue a file in it. |
| 15:35 | mstang_ | a|i nrepl |
| 15:36 | a|i | mstang_: in emacs? |
| 15:37 | mstang_ | a|i yes, it is on github, when installed into emacs, a control-c control-k will evaluate a buffer in nrepl |
| 15:38 | mstang_ | a|i https://gist.github.com/rkneufeld/5126926 |
| 15:39 | mstang_ | a|i nrepl runs inside emacs |
| 15:39 | a|i | mstang_: how is this different to emacs-live? I thought emacs-live bundles all the useful clojure stuff in emacs. |
| 15:40 | mstang_ | a|i sorry, don't know anything about emacs-live, the url I sent was from a Clojure West Conference talk |
| 15:41 | a|i | mstang_: thanks, I'll have a look into this now. |
| 15:41 | zackzackzack | Any ideas why leiningen might be hanging when I try to run the tests or repl? |
| 15:41 | mstang_ | a|i last week, so I know it is current, nrepl gets you Clojure access, the rest is "just" learning emacs editing |
| 15:43 | zackzackzack | Oh. I see why it's hanging now. It's not. The jvm is starting up. Somehow drip got disabled. Odd. |
| 15:47 | a|i | mstang_: how is nrepl-jack-in connected to a specific project.clj? |
| 15:49 | mstang_ | a|i not really, it starts a repl running and then you can "send" stuff to the repl to be evaluated, for instance from the end of an sexp you can control-x control-e and it will evaluate it |
| 15:49 | a|i | mstang_: then why does it say: 'Open an nREPL session. Intelligently loads project context if launched from any file within a Leiningen project.' |
| 15:50 | mstang_ | a|i ah, my guess is if you do it from within a project, not my style of development... |
| 15:50 | mstang_ | a|i however, let me try... |
| 15:54 | mstang_ | a|i not sure if it did anything when I executed nrepl-jack-in |
| 15:54 | a|i | mstang_: did you try C-c M-j or M-x nrepl-jack-in ? |
| 15:55 | mstang_ | a|j M-x nrepl-jack-in |
| 15:55 | a|i | mstang_: I did that with having a file open. but it doesn't connect to the repl. |
| 15:55 | a|i | C-c C-e doesn't output in repl. |
| 15:56 | mstang_ | a|i no, in the status at the bottom |
| 15:56 | mstang_ | a|i messages |
| 15:56 | a|i | what's the pint of opening a repl then? |
| 15:56 | a|i | point* |
| 15:57 | mstang_ | a|i well, if you open the messages buffer you can see it run |
| 15:58 | a|i | mstang_: ok, but what's th epoint of openning a repl? |
| 15:58 | mstang_ | a|i C-c C-k to load the buffer |
| 15:58 | a|i | mstang_: C-c C-k outputs in status line, not repl. |
| 15:59 | a|i | mstang_: the repl namespace doesn't change from user, is that normal? |
| 15:59 | mstang_ | a|i C-c M-n to switch the namespace |
| 15:59 | mstang_ | a|i yes it is normal |
| 16:01 | a|i | mstang_: does C-c C-k evaluate in repl and only output in the status line? |
| 16:02 | mstang_ | a|i yes, you can switch to the nrepl and input commands there at the prompt, or you can "send" from your .clj buffer and have nrepl evaluate it |
| 16:03 | mstang_ | a|i nrepl is a running session, so you can edit and load from emacs, or you can switch to the *nrepl* buffer and type commands directly into the repl, but that is hard to edit |
| 16:15 | noprompt | Raynes: you around? |
| 16:15 | Raynes | noprompt: Theoretically. |
| 16:16 | noprompt | Raynes: how did you get started with emacs? i'd like to give it another shot but i'm a hardcore vimmer. |
| 16:17 | Raynes | Well, I didn't come to Emacs from Vim so I don't have any big secrets for success there. |
| 16:18 | noprompt | oh haha, for some reason i thought you used vim before. |
| 16:18 | Raynes | It's been so long I don't even remember following any tutorials or anything. Chances are I just googled things as I went, grabbed a cheatsheet... |
| 16:18 | Raynes | I did. |
| 16:18 | Raynes | I went from Emacs to Vim for a couple of months and then back to Emacs with evil-mode because I liked Vim but was sadpanda that I didn't have Emac's extensibility and plugins. |
| 16:19 | arrdem | Raynes: lol yeah I found your blog post ranting about not having elisp around a few days ago. |
| 16:19 | borkdude | yogthos|away I tried either compojure.route/resources and wrap-resource from ring with some file in public and they seem to work independently, so I'm kind of confused why they are both here |
| 16:20 | noprompt | alrighty. i got evil-mode going. guess i'll just have to suck it up and figure out the rest. :) |
| 16:20 | Raynes | noprompt: You've got to be willing to take a productivity hit for a week or two while you learn. |
| 16:21 | arrdem | noprompt: that and I recommend trying emacs sans evil-mode before you use evil. |
| 16:21 | Raynes | You're going to be much slower until you get some muscle memory developed for stuff that evil-mode doesn't cover, but for the most part everything is googleable. |
| 16:21 | chessguy | don't suppose anyone's interested in doing a little pair programming. i'm playing around a little with a tiny rules engine, for fun and to help me learn clojure |
| 16:21 | Raynes | I'm not sure where I stand on evil-vs-no-evil. |
| 16:22 | arrdem | Raynes: it's a personality thing. |
| 16:22 | arrdem | I can handle key chords and was using them in vim before I started emacs-ing |
| 16:22 | Raynes | I have no information one way or the other (for I did not conduct studies) saying that people are more likely to learn Emacs with or without starting with evil-mode, since I started using it while I already knew Emacs. |
| 16:22 | noprompt | Raynes: yeah, i was aware there'd be a performance hit. i'll take the advice though and drop evil-mode for now. |
| 16:23 | noprompt | btw, how's that starter kit? |
| 16:23 | Raynes | In that case, you should drop to about 3 MPH for a while. |
| 16:23 | arrdem | noprompt: supposedly it's good but haven't tried it. |
| 16:23 | Raynes | evil-mode would have given you about 5MPH. ;P |
| 16:23 | noprompt | Raynes: that's what it was like when i first started learning vim. |
| 16:23 | Raynes | But I'm quite satisfied with your confidence, sir. |
| 16:24 | Raynes | I've used bits and pieces of the starter kit, and generally trust technomancy to not mess up Emacs stuff. |
| 16:24 | Raynes | *shrug* |
| 16:24 | Raynes | There is also emacs-live, but it looks horrible. |
| 16:25 | arrdem | it's abandonware and you'll have to patch a line but the sublime package is a nice wrapper over some stuff... |
| 16:25 | arrdem | give's you control-c and control-p to copy/paste to system clipboard |
| 16:25 | arrdem | among other things. |
| 16:25 | Raynes | Wait, you guys don't use OS X? |
| 16:26 | Raynes | I didn't realize there were people left that didn't. |
| 16:26 | arrdem | I'm running Arch Linux on all my boxes. |
| 16:26 | Raynes | You poor thing. |
| 16:26 | arrdem | lol |
| 16:26 | arrdem | !dice |
| 16:26 | arrdem | hum... |
| 16:26 | arrdem | ~dice |
| 16:26 | clojurebot | Huh? |
| 16:26 | Raynes | $dice maybe? :( |
| 16:26 | noprompt | i use os x. |
| 16:27 | Raynes | noprompt: Then if you use Emacs from homebrew or emacsformacosx.com you'll yet cmd+c and cmd+p for copying and pasting out of the box. |
| 16:27 | tbaldridge | Raynes: there were waaay more Linux users at Clojure/West than at the Conj |
| 16:27 | noprompt | the thing that kills me is the meta key. |
| 16:28 | noprompt | i had to remap capslock to meta. |
| 16:28 | tbaldridge | Conj was about 10% mac. Clojure/West was about 30-40% |
| 16:28 | Raynes | wat |
| 16:28 | arrdem | TBH I'm working on a Samsung Series 9 atm... so mod the fact that I'm running a minimal xwindows compositor basically means that I'm as close to a mac as I can get without buying one. |
| 16:28 | Raynes | noprompt: Remap capslock to control, dude. |
| 16:29 | noprompt | i would be my muscle memory for control is pretty there already. |
| 16:29 | noprompt | fwiw, i actually tried to remap caps lock to control |
| 16:29 | Raynes | I used to be really adamant about not changing ctrls location. |
| 16:29 | Raynes | But then work sent me a laptop with it pre-swapped for control and I was too lazy to change it. |
| 16:29 | Raynes | Never looked back. |
| 16:31 | noprompt | i'm planning to get a type matrix pretty soon so the problem may not be a real issue http://typematrix.com/ |
| 16:32 | noprompt | been wanting to get my hands on one for a while now |
| 16:35 | arohner | tbaldridge: I would have guessed C/W was 70% mac |
| 16:35 | noprompt | Raynes: do you use the gui version of emacs or terminal? |
| 16:35 | Raynes | noprompt: GUI, for this isn't 1995. |
| 16:36 | noprompt | lmfao |
| 16:36 | arrdem | despite being the resident Arch pants on head retard I also use the gui |
| 16:36 | arrdem | and why would you buy that... get a gaming mechanical and remap it. |
| 16:37 | noprompt | the typematrix? |
| 16:37 | noprompt | because i like the layout |
| 16:37 | Raynes | I use a das. |
| 16:37 | noprompt | i'd like to get a data hand but that's like 1K$ |
| 16:37 | Raynes | People at work come by to watch me type. Some bring popcorn. |
| 16:38 | noprompt | Raynes: the best thing about the das is that punchy sound. |
| 16:38 | Raynes | They have recorded albums of my das instrumentals. |
| 16:39 | noprompt | gives a new meaning to the phrase "keyboard solo" |
| 16:40 | arrdem | haha |
| 16:40 | noprompt | Raynes: you should do a serious recording, and put a picture of yourself on the album cover dressed up as bach |
| 16:40 | Raynes | lol |
| 16:41 | scottj | noprompt: seen truly ergonomic? I've used typematrix and te and prefer te. (though I prefer choc mini to both) |
| 16:42 | scottj | btw remapping capslock to control AND escape is nice |
| 16:43 | noprompt | scottj: the te looks interesting. it has the vertical layout i like. |
| 16:44 | noprompt | the placement of : and / might kill me a little |
| 16:45 | noprompt | scottj: what's nice about the choc mini? looks pretty standard to me. |
| 16:46 | scottj | noprompt: yeah I like standard :) relatively short spacebar and pgup/pgdn are close. and fns directly above and lined up with # keys. |
| 16:46 | arrdem | thanks for mentioning the TE, that looks cool! |
| 16:47 | scottj | noprompt: the change of placement on TE is VERY annoying |
| 16:47 | arrdem | abet a significant shift in key layour. |
| 16:47 | arrdem | *layout |
| 16:47 | noprompt | what would really be awesome if there was keyboard which let you physically reconfigure the keyboard some how |
| 16:47 | noprompt | instead of doing it via software |
| 16:48 | scottj | http://stevelosh.com/blog/2012/10/a-modern-space-cadet/ is where I got the capslock=control and escape idea, xcape is what I use on linux |
| 16:48 | noprompt | you move a key to a different location but it still sends the original signal |
| 16:48 | scottj | noprompt: I think kinesis advantage supports that, at least on the thumb keys |
| 16:48 | arrdem | noprompt: there are a few of those... |
| 16:48 | arrdem | or at least I saw one years ago. |
| 16:48 | noprompt | really? |
| 16:48 | noprompt | oh man i would love that |
| 16:48 | arrdem | yeah all the keys were done in software so the board was fully reconfigurable. |
| 16:49 | arrdem | it was pretty wacky. |
| 16:50 | arrdem | noprompt: http://www.ergodex.com/mainpage.htm |
| 16:51 | noprompt | whoa. that's wild. |
| 16:51 | technomancy | Raynes: am I too late to make a D&D joke on your "not sure where you stand on evil" comment? |
| 16:51 | arrdem | and it's at least a four year old product too... |
| 16:52 | Raynes | technomancy: Never. |
| 16:53 | technomancy | Raynes: you should get your alignment checked |
| 16:53 | noprompt | technomancy: nice |
| 16:53 | Raynes | Dun dun dun |
| 16:58 | noprompt | arrdem: have you seen the wads keyboard? |
| 16:58 | noprompt | or rather, heard anything good about them? |
| 16:58 | arrdem | noprompt: neg |
| 16:58 | arrdem | oh this isn't mwo. nil. |
| 17:00 | noprompt | spell check ruined that, wasd |
| 17:02 | arrdem | noprompt: good grief that's an overkill mech keyboard |
| 17:02 | arrdem | change the font of your keycaps ffs... |
| 17:02 | arrdem | *you can |
| 17:02 | Raynes | I want a wingding keyboard. |
| 17:02 | noprompt | hehe, yeah a bit over the top, eh? |
| 17:03 | noprompt | Raynes: comic sans? |
| 17:09 | borkdude | lpetit is "load file in REPL" in ccw supposed to spawn a repl, without me having to press "Run"? |
| 17:09 | lpetit | borkdude: yes |
| 17:12 | borkdude | lpetit and if I want to close a repl because I want to start a fresh one, which view/window do I kill? console, repl, both? |
| 17:13 | lpetit | borkdude: you close the repl, this will also close the associated console |
| 17:13 | borkdude | lpetit I updated to the newest ccw and "load file in REPL" doesn't start a repl, also the closing doesn't work as you described |
| 17:14 | lpetit | borkdude: that's an unfortunate regression. |
| 17:16 | borkdude | lpetit I just upgraded from 0.12.1 to 0.12.2 to see if that was the problem, no luck. Eclipse version : 4.2.2.M20blabla |
| 17:17 | lpetit | borkdude: will not have time to look at it right now, already fighting with a regression in Leiningen 2.1.1 API. Can you please file an issue, I'll fix it in 0.12.3 later this week. |
| 17:19 | borkdude | lpetit ok |
| 17:19 | lpetit | borkdude: thx |
| 17:19 | noprompt | scottj: did you say you can remap caps lock to both esc and cntrl? |
| 17:19 | scottj | noprompt: yep |
| 17:19 | noprompt | how? |
| 17:19 | clojurebot | with style and grace |
| 17:19 | scottj | noprompt: what os? |
| 17:20 | technomancy | clojurebot: botsnack |
| 17:20 | noprompt | os x |
| 17:20 | clojurebot | Thanks! Can I have chocolate next time |
| 17:20 | scottj | $google steve losh cadet keyboard |
| 17:20 | scottj | noprompt: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/ |
| 17:22 | borkdude | lpetit hmm, it might be that my project is somehow broken. it works in another project in the same workspace |
| 17:22 | lpetit | borkdude: try to "Leiningen > Reset project" |
| 17:22 | noprompt | scottj: thanks |
| 17:37 | borkdude | Raynes what is the common way to test code that normally uses the stateful sessions from lib-noir? |
| 17:38 | Raynes | Psh, like I test my websites. |
| 17:38 | borkdude | Raynes I remember in noir there was something like with-noir … blabla |
| 17:38 | Raynes | borkdude: You can use binding to bind the unbound variable things. There might be something in lib-noir. yogthos would know more. |
| 17:39 | yogthos | moi? :) |
| 17:40 | yogthos | I don't think there's anything special for testing stateful sessions, using binding would probably be the easiest |
| 17:41 | borkdude | Raynes ah yes, binding |
| 17:41 | xeqi | borkdude: you could use my kerodon library if you want to test the full routes |
| 17:41 | borkdude | xeqi I will look at that… sounds interesting |
| 17:42 | technomancy | kerodon is cool |
| 17:43 | yogthos | very fancy :) |
| 17:44 | borkdude | (binding [noir.session/*noir-session* (atom {})] works |
| 17:45 | borkdude | kerodon looks very interesting though. :-) |
| 17:45 | xeqi | just depends on the level you want to test at |
| 17:46 | yogthos | borkdude: with-redefs can be handy too |
| 17:46 | yogthos | if you have something that goes to db for example, you could redef it with something that spits out some test data |
| 17:53 | borkdude | yogthos yeah, that's very handy. |
| 17:57 | noprompt | scottj: oh man, this is definitely an improvement |
| 17:57 | noprompt | i think i can start learning emacs now |
| 17:59 | borkdude | gnight |
| 18:03 | pellis | hello |
| 18:10 | pellis | I'm wondering if anyone is doing async IO with clojure |
| 18:12 | ravster | is liberator known to fiddle with ring-session? |
| 18:14 | brehaut | pellis: https://github.com/ztellman/aleph |
| 18:14 | amalloy | i would have linked to lamina rather than aleph, but it's all the same i suppose |
| 18:15 | brehaut | pellis: if you mean 'are people in clojure writing callback soups', the not so much |
| 18:15 | brehaut | oh true. sorry |
| 18:16 | pellis | hm, not sure I prefer callback soup. |
| 18:16 | pellis | perhaps it is best if I give some context |
| 18:17 | pellis | u have a clojure (compojure) based API that i've build for processing articles (article = text + images). it will then classify the article into one of several groups |
| 18:18 | pellis | so a workflow would be: 1. download HTML (IO), 2. do text processing (CPU) 3. download images (IO), 4. process images via external tools (IO), 5. merge everything (CPU) |
| 18:19 | brehaut | pellis: so you want background workers? |
| 18:19 | pellis | well not so much. everything works well right now - i'm using maps and pmaps and clojure is very nice to me |
| 18:19 | pellis | the API was designed for server-to-server communication, so the traffic isn't really web-scale |
| 18:20 | pellis | right now I have a critical requirement, to push it towards "web scale" by letting users directly hit this API |
| 18:21 | pellis | in this case, I'm not sure I can waste so much resources on about threads where there's so much IO around |
| 18:21 | pellis | so my knee-jerk reaction was to start implementing everything in an evented framework. node.js and event machine came up, I picked node.js |
| 18:22 | pellis | but now I'm pretty much sad about 2 things. 1 - this takes me away from clojure 2 - I have java algorithms I have to port to javascript (yuck) |
| 18:22 | brehaut | well, pmap frinstance is capped at available processors + 2 |
| 18:23 | pellis | so my next reaction - wrap all the Java stuff with Clojure and Netty and offer the functionality for my (now new) node.js service via some kind of RPC |
| 18:23 | pellis | all this kind of made me realize that if there's a convenient async framework for clojure, i could implement network IO and such within clojure itself |
| 18:26 | technomancy | pellis: sounds like a job for message queues |
| 18:26 | pellis | technomancy, though, i didn't mentioned this all should be real time |
| 18:26 | technomancy | oh, ok |
| 18:26 | pellis | or, at least synchronous (client hangs and waits for answer) |
| 18:27 | pellis | right now it takes around 0.7s for a call and there's a lot to improve (premature optimization) |
| 18:29 | pellis | so basically i'm stuck with finding a way to call Java code through node.js or find an evented framework for clojure |
| 18:34 | amalloy | pellis: that'd be aleph/lamina for sure. nothing else in clojure comes close for evented networking |
| 18:34 | zakwilson | It seems to me that futures might provide a good alternative to event-based techniques to get good responsiveness from that sort of application in Clojure. |
| 18:34 | pellis | great, so I'll be sure to check lamina out |
| 18:47 | Scruffy | Hello. |
| 18:48 | zakwilson | It's my impression that futures use a thread pool and work queues such that resource consumption at "web scale" wouldn't really be a problem relative to an event-driven style. In any case, it would be trivial to test relative to rewriting code for an event framework. |
| 18:50 | rhickeybot | killuminati |
| 18:51 | pellis | zakwilson, isn't futures just a form of delayed execution? |
| 18:52 | zakwilson | pellis: no. Futures begin work as soon as there's a thread available (note: this may not be a completely accurate representation of their implementation from a technical perspective). |
| 18:55 | zakwilson | In fact, pmap is pretty much just (map deref (map (future (f a-seq)))) |
| 18:56 | pellis | zakwilson, thats interesting.. ill have to read about it |
| 18:57 | zakwilson | pellis: Most of the workflow you're describing above is sequential though, so I'm not sure how much gain there's going to be with either events or futures. |
| 18:58 | pellis | zakwilson, well, i'm running several algorithms on the same data, and then merging their result. these can run in parallel |
| 18:59 | zakwilson | If you have code that looks like (let [x (do-io-bound-thing) y (do-cpu-bound-thing-not-dependant-on-x)] (do-stuff-with-x-and-y)), you can parallelize it trivially with (let [x (future (do-io-bound-thing)) y (future (do-cpu-bound-thing-not-dependant-on-x))] (do-stuff-with @x @y)) |
| 18:59 | pellis | and I figured letting the OS handle the IO in the case of evented, will be better than blocked out threads |
| 19:00 | zakwilson | And if you have CPU-bound things that aren't already parallel, you can parallelize them the same way. |
| 19:01 | zakwilson | It might well be better, but if you have an easy way to load-test it, you can try futures trivially. Unrelated: I'm doing text classification in Clojure too. |
| 19:05 | pellis | zakwilson, yup, i'll keep that in mind |
| 19:07 | zakwilson | And I have an HTTP API or two, and it involves fetching data over the web, and it has (a small number of) users, and it uses futures to do that. I don't know that it's the best way to do things, but I know it's *a* way. |
| 19:09 | pellis | yep, i'll have to give it a go at least. either that or i'll wrap the actual algorithm with an RPC and call it from node.js |
| 19:25 | number35 | hi all |
| 19:25 | number35 | i would like to know if its possible to interleave two sequences with using only map and reduce |
| 19:28 | zakwilson | I'm pretty sure it's not. |
| 19:32 | dnolen | ,(reduce concat (map vector [1 2 3] ["one" "two" "three"])) |
| 19:32 | clojurebot | (1 "one" 2 "two" 3 ...) |
| 19:32 | dnolen | ##(reduce concat (map vector [1 2 3] ["one" "two" "three"])) |
| 19:32 | dnolen | number35: ^ |
| 19:33 | rplaca | number35: you can do it with mapcat by itself |
| 19:33 | rplaca | ##(mapcat #(vector %1 %2) [:a :b :c] [1 2 3]) |
| 19:33 | number35 | thank you |
| 19:33 | rplaca | ,(mapcat #(vector %1 %2) [:a :b :c] [1 2 3]) |
| 19:33 | clojurebot | (:a 1 :b 2 :c ...) |
| 19:33 | rplaca | which amounts to the same thing |
| 19:36 | dnolen | number35: though unless you're solving puzzles, probably better to use interleave |
| 19:38 | zakwilson | Using concat or vector is not doing it using only map and reduce. |
| 19:40 | dnolen | zakwilson: is there *anything* you can do w/ *only* map and reduce? ;) |
| 19:41 | zakwilson | dnolen: I don't think so, because they both require a function as an argument. I think the question may have been poorly phrased. |
| 19:45 | zakwilson | "can I make interleave using map, reduce, other built-in functions, function literals and data constructors?" is a very different question. The answer to that is "sure, easily, but interleave is in clojure.core, so why would you want to?". |
| 19:56 | hyPiRion | rplaca: You could just use ##(mapcat vector [:a :b :c] [1 2 3]) |
| 19:56 | hyPiRion | except lazybot is dead? |
| 19:56 | rplaca | hyPiRion: yes, good point! |
| 19:57 | hyPiRion | Raynes ^ |
| 19:57 | hyPiRion | Oh, but Raynes is offline too. Hmm. |
| 19:57 | rplaca | #(foo %1 %2) is always a code smell :) |
| 19:58 | rplaca | lazybot doesn't really exist. Raynes just answers by hand :) |
| 19:58 | hyPiRion | ah, and Raynes lost power now. |
| 19:58 | hyPiRion | viable solution |
| 20:02 | zakwilson | I'm inclined to think lazybot is just unreliable because the last commit to irclj is "Less scary README.". Prior to that, README said "Usage: don't" |
| 20:38 | bbloom | LOL: http://www.haskell.org/haskellwiki/Monad_tutorials_timeline |
| 20:38 | rplaca | the graph there is the best part! |
| 20:38 | bbloom | rplaca: oh yeah, the graph made my laugh pretty hard |
| 20:38 | rplaca | with a curve like that, I think I'll invest |
| 20:38 | rplaca | of course, past results are no guarantee of future performance |
| 20:38 | bbloom | i dunno, if my experience extrapolating wildly has taught me anything, it's the fact that 10 years from now, that graph will surely loop so far up that it flips back around and heads back towards the Y axix |
| 20:39 | akhudek | they need a graph like this: http://www.vayapotra.es/wordpress/wp-content/uploads/2009/02/2rmqi6o.gif |
| 20:40 | bbloom | nice. |
| 20:49 | ambrosebs | How do I pprint a record so it shows the ctor name? |
| 20:53 | rplaca | ambrosebs: you don't, without writing your own dispatch |
| 20:54 | rplaca | that seems to be a highly requested feature, so I'm planning to add a feature for that in the standard dispatch table |
| 20:56 | bbloom | fipp works on records, but not on lots of other stuff, heh |
| 20:57 | bbloom | ambrosebs: give it a try & i'm happy to take patches to cover more things. should be pretty easy to add stuff |
| 20:57 | ambrosebs | I'll have a look. |
| 20:57 | bbloom | and thanks to octagon, somebody else on planet earth has tried it and so i was able to hammer out a bug or two |
| 20:58 | brighid | I'm having trouble reading a configuration file. I'm basing what I'm trying on this Stack Overflow answer: http://stackoverflow.com/a/7781443/ -- I have a Leiningen project set up, and within that /src/my_project/foo.clj and /src/my_project/bar.conf. But I keep getting "FileNotFoundException bar.conf (No such file or directory)" errors. |
| 20:59 | brighid | What's the right way to say "please give me the contents of this file in my project"? |
| 21:00 | gfredericks | (clojure.java.io/resource "my_project/bar.conf") |
| 21:00 | gfredericks | I recommend putting it in /resources instead of /src though |
| 21:00 | bbloom | (doc clojure.java.io/resource) |
| 21:00 | clojurebot | "([n] [n loader]); Returns the URL for a named resource. Use the context class loader if no loader is specified." |
| 21:00 | gfredericks | but that coud should work either way |
| 21:00 | brighid | gfredericks: actually that's probably a good idea, thanks. |
| 21:00 | brighid | (the "put it in /resources" idea) |
| 21:01 | gfredericks | :) it's what it's for |
| 21:03 | i_s | does anyone know why (vals {}) => nil and not an empty seq? |
| 21:03 | gfredericks | nil is sort of an empty seq |
| 21:03 | gfredericks | ,[(seq? nil) (empty? nil)] |
| 21:03 | clojurebot | [false true] |
| 21:04 | gfredericks | ,(map seq [[] [1] [1 2]]) |
| 21:04 | clojurebot | (nil (1) (1 2)) |
| 21:04 | i_s | hm, ok that helps |
| 21:04 | hyPiRion | gfredericks: oh man, you lost a great opportunity there |
| 21:04 | hyPiRion | Hmm, was it |
| 21:04 | gfredericks | will I ever get it back? |
| 21:04 | hyPiRion | ~amalloy |
| 21:04 | clojurebot | amalloy is <amalloy> just use juxt, it'll be great |
| 21:04 | hyPiRion | yeah, that was it |
| 21:04 | hyPiRion | ,((juxt seq? empty?) nil) |
| 21:04 | clojurebot | [false true] |
| 21:04 | bbloom | i_s: it's to facilitate "nil punning" where it is often desirable to treat empty sequences as falsey |
| 21:05 | gfredericks | yes, juxt is the best way to explain unrelated concepts :P |
| 21:05 | hyPiRion | but but but |
| 21:05 | hyPiRion | JUXT! |
| 21:05 | i_s | i see |
| 21:05 | bbloom | i_s: ##(if-let [v (vals {})] v :no-vals) |
| 21:05 | gfredericks | ~juxt |
| 21:05 | clojurebot | juxt is usually the right answer |
| 21:05 | bbloom | ,(if-let [v (vals {})] v :no-vals) |
| 21:05 | clojurebot | :no-vals |
| 21:05 | gfredericks | &(doc vals) |
| 21:06 | gfredericks | ,(doc vals) |
| 21:06 | clojurebot | "([map]); Returns a sequence of the map's values." |
| 21:06 | gfredericks | well for all we know it's an implementation detail |
| 21:06 | gfredericks | ,(list) |
| 21:06 | clojurebot | () |
| 21:06 | bbloom | also fun: |
| 21:06 | gfredericks | ,(list*) |
| 21:06 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core$list-STAR-> |
| 21:06 | bbloom | ,() |
| 21:06 | clojurebot | () |
| 21:07 | bbloom | which weirded me out the first time i saw it |
| 21:07 | gfredericks | ,'() |
| 21:07 | clojurebot | () |
| 21:08 | gfredericks | ,''() |
| 21:08 | clojurebot | (quote ()) |
| 21:08 | gfredericks | ,(list* ()) |
| 21:08 | clojurebot | nil |
| 21:10 | gfredericks | clojure: it's what you make of it. |
| 21:11 | bbloom | turing machines: it's what you make of them. |
| 21:11 | gfredericks | you make busy beavers out of them |
| 21:12 | brighid | gfredericks: (clojure.java.io/resource "bar.conf") returns nil - what might I be doing wrong there? |
| 21:13 | gfredericks | is there a parent directory you're forgetting? |
| 21:13 | gfredericks | you had one earlier |
| 21:14 | i_s | with the nil punning argument though, why doesn't (filter odd? [2 4 6]) => nil instead of () |
| 21:14 | bbloom | brighid: that fn just delegates to the getResource method of the current class loader |
| 21:14 | i_s | seems inconsistent |
| 21:14 | gfredericks | i_s: it's lazy |
| 21:14 | bbloom | brighid: all info that applies to getResource also applies to clojure |
| 21:14 | gfredericks | lazy seq functions can't return nil |
| 21:14 | bbloom | for example http://stackoverflow.com/questions/12103371/how-to-use-getclass-getresource-method |
| 21:14 | i_s | hm touche |
| 21:15 | gfredericks | i_s: ideally they would but it's not feasible without giving up some laziness |
| 21:15 | i_s | right |
| 21:15 | bbloom | ,(seq (filter odd? [2 4 6])) |
| 21:15 | clojurebot | nil |
| 21:15 | gfredericks | the seq function is often used like ^that when you want to force the empty seq to nil |
| 21:15 | brighid | bbloom: Clojure is my introduction to Java, so I don't have an existing knowledge of "info that applies to getResource" :( |
| 21:16 | gfredericks | (when (seq ...) ...) |
| 21:16 | bbloom | brighid: i'm just telling you what to google for :-) |
| 21:16 | brighid | bbloom: Oh okay. Cheers. |
| 21:16 | gfredericks | brighid: if you're using leiningen you can try `lein classpath` to double-check what's included in your classpath |
| 21:16 | bbloom | brighid: also, you can try in your REPL (source clojure.java.io/resource) and then work backwards from there |
| 21:17 | brighid | Oh hey, #'source looks handy, thank you. |
| 21:17 | hyPiRion | The best is most likely |
| 21:17 | hyPiRion | ,(list? (list* (for [a [1]] a))) |
| 21:17 | hyPiRion | oh clojurebot, you so lazy |
| 21:17 | hyPiRion | ,(list? (list* (for [a [1]] a))) |
| 21:17 | hyPiRion | :'( |
| 21:17 | clojurebot | false |
| 21:17 | clojurebot | false |
| 21:18 | hiredman | ,(contains? (set (ancestors (class ()))) clojure.lang.Counted) |
| 21:18 | clojurebot | true |
| 21:23 | george_mcfly | why is it that when i pass a vector to drop-last, it gives me back a list ? shouldn't it return whatever collection type it receives ? |
| 21:23 | george_mcfly | (= '(1 2 3) (drop-last [1 2 3 4])) |
| 21:24 | bbloom | george_mcfly: no, clojure's sequence functions are generally lazy |
| 21:24 | bbloom | vectors have known size |
| 21:24 | bbloom | if you want to get a vector, you need to strictly evaluate, which you can do with vec or into [] |
| 21:24 | bbloom | ,(vec (drop-last [1 2 3 4])) |
| 21:24 | clojurebot | [1 2 3] |
| 21:24 | bbloom | but realize what this is doing: it's copying each element into a NEW VECTOR |
| 21:25 | bbloom | that's an O(1) operation |
| 21:25 | bbloom | er i mean O(N) |
| 21:25 | bbloom | if you want O(1), and you do, you can get that with pop: |
| 21:25 | bbloom | ,(pop [1 2 3 4]) |
| 21:25 | clojurebot | [1 2 3] |
| 21:25 | george_mcfly | cool |
| 21:25 | bbloom | since that's O(1), you're sure to get a vector back b/c the size i statically known and no copying or anything has to happen |
| 21:25 | george_mcfly | i'll have to read up on strictly evaluating |
| 21:26 | george_mcfly | right |
| 21:26 | george_mcfly | neat trick |
| 21:26 | george_mcfly | almost too simple to call a trick really heh |
| 21:26 | bbloom | heh |
| 21:26 | bbloom | if you're coming from Scala, you might be used to the CanBuildFrom thing. maybe? |
| 21:26 | george_mcfly | i'm not but good info nonetheless |
| 21:28 | bbloom | anyway, the point is that clojure provides data structures with runtime tuned for various needs, so use the right data structure! and whenever you need to do something O(N) no matter what, laziness kicks in and you get a seq |
| 21:28 | bbloom | ,(pop '(1 2 3)) |
| 21:28 | clojurebot | (2 3) |
| 21:28 | bbloom | ,(pop '[1 2 3]) |
| 21:28 | clojurebot | [1 2] |
| 21:28 | bbloom | ,(conj '(1 2 3) 4) |
| 21:28 | clojurebot | (4 1 2 3) |
| 21:28 | bbloom | ,(conj '[1 2 3] 4) |
| 21:28 | clojurebot | [1 2 3 4] |
| 21:29 | bbloom | lists are built from the front, vectors from the rear b/c of their internal structure and performance guarentees |
| 21:29 | brighid | Okay this still isn't working, and I don't think I gave enough information the first time about what my problem was. Here's what I'm currently trying: https://gist.github.com/brighid/5234382 That gives me the contents of the file that I want, but it needs an absolute filesystem path. How can I go from that to a relative-to-my-project path? |
| 21:34 | xeqi_ | brighid: try (io/resource "bar.conf") |
| 21:36 | brighid | xeqi: In place of the io/reader call? |
| 21:36 | bbloom | brighid: as an argument to it |
| 21:37 | xeqi | I think in replacement of the path |
| 21:38 | xeqi | though I've rarely needed a pushbackreader, so there might be a different spot depending on how you are using it |
| 21:38 | gfredericks | if (io/resource "bar.conf") returns nil at the repl then I think something is wrong |
| 21:39 | xeqi | if you made the resources/ dir after starting the repl you might need to restart it |
| 21:40 | gfredericks | ah ha; good thought |
| 21:40 | brighid | Good point. *restarts nrepl* |
| 21:41 | brighid | (io/resource "bar.conf") => #<URL file:/Users/brighid/Dropbox/clojure/...> \o/ |
| 21:42 | gfredericks | hoo-ray |
| 21:43 | brighid | Okay, this version works: https://gist.github.com/brighid/5234382 |
| 21:43 | brighid | Thank you folks. :) I didn't get *where* to use #'io/resource at first, also I think that the REPL indeed hadn't seen the file. |
| 21:44 | gfredericks | presumably leiningen doesn't see the point in adding non-existent directories to the classpath |
| 21:45 | brighid | gfredericks: a reasonable enough decisions. |
| 21:51 | hyPiRion | blech, why bother DDoSing Freenode? |
| 21:52 | headshot | why bother ddosing anything? |
| 21:53 | gfredericks | D-DOS: for when you can't get enough DOS |
| 21:55 | gfredericks | oh wow I forgot it had a logo with bubble letters |
| 22:22 | maxb2 | nick maxb_ |
| 23:09 | wei_ | in a compojure app: where's the best place to call to connect to my db so that lein ring server connects to the db? |
| 23:14 | akhudek | wei_: I always just use a main that does initialization of this sort then runs the server via the ring jetty adapter |
| 23:14 | wei_ | i see. that's what I settled on just now |
| 23:15 | akhudek | though connection pooling would avoid that as the pool will initiate connections as needed |
| 23:15 | akhudek | think korma has connection pooling built in |
| 23:15 | akhudek | no doubt there is a way to add it easily for clojure.jdbc too |