2011-06-22
| 00:41 | sunnibo | question: is there any well-formed URL checking lib? i don't want to check if the URL is valid or not. i just want to check if the given string is a URL or not. |
| 00:46 | amalloy | sunnibo: uhhh, the thing you want to do and the thing you don't want to do seem to be the same thing. http://www.someurlimadeup.com isn't "invalid" just because nobody owns that domain name |
| 00:47 | amalloy | but i think ##(java.net.URL. "http://whatever.com") will work, by throwing an exception if it's invalid |
| 00:47 | sexpbot | ⟹ #<URL http://whatever.com> |
| 00:48 | amalloy | &(java.net.URL. "test") |
| 00:48 | sexpbot | java.net.MalformedURLException: no protocol: test |
| 00:52 | sunnibo | thanks, amalloy |
| 02:01 | sunnibo | question: how can i get a number from a string? the given string is an alphanumeric. i want to get the number part. ex) "123'" -> 123 |
| 02:06 | amalloy | $findfn "123" 123 |
| 02:06 | sexpbot | [clojure.core/read-string clojure.core/bigdec clojure.core/bigint] |
| 02:07 | Scriptor | ,(doc read-string) |
| 02:07 | clojurebot | "([s]); Reads one object from the string s" |
| 02:07 | Scriptor | ,(read-string "123") |
| 02:07 | clojurebot | 123 |
| 02:07 | Scriptor | ,(read-string "123'") |
| 02:07 | clojurebot | 123 |
| 02:07 | Scriptor | sunnibo: looks liek that's what you want |
| 02:07 | Scriptor | *like |
| 02:22 | rhdoenges | sunnibo: or (Integer. "123") |
| 02:22 | rhdoenges | ,(Integer. "123) |
| 02:22 | clojurebot | EOF while reading string |
| 02:22 | rhdoenges | ,(Integer. "123") |
| 02:22 | clojurebot | 123 |
| 02:22 | rhdoenges | ,(Number. "123") |
| 02:22 | clojurebot | java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Number |
| 02:22 | rhdoenges | ohkay. |
| 02:22 | rhdoenges | so you want Integer probably |
| 02:24 | rhdoenges | because this can happen: |
| 02:24 | rhdoenges | ,(read-string "(1 2 3 4 5)") |
| 02:24 | clojurebot | (1 2 3 4 5) |
| 02:25 | Scriptor | ah, right, read as in clojure's reader |
| 02:30 | terom | Integer(String s) constructs a new Integer object; in case that matters, you can use also Integer#parseInt(String s). |
| 02:30 | terom | ,(Integer/parseInt "123") |
| 02:30 | clojurebot | 123 |
| 02:32 | Scriptor | terom: parseInt doesn't work when there are non-numeric characters, and that's what sunnibo needed |
| 02:32 | Scriptor | ,(Integer/parseint "123'") |
| 02:32 | clojurebot | java.lang.IllegalArgumentException: No matching method: parseint |
| 02:32 | Scriptor | ,(Integer/parseInt "123'") |
| 02:32 | clojurebot | java.lang.NumberFormatException: For input string: "123'" |
| 02:32 | terom | ,(Integer. "123'") |
| 02:32 | clojurebot | java.lang.NumberFormatException: For input string: "123'" |
| 02:33 | terom | Scriptor: true, and neither does Integer constructor. |
| 02:33 | Scriptor | yep, so I guess you'd have to rely on read-str, although if there's valid clojure code in the string there'd be problems |
| 02:34 | terom | Well, one could also use regexps. Depends on the input strings, really. |
| 02:36 | rhdoenges | (read-str "123") is prettier. Just be sure that you are passing safe input and you're fine. |
| 02:38 | rhdoenges | *read-string |
| 02:38 | rhdoenges | :P |
| 02:39 | Scriptor | ,(read-string "2 a") |
| 02:39 | clojurebot | 2 |
| 02:39 | Scriptor | ,(read-string "2 :a") |
| 02:39 | clojurebot | 2 |
| 02:40 | sunnibo | read-string would be good for me. thanks, guys! |
| 02:40 | Scriptor | sunnibo: careful if you do something like (read-string "a 2") |
| 02:40 | Scriptor | ,(read-string "a 2") |
| 02:40 | clojurebot | a |
| 02:41 | Scriptor | as you can see, it seems to go for the first token |
| 02:42 | Scriptor | I guess if you need to you could always do a string replace of anything that's not a digit with blak |
| 02:46 | amalloy | &(->> "a 123" (re-seq #"\d+") first read-string) |
| 02:46 | sexpbot | ⟹ 123 |
| 03:23 | sunnibo | another question: ((1 2 3) (4 5) (6 7)) -> (1 2 3 4 5 6 7) |
| 03:25 | raek | sunnibo: ##(apply concat '((1 2 3) (4 5) (6 7))) |
| 03:25 | sexpbot | ⟹ (1 2 3 4 5 6 7) |
| 03:26 | raek | ,(apply concat '((1 2 3 (4 5)) (6 7))) |
| 03:26 | clojurebot | (1 2 3 (4 5) 6 7) |
| 03:26 | raek | ,(flatten '((1 2 3 (4 5)) (6 7))) |
| 03:26 | clojurebot | (1 2 3 4 5 6 7) |
| 03:27 | raek | "apply concat" does not have a shorter name unfortunately |
| 03:30 | raek | and "flatten" is not in general a substitute |
| 03:30 | sunnibo | raek, thanks |
| 03:49 | Raynes | I propose that concat be renamed to octocat. |
| 03:51 | rhdoenges | I propose that github does all my programming and I eat calamari. |
| 03:54 | sunnibo | ,(and '(false false)) |
| 03:54 | clojurebot | (false false) |
| 03:55 | sunnibo | ,(and '(false true)) |
| 03:55 | clojurebot | (false true) |
| 03:55 | __name__ | ,(apply and '(false false)) |
| 03:55 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.core/and |
| 03:55 | sunnibo | how can i get just 'false'? |
| 03:55 | raek | ,(every? identity '(false false)) |
| 03:55 | clojurebot | false |
| 03:56 | sunnibo | ,(every? identity '(false true)) |
| 03:56 | clojurebot | false |
| 03:56 | raek | ,(and :truthy :falsy) |
| 03:56 | clojurebot | :falsy |
| 03:56 | raek | ,(boolean (and :truthy :falsy)) |
| 03:56 | clojurebot | true |
| 03:56 | sunnibo | ,(some identity '(false true)) |
| 03:56 | clojurebot | true |
| 03:56 | sunnibo | yeah, but the parameter is a list |
| 03:57 | raek | eh, ":falsy" is of course truthy since it's neither nil nor false... |
| 03:57 | __name__ | (every? true? [true false]) |
| 03:57 | __name__ | ,(every? true? [true false]) |
| 03:57 | clojurebot | false |
| 03:57 | __name__ | ,(every? true? [false false]) |
| 03:57 | clojurebot | false |
| 03:57 | __name__ | ,(every? true? [false true]) |
| 03:57 | clojurebot | false |
| 03:57 | raek | ,(every? true? [1 2]) |
| 03:57 | clojurebot | false |
| 03:57 | __name__ | ,(every? true? [true true]) |
| 03:57 | clojurebot | true |
| 03:57 | raek | ,(every? identity [1 2]) |
| 03:57 | clojurebot | true |
| 03:57 | sunnibo | what's the 'identity |
| 03:58 | raek | sunnibo: the identity function just returns its argument |
| 03:58 | raek | so the value itself is checked for truthiness |
| 03:59 | sunnibo | ,(identity '(false true)) |
| 03:59 | clojurebot | (false true) |
| 03:59 | sunnibo | i got it |
| 03:59 | rhdoenges | ,(doc and) |
| 03:59 | clojurebot | "([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true." |
| 03:59 | raek | ,(every? identity [a b c]) is equivalent to (boolean (and (identity a) (identity b) (identity c)))) which is equivalent to (boolean (and a b c)) |
| 03:59 | clojurebot | java.lang.Exception: Unable to resolve symbol: a in this context |
| 04:24 | sunnibo | question: i have a couple of lists, (1 2 3) (a b c) (u v s). how can i get (1 a u) (2 b v) (3 c s)? |
| 04:27 | Fossi | ,(find) |
| 04:27 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$find |
| 04:31 | Scriptor | sunnibo: look into map, specifically passing it multiple lists |
| 04:31 | Scriptor | check out the examples: http://clojuredocs.org/clojure_core/clojure.core/map |
| 04:36 | sunnibo | ,(map list '(1 2 3) '(a b c) '(u v s)) |
| 04:36 | clojurebot | ((1 a u) (2 b v) (3 c s)) |
| 04:39 | Cozey | woo - lisp syntax is gaining popularity: http://programming.nu/ |
| 04:42 | Fossi | weird |
| 05:33 | pyr | noir is really well polished |
| 06:19 | Cozey | how could i define a multimethod dispatch function, so it accepts a _set_ of values per each defmulti ? |
| 06:20 | bsteuber | Cozey: you can't using defmulti |
| 06:20 | bsteuber | but you can do that yourself |
| 06:21 | bsteuber | have one lookup function |
| 06:21 | bsteuber | and one facade function doing the dispatch |
| 06:23 | clgv | Cozey: I am not sure if I understood you completely - can you give an example of what you mean? |
| 06:24 | Cozey | well |
| 06:25 | Cozey | (defmulti foo (fn [some-text value] some-text)) |
| 06:26 | Cozey | (defmethod #{"zebra" "horse"} [_ v] (run-away v)) |
| 06:26 | Cozey | (defmethod #{"fox"} [_ v] (hide v)) |
| 06:26 | Cozey | something like this |
| 06:26 | jhuni | ,(+ 1 1) |
| 06:26 | clojurebot | 2 |
| 06:27 | clgv | ah ok |
| 06:28 | jhuni | ,(-> 0 inc inc) |
| 06:28 | clojurebot | 2 |
| 06:29 | clgv | Cozey: you could implement bsteuber suggestion then or build an own macro that translates your "set defmethod" into single standard defmethods. |
| 06:33 | Cozey | hmm - lookup, disptach - which one is on defmulti and wher is the other one ? |
| 06:33 | clgv | Cozey: defmethod and defmulti almost instantly use the java part of the clojure implementation. so you cant just alter them easily |
| 06:36 | Cozey | clgv: generating few methods is not a bad idea |
| 06:39 | Cozey | and in bsteuber's idea, how would that look ? defmethod always matches it's arguments with = right? |
| 06:41 | Cozey | hmm. but from extensibility perspective, generating a defmethod for each set element is better |
| 06:44 | bsteuber | Cozey: true, so maybe it's simplest |
| 06:44 | bsteuber | to just have a macro define a method per key |
| 06:45 | manutter | can you use hierarchies for that? |
| 06:46 | clgv | Cozey: you could try something like that: (defmacro defmethod-set [name value & body] (if-not (set? value) `(defmethod ~name ~value ~@body) `(doseq [v# ~value] (defmethod ~name v# ~@body)))) |
| 06:46 | clgv | I tried it for a simple value and a set |
| 06:46 | clgv | (defmethod-set foo #{"donkey", "horse"} [bla v] "donkey or horse") |
| 06:46 | clgv | (defmethod-set foo "zebra" [bla v] "zebra") |
| 06:47 | Cozey | yes - unfortunately in my example i dispatch on two values - from which only one is intended to be a set - but a general solution would create a cartesian product of both sets (it they were sets) and generate defmethods for this |
| 06:47 | clgv | it get's the job done, but it will define multiple implementations - one for each dispatch value. |
| 06:48 | Cozey | s/example/project/ |
| 06:48 | sexpbot | <Cozey> yes - unfortunately in my project i dispatch on two values - from which only one is intended to be a set - but a general solution would create a cartesian product of both sets (it they were sets) and generate defmethods for this |
| 06:48 | Cozey | sexpbot: thanks :-) |
| 06:48 | clgv | hmm you can also skip the if-not and only use defmethod for value dispatch and defmethod-set for set dispatch |
| 06:50 | Cozey | yes |
| 06:51 | clgv | hmm you could also use the original defmethod only and built some sort of pre-dispatch into the dispatch function |
| 06:52 | Cozey | it's not possible to add a docstring to defmulti ? |
| 06:52 | Cozey | "The syntax for defmulti has changed. Example: (defmulti name dispatch-fn :default dispatch-value)" |
| 06:53 | clgv | (defmulti foo (fn [some-text value] (cond (#{"donkey" "horse"} some-text) :donkey-or-horse (= "zebra" some-text) :zebra :else :default))) |
| 06:53 | clgv | and then use the keywords in your defmethods |
| 06:53 | Cozey | uh my bad - it's ok |
| 06:54 | clgv | I think thats really elegant that way |
| 06:54 | Cozey | clgv: yes i thought about this too - but then it would not be possible to add new types - and that is what defmulti is all about |
| 06:54 | clgv | humm can you use a multimethod as dispatch function? ;) |
| 06:54 | Cozey | so the previous idea is better, because in the end we get a 'compatible' solution, typing less. |
| 06:55 | Cozey | brialiant! |
| 06:55 | clgv | but still quite a bit of a hack ;) |
| 06:56 | Cozey | or maybe i could use a hierarchy ? |
| 06:56 | Cozey | but can i use strings in hierarchies ? |
| 06:56 | bsteuber | no, only namespace-qualified keywords are allowed in hierarchies |
| 06:56 | bsteuber | and java classes as leaves |
| 06:58 | clgv | is there a clojure construct called "hierarchy"? |
| 06:59 | Cozey | i could convert the strings into keyword |
| 06:59 | Cozey | http://clojure.org/multimethods |
| 06:59 | clgv | just got there through google ;) |
| 07:00 | Cozey | how to create a ::kw keyword ? |
| 07:00 | Cozey | bound to a namespace? |
| 07:01 | Cozey | ,(keyword *ns* "pe") |
| 07:01 | clojurebot | java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to java.lang.String |
| 07:01 | clgv | Cozey: keywords are not really bound to namespaces - if you add :: in front it just adds the namespace as prefix to the keyword |
| 07:01 | Cozey | ,(doc keyword) |
| 07:01 | clojurebot | "([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically." |
| 07:01 | Cozey | but how to run second form of keyword |
| 07:02 | terom | ,(keyword "ns" "keyword") |
| 07:02 | clojurebot | :ns/keyword |
| 07:02 | clgv | &(keyword (name *ns*) "pe") |
| 07:02 | sexpbot | java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.Named |
| 07:02 | clgv | &(keyword (ns-name *ns*) "pe") |
| 07:02 | sexpbot | java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String |
| 07:02 | bsteuber | haha |
| 07:02 | bsteuber | closer |
| 07:02 | terom | ,(keyword (str *ns*) "pe") |
| 07:02 | clojurebot | :sandbox/pe |
| 07:02 | bsteuber | but using *ns* doesn't make sense anyways |
| 07:03 | Cozey | why? |
| 07:03 | clojurebot | http://clojure.org/rationale |
| 07:03 | bsteuber | ,::pe |
| 07:03 | clojurebot | :sandbox/pe |
| 07:03 | bsteuber | because :: is shorter |
| 07:03 | clgv | bsteuber: he wants to generate keywords from strings ;) |
| 07:04 | bsteuber | damn :) |
| 07:04 | bsteuber | but I don't think a hierarchy will gain so much |
| 07:04 | bsteuber | because if you want to define many at once |
| 07:04 | bsteuber | you still need to generate all the derive-statements |
| 07:05 | Cozey | yes but it's shorter and extensible |
| 07:06 | Cozey | when I think of it now, it's a perfect match for this use case |
| 07:06 | clgv | you can always write a wrapper macro or function ;) |
| 07:07 | clgv | Cozey: so your dsipatch function will always got to the highest parent in the hierachy and return that one? |
| 07:08 | Cozey | clgv: there's this isa? thing which is used automatically |
| 07:09 | Cozey | i'll get it to work and show |
| 07:10 | clgv | Cozey: can't imagine a dynamic version with 'isa? but I'll wait and see^^ |
| 07:10 | Cozey | the isa? should be automatic |
| 07:10 | Cozey | here are examples : http://clojuredocs.org/clojure_core/1.2.0/clojure.core/defmulti |
| 07:11 | clgv | it's transitive for sure but I dont know how you want to write your dispatch function with it |
| 07:14 | clgv | ah. defmultia uses 'isa? instead of '= |
| 07:28 | Cozey | *ns* yields <user> when required from user, even if the function is in another ns |
| 07:28 | Cozey | shoudl i harcode it like "foo.bar" or ? |
| 07:36 | terom | I'm not sure what you're doing (maybe you should paste your code somewhere), but maybe this could help: ##(read-string "::pe") |
| 07:36 | sexpbot | ⟹ :sandbox7608/pe |
| 07:38 | clgv | Cozey: thats expected behavior. *ns* returns the *ns* you are in. you might want to use ~*ns* within a macro |
| 07:39 | Cozey | mhm |
| 07:39 | clgv | Cozey: or you show us the example, what it does and tell us what it is intended to do ;) |
| 07:40 | Cozey | one sec: |
| 07:40 | Cozey | https://github.com/lolownia/lancet/blob/master/src/lancet/core.clj#L58 |
| 07:42 | Cozey | that way i can write ant-tasks under lein using more idiomatic clojure: https://gist.github.com/1039929 |
| 07:43 | clgv | so now the exact call and its output are needed ;) |
| 07:44 | Cozey | ? |
| 07:45 | Cozey | (add-nested "exec" (ExecTask. .... ) "--help") will set --help argument on ExecTask |
| 07:46 | Cozey | on the other hand (add-nested "war" (War. ...) (FileSet. ... ) ) will set filesets for Warfile to use. Ant has a bizzare API - that is: lot's of tasks use different input objects |
| 07:46 | clgv | humm I dont even see any usage of *ns* in there |
| 07:46 | Cozey | like ManifestTask for generating Manifest files - they use Manifest$Attribute |
| 07:46 | Cozey | i have hardcoded lancet.core |
| 07:47 | Cozey | line 68 |
| 07:47 | Cozey | not the best solution out there |
| 07:51 | Cozey | enough. I'm going outside :-) thanks for help and have a nice day. |
| 07:52 | clgv | *ns* should work in there as well |
| 08:14 | clgv | concerning maps where is the difference between 'into and 'merge? which one should I prefer to use? |
| 08:15 | clgv | (doc into) |
| 08:15 | clojurebot | "([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined." |
| 08:15 | clgv | ok merge supports multiple maps |
| 08:17 | bsteuber | into also works for other types |
| 08:18 | clgv | yes, it's more general. |
| 09:01 | shtutgart | In Midje, I've wrote (provided (get @an-atom anything) => :foo) and got "You claimed the following was needed, but it was never used: (get (clojure.core/deref an-atom) anything)". What might be the problem? |
| 09:02 | shtutgart | (of course I'm calling get on @an-atom) |
| 09:17 | manutter | shtutgart: I wonder if it would make a difference if you wrote out (deref an-atom) instead of using the shortcut @an-atom |
| 09:23 | raek | ,(read-string "@foo") |
| 09:23 | clojurebot | (clojure.core/deref foo) |
| 09:24 | raek | that seems unlikely. there shouldn't be any difference from the forms emitted by the reader. (except for the namespace qualification of the symbol, maybe) |
| 09:34 | pyr | hi |
| 09:34 | pyr | is it a known bug that (keyword "") breaks the code is data / data is code aspect of clojure |
| 09:35 | pyr | ,(read-string (str {(keyword "") :foo})) |
| 09:35 | clojurebot | java.lang.RuntimeException: java.lang.Exception: Invalid token: : |
| 09:39 | jochen_ | hi, I have an enlive question: in swadonnette tutorial scrape2.clj, select with a set as second par is used to extract two items, but then partition2 with vector destructuring is used to assign to headline and points. Isn't this broken as a set does not guarantee any order? |
| 09:39 | cemerick | pyr: Not broken. Empty keywords just aren't readably printable. |
| 09:41 | pyr | it looks as if LispReader.java could be coerced into getting it right |
| 09:42 | pyr | cemerick: ok, but that breaks homoiconicity at least |
| 09:42 | cemerick | pyr: A saner approach (often-suggested) is to support arbitrary symbols and keywords via pipes. e.g. :|| for an empty keyword, or |foo bar| for a symbol with spaces, etc. |
| 09:43 | cemerick | pyr: how? You're just bumping up against impl details of the reader. |
| 09:45 | pyr | well even if its not that important if it can be cleanly fixed in the reader it's just all for the better isn't it ? |
| 09:47 | cemerick | pyr: the empty keyword is just one edge case, along with keywords and symbols with constituent whitespace, colons, and slashes. "Fixing" the reader to handle just one of them isn't seen as a high priority, when there's likely an acceptable general-purpose solution. |
| 09:48 | clgv | pyr you can also do that: ##(keyword ":bla") |
| 09:48 | sexpbot | ⟹ ::bla |
| 09:48 | pyr | cemerick: 'k, got it |
| 09:49 | cemerick | pyr: If it's a big concern/problem for you, do feel free to take it on. My guess is that particular behaviour hasn't changed because no one has cared enough to push on it. |
| 09:49 | pyr | cemerick: nope, i didn't get that there were so many other non readable forms |
| 09:50 | pyr | cemerick: and indeed it doesn't make sense to fix just the one |
| 09:50 | pyr | it's true that i could have just tried ##(keyword " ") |
| 09:50 | sexpbot | ⟹ : |
| 09:51 | pyr | to see for myself :) |
| 09:52 | clgv | but I guess this one doesnt read-in like it should as well: ##(-> (keyword ":bla") str read-string) |
| 09:52 | sexpbot | ⟹ :sandbox7608/bla |
| 09:53 | clgv | it's discouraged in some doc to generate keywords like that but not impossible. |
| 10:10 | TimMc | ,(identical? :f (keyword "f")) |
| 10:10 | clojurebot | true |
| 10:10 | TimMc | good |
| 10:17 | clgv | &(identical? ::bla (keyword ":bla")) |
| 10:17 | sexpbot | ⟹ false |
| 10:17 | clgv | ;) |
| 10:34 | TimMc | eep |
| 10:35 | TimMc | Oh, I see. |
| 10:51 | clgv | sexpbot: would you like to join #clojure.de? ;) |
| 10:51 | sexpbot | I'd do him. Hard. |
| 11:03 | ejackson | filthy bot - i hope you practice safe hex. |
| 11:16 | miltondsilva | hi, you all know this http://cemerick.com/2011/06/15/the-2011-state-of-clojure-survey-is-open/ so, in the comments section Chas Emerick says that a different survey covering other type of questions could be useful... |
| 11:17 | miltondsilva | here is a draft of a possible survey |
| 11:17 | miltondsilva | https://spreadsheets.google.com/spreadsheet/viewform?formkey=dFFJTTZWT2lXR1N1dTJTWk5mdjZXZlE6MQ |
| 11:18 | miltondsilva | sugestions are very welcome (to add more questions or to add more options, I'm sure there are missing ones) |
| 11:54 | justinlilly | Hey folks. What's the preferred cheap/free hosting setup for a clojure webapp? AppEngine? |
| 11:54 | justinlilly | didn't know if there is a heroku-like equivalent in the JVM world. |
| 11:54 | dnolen | justinlilly: Clojure runs on Heroku |
| 11:55 | wastrel | never heard of heroku |
| 11:56 | justinlilly | ahh. neat. Didn't realize they offered more hosting options these days. |
| 11:59 | sritchie | jesus, just went into #java, it's crazy in there |
| 11:59 | pjstadig | justinlilly: they have this whole new procfile thing |
| 11:59 | sritchie | thank you all for your civility |
| 11:59 | pjstadig | where you can run pretty much anything you want |
| 12:00 | polyst | (inc sritchie) |
| 12:00 | sexpbot | ⟹ 1 |
| 12:00 | justinlilly | hm. neat. I may check it out. Not having a reasonable place to deploy was one hesitation I had w/ messing around with some clojure webapps, but presumably, that's not an issue now :) |
| 12:02 | seancorfield__ | i was pleasantly surprised by how easy it is to run clojure on heroku |
| 12:04 | TimMc | sritchie: "How does I hello world?" |
| 12:05 | TimMc | "WHAT IS MAIN" |
| 12:05 | sritchie | one of the first things I saw was "YOU'RE SHADOWING THE FUCKING VARIABLE!!!" |
| 12:05 | TimMc | haha |
| 12:05 | sritchie | see, even cursing in here feels just wrong and terrible |
| 12:06 | TimMc | ~guards! |
| 12:06 | clojurebot | SEIZE HIM! |
| 12:06 | sritchie | clojurebot: botsnack |
| 12:06 | clojurebot | Thanks! Can I have chocolate next time |
| 12:06 | sritchie | obvi |
| 12:06 | polyst | $kill |
| 12:06 | sexpbot | KILL IT WITH FIRE! |
| 12:07 | clgv | clojurebot: chocolate |
| 12:07 | clojurebot | Pardon? |
| 12:07 | clgv | lol |
| 12:07 | dnolen | sritchie: well, you have to sympathize with #java. They must get the same 10 noob/student questions every couple of minutes. |
| 12:09 | sritchie | dnolen: yes, the point's well taken -- grizzled as they are, at least those guys are in there answering questions |
| 12:21 | wastrel | clojurebot eh |
| 12:30 | tufflax | When calling swap!, the actual swap happens in another thread right? I find that I'm using a lot of (swap! some-atom (constantly some-val)) and realized that that can be very bad if the last swap does not happen before I use the atom to create the next value that is gonna be the argument to constatly. I shouldn't be using constantly so much, right? |
| 12:31 | hiredman | tufflax: no |
| 12:31 | tufflax | no? :p |
| 12:31 | hiredman | tufflax: there was a question somewhere in there, the answer is no |
| 12:31 | clojurebot | c'est bon! |
| 12:32 | tufflax | hiredman there are 2 questions |
| 12:32 | hiredman | fine: no, whatever you like |
| 12:33 | tufflax | So swap! happens in the caller thread? |
| 12:34 | raek | tufflax: also, you can use reset! in this case |
| 12:34 | raek | tufflax: yes |
| 12:34 | tufflax | ok, thanks |
| 12:34 | raek | tufflax: the current value is read, the function is applied to create a new value and then the new value is compare-and-set!'ed in |
| 12:34 | tufflax | ah ok |
| 12:34 | tufflax | didn't know about reset! |
| 12:35 | raek | if the value had changed, the set fails and another attempt is done |
| 12:35 | tufflax | i see |
| 12:37 | edw | Anyone here use redistogo? I'm trying to figure out where, if anywhere to pass in the user from the redis URL. |
| 12:38 | edw | I'm using redis-clojure... |
| 12:38 | abedra | how does one file an issue with Ring? |
| 12:38 | edw | Github? |
| 12:38 | clojurebot | github is http://github.com/clojure/clojure |
| 12:38 | abedra | there's no issue page up on the github wiki |
| 12:40 | edw | Hmm. The man doesn't want to be contacted... |
| 12:41 | pjstadig | http://groups.google.com/group/ring-clojure ? |
| 12:45 | abedra | edw, it's fine, I just emailed mark |
| 12:45 | abedra | there's a bug in wrap-params |
| 12:46 | abedra | under the hood it calls URLDecode/decode |
| 12:46 | abedra | and if the param passed in is "%" that blows up |
| 12:46 | abedra | throwing an exception and halting everything else |
| 12:46 | edw | Whereas it should call what? Something that also escapes query-string chars like ? and & |
| 12:47 | abedra | that's why I emailed mark |
| 12:47 | abedra | there are a few ways of working around this, but before I spend time putting together a patch I would like to get his input |
| 12:47 | edw | Right. I just forget the proper names of the more and less permissive versions. |
| 12:49 | hugod | Isn't weavejester maintaining ring now? |
| 12:50 | abedra | hugod, he might |
| 12:50 | abedra | be |
| 12:50 | abedra | i should send him a note as well |
| 12:54 | ilyak | Damn. Why doesn't my ccw builder build clojure files? |
| 12:54 | ilyak | Is there any logs or something? |
| 12:59 | duncanm | hmm, anyone know how to copy an emacs stack trace? |
| 13:00 | duncanm | the buffer seems kinda stuck, and once i press 'q', it goes away |
| 13:09 | dpritchett | I'm trying to figure out how my noir app is automatically reloading every time i save a view file. i can write a function, save, and hit f5 and the new function is there |
| 13:09 | dpritchett | I'm using lein run, noir uses ring/jetty by default i think |
| 13:09 | dpritchett | digging around in the respective sources to figureo ut where the hot reloads come in |
| 13:10 | mids | dpritchett: its the reload-modified middleware in https://github.com/ibdknox/noir/blob/master/src/noir/server.clj |
| 13:10 | dpritchett | thanks mids |
| 13:11 | dpritchett | I'm quite glad it's doing this I just didn't expect it :) |
| 13:12 | dpritchett | here's the ring.middleware.reload-modified source, fun read https://github.com/weavejester/ring-reload-modified/blob/master/src/ring/middleware/reload_modified.clj |
| 13:39 | amalloy | duncanm: C-x h to mark the whole buffer, then M-w to copy? |
| 13:58 | edw | Is there any consensus on the "best" redis client out there? |
| 14:06 | dpritchett | how can i use array literal notation side by side with an array generating function |
| 14:06 | dpritchett | say I have one function that returns an array with three k:v pairs |
| 14:06 | dpritchett | and i want to reference it from within a list where i specified two arrays literally and i want to specify the third using my function |
| 14:07 | dpritchett | e.g. https://gist.github.com/04a93dcf80d8a5dd6913 |
| 14:08 | dpritchett | ah, found a stray paren nevermind |
| 14:10 | wastrel | parenthesis can be important |
| 14:29 | devn | Also, how does everyone manage getting the latest build with leiningen? Is there some easy route I'm missing? |
| 14:35 | dpritchett | i just run "lein update" sporadically |
| 14:46 | dnolen | it's a bit annoying that ls |
| 14:47 | dnolen | oops sorry |
| 14:47 | polyst | (dec dnolen) |
| 14:47 | sexpbot | ⟹ 2 |
| 14:47 | polyst | ;-) |
| 15:00 | amalloy | edw: i've used aleph a little for redis, and it seems fine |
| 15:14 | gtrak | you guys ever thought of using akka for multi-node stuff? are there other alternatives for clojure that work better? |
| 15:15 | seancorfield__ | anyone use clojuresque with gradle? pros / cons vs leiningen? |
| 15:16 | hiredman | gtrak: depends what you are distributing |
| 15:16 | hiredman | akka is actors righ? |
| 15:16 | hiredman | right |
| 15:16 | gtrak | yes |
| 15:16 | dpritchett | does hiccup usually spit out source with no whitespace? http://3y5n.localtunnel.com/todos |
| 15:17 | gtrak | I don't know exactly what to distribute, but I want to prototype with it in mind, so I want something flexible and light |
| 15:17 | hiredman | actors are generally nice for modeling state machines, but if you are just distributing data processing in parallel then you don't need them |
| 15:17 | hiredman | gtrak: how can you not know that? |
| 15:18 | gtrak | just experiementing |
| 15:18 | gtrak | for my own gratification |
| 15:18 | hiredman | well then do whatever is most gratifying |
| 15:19 | amalloy | dpritchett: yes |
| 15:19 | gtrak | but i think it'll look like looping over a dataset, where the dataset is a cache that gets synched with a db or something |
| 15:19 | amalloy | i assume there's a setting/binding somewhere you can change |
| 15:20 | technomancy | I briefly looked into using akka. the docs assume you know scala, so I didn't get very far |
| 15:20 | technomancy | actually kind of glad I didn't spend more time on it after reading this: http://blog.darevay.com/2011/06/clojure-and-akka-a-match-made-in/ |
| 15:21 | gtrak | yea, I just saw that |
| 15:21 | gtrak | though you see at the bottom jboner's interested in seeing it work |
| 15:22 | hiredman | I do have an as yet unannounced library that attempts to making working with message queues (hornetq) dirt simple to start with |
| 15:22 | hiredman | https://github.com/hiredman/vespa-crabro |
| 15:22 | technomancy | gtrak: yeah, there's promise; it's just not there yet |
| 16:15 | amalloy | chouser: is there a finger-tree measure i could use/write that would support fast conjing onto one end, and fast dissoc from anywhere in the middle? |
| 16:18 | devn | this new noir web framework looks promising |
| 16:18 | devn | https://github.com/ibdknox/noir |
| 16:20 | dpritchett | yeah its been fun playign with it today devn |
| 16:20 | dpritchett | i like having a few sensible defaults chosen for me so i don't have to figure out the whole stack myself |
| 16:20 | dpritchett | although reading this helped too http://brehaut.net/blog/2011/ring_introduction |
| 16:31 | hickster | whois chouser |
| 17:04 | devn | a nice guy |
| 17:09 | amalloy | devn: the official #clojure faq |
| 18:10 | sdeobald | Does anyone know if there's a function in contrib (or otherwise) to convert camelCase into hyphen-case? |
| 18:12 | amalloy | sdeobald: there are a few libraries with an implementation of that you could steal. i don't know of one in contrib |
| 18:14 | amalloy | sdeobald: https://github.com/ninjudd/cake/blob/develop/src/cake/tasks/deps.clj#L95 is one, which i think i wrote |
| 18:15 | tremolo | couldn't you handle that with a relatively simple RegEx replace |
| 18:20 | sdeobald | amalloy: Thanks. Was just hoping to avoid writing yet another. Guess it's probably just time to suck it up and assemble some sort of generic utils lib. |
| 18:21 | amalloy | sdeobald: i approve of everyone having their own generic utils lib |
| 21:17 | arohner | chouser: remember my "bug report" a few days ago about clojure.data.xml.pull-parser holding on to head? Turns out, it was the clojure keywords not being GC'd issue |
| 21:18 | arohner | I'm succesfully dorun'ing across all of wikipedia now |
| 21:37 | alandipert | arohner: that's on 1.2? |
| 21:38 | arohner | alandipert: I was having problems on 1.2.0. The keyword GC issue is fixed in 1.2.1 (and trunk) |
| 21:39 | alandipert | arohner: cool, just wanted to make sure it didn't sneak back in |
| 22:22 | carllerche | is it possible to connect a repl to a running process? |
| 22:25 | cemerick | carllerche: if your running process is running a network REPL server (like swank or nREPL), yes |
| 22:26 | carllerche | cemerick: is it sane to run swank and such in production? |
| 22:26 | technomancy | we have swank in production |
| 22:26 | technomancy | it's perfectly reasonable as long as you only listen on localhost |
| 22:27 | cemerick | carllerche: That's a loaded question. You certainly can (I do). |
| 22:27 | scgilardi | if you can arrange to run code in the process somehow, you can open up a repl over a socket. examples: http://sean8223.blogspot.com/2009/06/adding-remotely-accessible-repl-to.html and http://clojure.github.com/clojure-contrib/server-socket-api.html |