2016-04-13
| 01:33 | tolstoy | Why would that reloaded.repl thing, when you call "reset-all", when not changing any code, cause a "namespace not found" issue? |
| 01:36 | tolstoy | Hm. lein clean fixes it? Weird. |
| 02:00 | ilevd | How can I transform enlive node back to html? |
| 02:07 | om | ilevd: if memory serves, enlive-html/html |
| 02:12 | om | ilevd: memory doesn't serve well: it's emit* |
| 02:21 | ilevd | om: thanks, with (apply str .. ) it seems work |
| 02:21 | om | ilevd: I forgot to say it returns a seq |
| 02:22 | om | ilevd: I had to take a look at the a mailbox processor I wrote some time ago |
| 02:29 | ilevd | I think it must be a public lib api method |
| 02:56 | ashnur | so, I am working with mori data structures which is close enough to what you have to ask here, how would you accomplish this? https://gist.github.com/ashnur/34e241049825d1e66ce5519c20c52689 |
| 03:01 | TEttinger | hi ashnur |
| 03:02 | ashnur | hi :) |
| 03:03 | TEttinger | this is uh confusing. I'm not sure why the keys are 1 and 5, and the values "c" and "j" |
| 03:04 | TEttinger | maps in clojure and maybe mori are unsorted when made with the {} literal |
| 03:04 | TEttinger | I think for maps of less than 8 keys the sort order is "usually predictable", but that is an implementation detail on clojure and may not be true for cljs/mori |
| 03:08 | ashnur | keys and values are such because this is example data, the original data is way more confusing with stupid names |
| 03:09 | TEttinger | I just don't see the relationship at all |
| 03:09 | ashnur | and i want a vector back, so that's ordered just fine |
| 03:09 | ashnur | [{1:"c"}, {5: "j"}] this is a list of hashMaps |
| 03:09 | TEttinger | oh there we go |
| 03:09 | TEttinger | I see now |
| 03:10 | ashnur | yeah, i wasted a night to figure out the relationships, there is actually way more data, it's coming from a Java backend |
| 03:11 | TEttinger | it looks up key x in the rec map to get the end result key of 1. in the second half of the data, it looks up key z in rec to get "c" |
| 03:12 | TEttinger | in mori, are rec and order equivalent to "rec" and "order", that is, they're strings but you can omit the quotes? |
| 03:13 | ashnur | this is javascript and the object (hashMap) keys are always strings everywhere |
| 03:13 | ashnur | so I think yes? |
| 03:14 | ashnur | rec has the data from which the keys and values have to be chosen by the value of they key attribute and the put into objects using the order attribute |
| 03:14 | ashnur | so easy to write down in english :)) |
| 03:16 | ashnur | and what's even worse, i simplified this because even the value of the key is actually coming from a list so i have a lookupf function for that |
| 03:16 | ashnur | i love good backend APIs. |
| 03:17 | TEttinger | ,(def data [{ "key" "x", "values" [ {"order" 1, "rec" {"x" 1, "y" 2, "z" 3}}, {"order" 2, "rec" {"x" 5, "y" 7, "z" 9}}]},{ "key" "z", "values" [ {"order" 1, "rec" {"x" "a", "y" "b", "z" "c"}}, {"order" 2, "rec" {"x" "h", "y" "i", "z" "j"}}] ) |
| 03:17 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 03:17 | TEttinger | gah |
| 03:18 | TEttinger | ,(def data [{ "key" "x", "values" [ {"order" 1, "rec" {"x" 1, "y" 2, "z" 3}}, {"order" 2, "rec" {"x" 5, "y" 7, "z" 9}}]},{ "key" "z", "values" [ {"order" 1, "rec" {"x" "a", "y" "b", "z" "c"}}, {"order" 2, "rec" {"x" "h", "y" "i", "z" "j"}}]}] ) |
| 03:18 | clojurebot | #'sandbox/data |
| 03:19 | TEttinger | so that's one problem, there was a missing square bracket I think |
| 03:20 | ashnur | yes, thanks for pointing it out |
| 03:21 | ashnur | fixed the example :) |
| 03:21 | ashnur | i need something like parinfer for javascript :D |
| 03:31 | TEttinger | ,(def data (atom [{ "key" "x", "values" [ {"order" 1, "rec" {"x" 1, "y" 2, "z" 3}}, {"order" 2, "rec" {"x" 5, "y" 7, "z" 9}}]},{ "key" "z", "values" [ {"order" 1, "rec" {"x" "a", "y" "b", "z" "c"}}, {"order" 2, "rec" {"x" "h", "y" "i", "z" "j"}}]}] )) |
| 03:31 | clojurebot | #'sandbox/data |
| 03:33 | TEttinger | ,(def data [{ "key" "x", "values" [ {"order" 1, "rec" {"x" 1, "y" 2, "z" 3}}, {"order" 2, "rec" {"x" 5, "y" 7, "z" 9}}]},{ "key" "z", "values" [ {"order" 1, "rec" {"x" "a", "y" "b", "z" "c"}}, {"order" 2, "rec" {"x" "h", "y" "i", "z" "j"}}]}] ) |
| 03:33 | clojurebot | #'sandbox/data |
| 03:35 | ashnur | i have no idea what's happening |
| 03:35 | TEttinger | I'm workin some magic |
| 03:46 | TEttinger | hooray! |
| 03:46 | TEttinger | ,(let [atm (atom {})] (doseq [{:strs [key values]} data] (doseq [{:strs [order rec]} values] (swap! atm assoc-in [order](rec key)))) @atm) |
| 03:46 | clojurebot | {1 "c", 2 "j"} |
| 03:46 | TEttinger | it doesn't quite work yet |
| 03:46 | ashnur | holy shit that's longer than expected |
| 03:47 | ashnur | at least 3-4 things i never used |
| 03:47 | ashnur | from that list |
| 03:58 | amalloy | why on earth would you use an atom for that |
| 03:58 | amalloy | it's just a reduce over the thing you're currently holding in the atom |
| 03:59 | TEttinger | ,(let [atm (atom [])] (doseq [{:strs [key values]} data] (doseq [{:strs [order rec]} values] (swap! atm update-in [(dec order)] #(vec (concat % [(rec key)]))))) (mapv #(apply hash-map %) @atm)) |
| 03:59 | clojurebot | [{1 "c"} {5 "j"}] |
| 03:59 | TEttinger | I'm kinda brain-blocked right now |
| 03:59 | TEttinger | I'm currently helping 3 different people, two of them in a java channel |
| 04:02 | TEttinger | amalloy, is it just a reduce though? his data seems to call for updating different parts of the returned value based on the value of the order key |
| 04:02 | TEttinger | I guess anything CAN be a reduce |
| 04:03 | amalloy | you turn the doseq into a nested (for), producing a list of operations to perform |
| 04:03 | amalloy | and then you reduce over those, doing the swaps as pure functions on the accumulator |
| 04:04 | amalloy | or really it looks like it's so simple you don't even need to reduce, you can just (into {} (for ...)) |
| 04:04 | TEttinger | the underlying algorithm isn't what I'd call simple |
| 04:04 | TEttinger | it might work |
| 04:04 | TEttinger | try it |
| 04:04 | amalloy | you're really talking about this snippet? (let [atm (atom {})] (doseq [{:strs [key values]} data] (doseq [{:strs [order rec]} values] (swap! atm assoc-in [order](rec key)))) @atm) |
| 04:05 | TEttinger | the data that it needs to output is weird |
| 04:05 | amalloy | (into {} (for [{:strs [key values]} data, {:strs [order rec]} values] [order (rec key)])) |
| 04:05 | amalloy | i don't see how that's weird at all |
| 04:05 | TEttinger | nope |
| 04:06 | TEttinger | not correct |
| 04:06 | TEttinger | ,(into {} (for [{:strs [key values]} data, {:strs [order rec]} values] [order (rec key)])) |
| 04:06 | clojurebot | {1 "c", 2 "j"} |
| 04:06 | TEttinger | he needs the keys to be 1 and 5, looked up in the "x" key for the first map |
| 04:06 | TEttinger | [{1 "c"} {5 "j"}] is the desired output |
| 04:07 | amalloy | i took the first version you wrote, which as you say doesn't work yte |
| 04:07 | TEttinger | yeah, I posted a working one |
| 04:07 | TEttinger | ,(let [atm (atom [])] (doseq [{:strs [key values]} data] (doseq [{:strs [order rec]} values] (swap! atm update-in [(dec order)] #(vec (concat % [(rec key)]))))) (mapv #(apply hash-map %) @atm)) |
| 04:07 | clojurebot | [{1 "c"} {5 "j"}] |
| 04:07 | amalloy | and wrote something equivalent without a doseq or an atom |
| 04:09 | amalloy | it would probably be a good exercise for you to perform the same transformation i did on your unfinished solution |
| 04:09 | amalloy | there's nothing weird or special about the requirements, and it transforms into a reduce/for perfectly well |
| 04:10 | TEttinger | it just seems kinda... imperious to not even address ashnur who asked the question and only critique the solution. I mean it could be better, and I'll do the improvement when I have time |
| 04:13 | amalloy | it was unnecessarily rude of me to lead with "why on earth would you do that" |
| 04:15 | amalloy | but i'm not especially interested in the 0th-order thing of answering every specific question in #clojure myself. i actually answered a *very* similar question earlier tonight, which you can see if you look through the logs for bmuk's question |
| 04:15 | amalloy | rather, i want to improve the answers given by the channel whether i'm here or not, which means code reviews of answers that could be better |
| 04:16 | amalloy | in particular from regulars who i would expect to be recommending functional solutions |
| 04:16 | TEttinger | I was kinda thrown off by the initial figuring out the data |
| 04:16 | TEttinger | this is what I started with: https://gist.github.com/ashnur/34e241049825d1e66ce5519c20c52689 |
| 04:17 | amalloy | yeah, figuring out someone's crazy input format and how they intend it to be related ot their output is not easy |
| 04:18 | TEttinger | and that's the cleaned up version too... apparently the server-side code outputs even nastier results |
| 04:24 | ashnur | yeah, the Java backend guy just dumps json on me from Hibernate |
| 04:24 | ashnur | and this is some virtual tables stored in pgsql. tables stored in tables :D |
| 04:25 | ashnur | and thanks for the help TEttinger |
| 04:26 | TEttinger | I'd take a look at what amalloy had for an improvement that should both perform better and scale more cleanly to more complex data |
| 04:26 | ashnur | i will do that too, i am asking these questions because the way clojure handles data seems really down to earth and want to practice it |
| 04:27 | ashnur | need to leanr it eventually :) |
| 04:31 | alexelcu | @tobyirc @dysfun @jjmalina Hello, I'm a Scala developer and I like Clojure as well and trying to learn more. There's lots to learn from Scala though, things that you won't learn from Clojure and the reverse is also true and neither of them is a dead-end. Scala follows idioms and design patterns that are more common in the very static languages from the ML family / Haskell / Idris, etc. For example Scala developers are very much into modeling of types and |
| 04:36 | TEttinger | ah! |
| 04:36 | TEttinger | ashnur: |
| 04:36 | TEttinger | ,(mapv #(apply hash-map (reverse %)) (reduce (fn [coll [k v]] (update-in coll [k] conj v)) [] (for [{:strs [key values]} data, {:strs [order rec]} values] [(dec order) (rec key)]))) |
| 04:36 | clojurebot | [{1 "c"} {5 "j"}] |
| 04:37 | TEttinger | thanks amalloy, for a firm slap back to functional programming :) |
| 04:37 | amalloy | haha, you're welcome. sorry for not doing it as politely as i could |
| 04:38 | TEttinger | nah I should be used to your superior technical skills seeming like superiority sometimes |
| 04:39 | TEttinger | I'm trying to remember if you work at a place I know of |
| 04:40 | TEttinger | facebook, groupon, what is now IBM as clients, nice |
| 04:41 | TEttinger | heh, and gfredericks works at or with Groupon, I wonder if there's a connection there |
| 05:24 | sobel | amalloy: i'm so with you on trying to be able to answer every question. i was a regular helper on #postgresql for years and it did more for rounding out my knowledge than pretty much anything else i did |
| 07:16 | gizmo385 | So in the application that I'm working with, I'm trying to update a global state value. I've tried both atoms and dynamic variables, but no matter what I do, I can't seem to get the value to update until after the entire execution thread terminates? |
| 07:16 | gizmo385 | For example, if I run my functions in the REPL and check the values of the atom/global AFTER the function finishes in the REPL, then the value is what I expect |
| 07:16 | gizmo385 | But If I try to check the value mid-execution, it never changes. What gives? |
| 07:17 | gxx3 | is clojure as interactive as CL with slime? |
| 07:17 | gizmo385 | Any ideas on how to properly structure this so that it updates the variables immediately after calling set!, swap!, or whatever function I need to call to update the var |
| 07:22 | gizmo385 | I've also tried it with refs and that isn't working either? |
| 07:27 | Kneiva | gizmo385: can you show some code? |
| 07:28 | kwladyka | gizmo385 i wrote article in that topic a few days ago clojure.wladyka.eu - maybe it will help you. |
| 07:30 | gizmo385 | Yeah, let me put it in in a pastebin |
| 07:34 | ridcully | gizmo385: i ask, because we had this yesterday and misery loves company: are you actually realizing the result when you modify your atom? if your manipulation happens in something lazy it might not happen until you print it in the repl e.g. |
| 07:35 | gizmo385 | @Kneiva @kwladyka @ridcully Here is the code that describes the state with a use example on the bottom: http://pastebin.com/96HmXui1 |
| 07:36 | gizmo385 | If I actually call the function I have at the bottom of the paste in the REPL, the value on :failure comes out to false even if raise-error! gets called |
| 07:36 | gizmo385 | But, if I check the value of the error (by calling error?) in the REPL after the described function /finishes/ then the value is true |
| 07:36 | gizmo385 | So I would think that something is happening lazily, but I can't figure out what? And I can't find any documentation on how to force the state change |
| 07:37 | gizmo385 | @Kneiva @kwladyka @ridcully Here is the paste again incase all the disconnections threw it out of the screen: http://pastebin.com/96HmXui1 |
| 07:44 | kwladyka | gizmo385 i don't have too much time now but try :failure @error-occured? |
| 07:46 | kwladyka | eventually you don't call raise-error! before that |
| 07:46 | gizmo385 | @kwladyka Just retried it, no dice |
| 07:46 | kwladyka | just use println in this function to see when it is run |
| 07:46 | gizmo385 | But in a let, the forms bind in order. Could it not be evaluating the call to (parse ...) until I at it in the map? |
| 07:47 | gizmo385 | Because I know that raise-error! is getting called at some point since the print statement in raise-error! runs |
| 07:47 | gizmo385 | I tried the @error-occured to no avail :/ |
| 07:50 | gizmo385 | Got it. The function call isn't getting run. If I print the parse-result and then check the value, it runs |
| 07:50 | gizmo385 | err it gets the right value |
| 07:52 | gizmo385 | I feel like there should be a macro or function that I can use that forces non-laziness? |
| 07:53 | MJB47 | (doc doall) |
| 07:53 | clojurebot | "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time." |
| 07:58 | gizmo385 | @MJB47 That certainly help :) |
| 07:58 | gizmo385 | Thanks a bunch everyone :D |
| 08:44 | mpenet | gxx3: yes, cider is an equivalent of slime for clojure |
| 08:46 | mpenet | gxx3: clojure-mode actually used slime internally in the past, until it was replaced by something more customizable/upgradable for clojure. So you'll find a ton of keybinding/features inherited from slime for instance |
| 09:45 | asdf12z_ | do a lot of people use speclj ? bdd test framework or the built in for clojure ? |
| 09:45 | asdf12z_ | can't seem to mark a test pending in clojure.test |
| 10:28 | Guest35203 | Anyone have any recommendations on schedulers? I'm looking at using Chime or Quartzite |
| 10:54 | seangrove | Hey all, struggling with an error, "java.lang.IllegalArgumentException: Cannot open <nil> as a Reader., compiling" |
| 11:38 | justin_smith | Guest32455: I've had good luck with just using the ScheduledThreadPoolExecutor which comes with the jvm https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html |
| 11:39 | Russell- | Oh yes, there is. http://stackoverflow.com/questions/10957257/clojure-debugging-println-line-number-and-file-name |
| 11:41 | justin_smith | asdf12z_: I am pretty sure clojure.test has no concept of "pending", in fact I have no idea what a "pending test" would be |
| 11:42 | Glenjamin | a test title with either no implementation, or one that's known to not be working |
| 11:43 | Glenjamin | often a TODO as a testcase, that doesn't fail the build |
| 11:54 | gigasquid | https://gist.github.com/Medeah/2bc6e92b86ae7e8abc14 |
| 11:55 | justin_smith | (inc gigasquid) |
| 11:55 | justin_smith | nice |
| 12:12 | russellw | I'm confused about the macro in the accepted answer in http://stackoverflow.com/questions/10957257/clojure-debugging-println-line-number-and-file-name - in particular about printing the name versus value of the argument |
| 12:12 | russellw | ~(pr-str x) prints the name of the argument but ~x prints the value. How can that be? |
| 12:12 | clojurebot | Excuse me? |
| 12:12 | russellw | I would have expected either both to print the name or both to print the value |
| 12:16 | justin_smith | russellw: I bet macroexpand would help |
| 12:18 | justin_smith | ,(defmacro thing-and-string [x] `(list ~(pr-str x) ~x)) |
| 12:18 | clojurebot | #'sandbox/thing-and-string |
| 12:19 | justin_smith | ,(macroexpand-1 '(thing-and-string +)) |
| 12:19 | clojurebot | (clojure.core/list "+" +) |
| 12:19 | justin_smith | russellw: at the time of expansion, + is just a symbol, so emitting the string emits the string of that symbol. The value emitted by the macro is then evaluated when it is run. |
| 12:21 | russellw | justin_smith, oh! That makes sense, thanks |
| 12:22 | justin_smith | russellw: a big a-ha moment for me about macros is that you could just return a list of symbols, and that would be the code that gets compiled |
| 12:22 | justin_smith | ,(defmacro demo [] (list 'println "hello" "world")) |
| 12:22 | clojurebot | #'sandbox/demo |
| 12:22 | justin_smith | ,(demo) |
| 12:22 | clojurebot | hello world\n |
| 12:23 | justin_smith | when we use helpful things like ` we can forget that is all they are doing sometimes |
| 12:23 | russellw | Yeah, I guess with practice you get used to keeping the two levels of indirection straight |
| 12:26 | Glenjamin | ,(defmacro lemme-see [x] (list 'list (name x) x))) ; attempt to get the same effect without ` |
| 12:26 | clojurebot | #'sandbox/lemme-see |
| 12:26 | Glenjamin | ,(macroexpand '(lemme-see +)) |
| 12:26 | clojurebot | (list "+" +) |
| 12:27 | justin_smith | Glenjamin: nice |
| 12:28 | justin_smith | ,(defmacro another-thing [x] (list 'list (name x) (type x) x))) |
| 12:28 | clojurebot | #'sandbox/another-thing |
| 12:28 | justin_smith | ,(another-thing +) |
| 12:28 | clojurebot | ("+" clojure.lang.Symbol #object[clojure.core$_PLUS_ 0x2ae38b7a "clojure.core$_PLUS_@2ae38b7a"]) |
| 12:30 | Glenjamin | ,(lemme-see +) |
| 12:30 | clojurebot | #error {\n :cause "Unable to resolve symbol: lemme-see in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: lemme-see in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: lemme... |
| 12:30 | Glenjamin | ,(defmacro lemme-see [x] (list 'list (name x) x))) |
| 12:30 | clojurebot | #'sandbox/lemme-see |
| 12:30 | Glenjamin | ,(lemme-see +) |
| 12:30 | clojurebot | ("+" #object[clojure.core$_PLUS_ 0x6295c0bb "clojure.core$_PLUS_@6295c0bb"]) |
| 12:31 | Glenjamin | ah, earlier i got a read-eval error, but i think that was because of a `~x |
| 12:31 | Glenjamin | ,`~x |
| 12:31 | clojurebot | #error {\n :cause "Unable to resolve symbol: x in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x in this context"\n ... |
| 12:54 | WorldsEndless | I need to do some XML templating. Anyone done this? Recommendations for libraries or approaches? |
| 12:55 | justin_smith | WorldsEndless: hiccup works decently for xml templating (though it doesn't specifically target it, it generates it OK if you use the tags right) |
| 12:55 | justin_smith | if you want to programmatically modify the structure clojure.data.xml is nicer though |
| 12:56 | WorldsEndless | Okay; clojure.data.xml was what I was looking at |
| 12:56 | WorldsEndless | I don't need to modify the structure but just fill in data values |
| 12:57 | justin_smith | yeah, I would use hiccup for that personally |
| 13:01 | WorldsEndless | What woudl you read the template with? Hickory? |
| 13:02 | justin_smith | WorldsEndless: typically with hiccup the template is inside some templating function, not in a dedicated templating file |
| 13:03 | justin_smith | WorldsEndless: I have not tried hickory |
| 13:03 | gmcramm | WorldsEndless: Do you already have an xml template that you're trying to modify, or are you creating new ones? |
| 13:03 | WorldsEndless | I have an XML template used for Apache FOP |
| 13:03 | WorldsEndless | I need to fill in values |
| 13:04 | justin_smith | oh, that's different, I misunderstood |
| 13:04 | gmcramm | Ah. IMO hickory might be a better bet then |
| 13:04 | gmcramm | You could also look at enlive |
| 13:04 | WorldsEndless | I like enlive, but hadn't thought of using it on xml |
| 13:06 | gmcramm | It should work just fine with xml. At least, I don't see why it wouldn't. |
| 13:17 | WorldsEndless | Oh. Enlive actually has an xml-resource function. Nice! |
| 14:34 | sdegutis | Are there any other "escape-html" functions besides in Hiccup? |
| 14:44 | sdegutis | Is there a function in clojure.core like this? (fn [f x] (if (f x) x)) |
| 14:44 | sdegutis | some-> comes to mind but it's not quite right since it returns (f x) if it's non-nil, rather than x itself |
| 14:47 | sdegutis | Good afternoon. |
| 14:59 | amalloy | sdegutis: incredibly that function exists, not in clojure itself, but rather in every clojure library ever written |
| 15:05 | sdegutis | amalloy: yeah that's what I thought |
| 15:05 | sdegutis | amalloy: what do you call it? |
| 15:18 | tolstoy | When? |
| 15:33 | sobel | that's coalesce |
| 15:33 | sobel | popular sql function |
| 16:46 | ben_vulpes | how do i use (.. class method method get-first-thinger) in interopland? |
| 16:47 | ben_vulpes | i want to call .get(0) basically |
| 16:50 | Glenjamin | ben_vulpes: most use of .. can be replaced with ->> which imo is a bit clearer (as it's more common) |
| 16:51 | amalloy | not ->>, but -> |
| 16:51 | amalloy | and *all* uses |
| 16:51 | Glenjamin | ack, yes |
| 16:51 | cortexman | tf |
| 16:51 | Glenjamin | ,(-> (ArrayList. [(ArrayList. [1])] (.get 0) (.get 0)) |
| 16:52 | Glenjamin | damn, missed a paren |
| 16:52 | cortexman | anyone else us a cider clojurescript repl? |
| 16:52 | Glenjamin | ,(-> (ArrayList. [(ArrayList. [1])]) (.get 0) (.get 0)) |
| 16:52 | amalloy | Glenjamin: or just (-> [[1]] (.get 0) (.get 0)) |
| 16:52 | cortexman | i've noticed that when there are a lot of keyed reagent objects on the page it just times out a lot |
| 16:52 | Glenjamin | oh right, i forget vectors have methods |
| 16:53 | Glenjamin | also, clojurebot appears to be absent :( |
| 16:55 | amalloy | Glenjamin: importantly, they implement List |
| 16:55 | amalloy | which is why (ArrayList. [1]) also works |
| 16:55 | Glenjamin | yeah, i was thinking in java mode |
| 16:56 | Glenjamin | presumably (nth (ArrayList. [1]) 0) also works |
| 16:56 | amalloy | yes |
| 16:58 | Glenjamin | oh, huh - nth also works on regex match objects |
| 16:59 | alexei___ | For "public BoxUser.Info getInfo(String... fields)" is there anything special about calling this kind of methods? (.getInfo box-user) says "No matching field found" |
| 17:00 | ben_vulpes | thanks Glenjamin, amalloy |
| 17:00 | ridcully | iirc you need to pass an empty String[] |
| 17:01 | ridcully | it's ok to call getInfo() in java, but not in clojure |
| 17:01 | Glenjamin | hrm, i thought it was documented on the java iterop page, but yeah - Type... is actually sugar for an array parameter |
| 17:02 | alexei___ | Ok, thanks: ^BoxUser$Info user-info (.getInfo (BoxUser/getCurrentUser api) (into-array String [])) |
| 17:02 | alexei___ | seems to work |
| 17:06 | edaq | Hey thought I would mention a new site |
| 17:06 | edaq | neuro-linguistic-programming.angelfire.com |
| 17:06 | edaq | it is an interesting topic |
| 17:18 | russellw | I noticed that when I run a CPU intensive clojure program, even when I haven't done anything to multithread it, Windows task manager says it's using two, three or even four CPU threads - a pleasant surprise! Is this because the garbage collector is running in separate threads? |
| 17:25 | arkh | russellw: depends on your code but garbage collection, future, send and send-off for agents, core async, etc. use their own threads or thread pools |
| 17:25 | russellw | Right, I wasn't even using any of the other things, though I was doing a lot of memory allocation |
| 17:26 | Glenjamin | when I did something similar, I found that GC was using the other cores |
| 17:26 | russellw | This is good, it means you can get at least some benefit from multiple CPU cores without having done any multithreading in your code |
| 17:26 | {blake} | OK, given a list where some of the keys are case-insensitive duplicates, provide a consisten way to turn those keys into case-insensitive uniques. Like '(:abra :cadabra :Abra :ABRA) could become '(:abra :cadabra :Abra1 :ABRA4). |
| 17:26 | Glenjamin | you might want to look into reducers/fold if you do want to parallelise the computation itself |
| 17:27 | {blake} | (I'm counting upper-case letters to give the unique number after the keyword. In case the list isn't always in the same order.) |
| 17:27 | russellw | Glenjamin, thanks, I'll keep that in mind |
| 17:27 | {blake} | (And the list is created from keys in a map.) |
| 17:28 | Glenjamin | {blake}: some sort of loop where you keep a counter and a set of lowercased keys-so-far |
| 17:29 | {blake} | Glenjamin: Yeah, that's what I started with. But it's getting uglier than I like. I was thinking of building a map like {:Abra :Abra1, :ABRA :ABRA4...} |
| 17:29 | Glenjamin | what is the real goal, this sounds like a bit of a weird thing to want to do |
| 17:30 | {blake} | Converting Mongo to SQL. Everything was going so well, until I discovered I had a map with keys like "401k" and "401K". :/ |
| 17:30 | Glenjamin | and SQL is case sensitive? |
| 17:30 | Glenjamin | erm, insensitive |
| 17:31 | {blake} | Glenjamin: Yes. INsensitive. |
| 17:31 | russellw | {blake}, I think the job will become easier if you drop the requirement to preserve case |
| 17:32 | {blake} | russellw: There isn't really a requirement to preserve case. |
| 17:32 | russellw | {blake}, good, then a map like the one you have in mind, converting the keys to lowercase first, should do the job |
| 17:33 | kenrestivo | if i were to while but needed the results of the test, i.e. to log it, what should i use? |
| 17:33 | Glenjamin | why does a single entity have keys for 401k and 401K ? |
| 17:34 | kenrestivo | i.e. (let-while [foo (some-test)] (log foo)) |
| 17:34 | russellw | Converting the keys to lowercase after lookup, that is. And I suppose any time a system allows a degree of freedom, bad data will creep in |
| 17:34 | russellw | Though it might be worth investigating whether those keys should actually be considered distinct |
| 17:34 | {blake} | Yeah, this is a...well, this mongo database has been through a lot. |
| 17:34 | {blake} | Some of the results are serialized with nippy. And some are not. |
| 17:35 | {blake} | The date formats change throughout. |
| 17:36 | kenrestivo | ah (while (when-let [d (some-test)] (log d) true)) seems to work |
| 17:36 | {blake} | By which I mean, sometimes they're dates, sometimes they're strings. |
| 17:37 | ridcully | philosophical |
| 17:48 | will_sm | Created a webapp using figwheel for some school thing |
| 17:48 | will_sm | My server should be able to handle 200+ people refreshing every 10 seconds right? |
| 17:48 | will_sm | 3kb of data each time |
| 17:50 | russellw | will_sm, that's not a terribly heavy load so I would think it shouldn't be a problem. (Caveat, I've never heard of figwheel before) |
| 17:50 | ridcully | will_sm: you are running figwheel as your primary server? are you asking because you see some problem? |
| 17:51 | will_sm | russellw, figwheel is used to get automatic reloading of clojurescript code. The server jetty I think |
| 17:51 | russellw | I'm assuming you're asking because it's not actually keeping up with the load |
| 17:51 | will_sm | no problem, I have things working on my end, and I've never done anything that is not tiny scale |
| 17:51 | russellw | Oh, well that's good then |
| 17:52 | will_sm | so clojure is easy to scale in general right? |
| 17:52 | russellw | I'm not yet in a position to say for definite, but thus far my impressions of it are good |
| 17:53 | russellw | The JVM is the world's best heavy duty runtime, and clojure seems to make good use of it |
| 17:53 | russellw | Just don't use instaparse for non-tiny files :) |
| 17:53 | ridcully | figwheel is a productivity drug |
| 17:54 | Glenjamin | did you get a parser working russellw ? |
| 17:54 | russellw | Glenjamin, the author got back to me, said it was really only intended for files on the tens of kilobytes scale, so I'll probably just write the parsers by hand |
| 17:55 | will_sm | figwheel + reagent has been a great experience |
| 17:55 | will_sm | making a ring handler, not so much, but as expected from being an web noob |
| 17:56 | Glenjamin | did you look at https://github.com/ericnormand/squarepeg at all? |
| 17:57 | russellw | no, trying one parser generator was fun, trying two in succession would be not so much fun to my way of thinking. It's not like writing recursive descent parsers by hand is all that difficult after all :) |
| 17:58 | Glenjamin | my favourite approach is to have the state parameter be the function |
| 17:58 | russellw | How do you mean? |
| 18:00 | Glenjamin | here's a JS example: https://github.com/creationix/mine/blob/master/mine.js#L130 |
| 18:01 | russellw | ah! That is elegant |
| 18:02 | russellw | I usually just interface the tokeniser and parser by having a global/module scope variable for the current token. in clojure, that would be done with the tokeniser executing (def tok ...) to set the current token, right? |
| 18:03 | Glenjamin | i'd write it as a loop recur I think |
| 18:03 | Glenjamin | or maybe closure over an atom, wouldn't use a global |
| 18:04 | russellw | Also iirc the Java standard library has a line number reader that keeps track of the current line number in the input for you, which I can use |
| 18:04 | russellw | Not that keeping track of the current line number is difficult, but it's one of those chores that it's all the nicer to have done for you |
| 18:04 | {blake} | Got an old clojure web app, which hasn't been deployed in a while. When I try to run it via "java -jar", I get "Could not find or load main class myapp.handler.main." Which, yeah, it's not called "main" so I can see why it wouldn't be found. What I don't know is why it's looking for it "all of a sudden". |
| 18:05 | russellw | {blake}, maybe it was previously run with some script or something that pointed it at the right thing? |
| 18:06 | {blake} | russellw: So, I could pass it a parameter to point to the right thing, maybe? |
| 18:06 | russellw | {blake}, I would think so |
| 18:06 | amalloy | ,clojure.lang.LineNumberingPushbackReader |
| 18:07 | amalloy | well, rip clojurebot. that exists, anyway |
| 18:08 | russellw | amalloy, ah, sweet, thanks! |
| 18:09 | cortexman | can you capture the output of pprint in a variable? it accepts a writer option |
| 18:09 | cortexman | oh, with-out-str looks promising :) |
| 19:02 | Kingmob | Anybody have time for a namespace/file/loading question? Does anyone know of a way to force loading of files? I have multimethods whose definitions are in multiple files, but nothing directly "require"s them, so the files aren't being loaded, it seems. |
| 19:04 | amalloy | you force files to be loaded by requiring them |
| 19:04 | amalloy | there is no "i need this file to be loaded but i don't want to load it explicitly" mechanism |
| 19:05 | Kingmob | I'd originally assumed all files added to a project/jar were loaded, not lazy-loaded. |
| 19:06 | Kingmob | ..and was hoping that defining a defmethod in other files would get picked up, since nothing *other* than the defmethod is necessary elsewhere |
| 19:07 | Kingmob | Is there a good way to say "require every file in this directory/namepsace"? |
| 19:08 | amalloy | no |
| 19:09 | {blake} | ,(def r {:abra 1 :cadabra 2 :Abra 3 :ABRA 4}) |
| 19:10 | Kingmob | ok, thx |
| 20:30 | sdegutis | Oh man. Guys. |
| 20:30 | sdegutis | justin_smith: ping |
| 21:32 | asdf12z_ | whenever i write a let binding, often times i want to say... (let [term (if encode (url-encode term) term)] is there an easier way to say that? like update term if x is true only? instead of a if else |
| 21:43 | justin_smith | sdegutis keeps logging off, I just got my room at the hotel where clojure/west is happening |
| 21:46 | iovechildren | my gf doesnt know but i fuck her 2 autistic 16 year old girls is that bad ? |
| 21:47 | iovechildren | putting my dick inside them is so fun |
| 21:47 | iovechildren | i hope we dont break up |
| 21:49 | slideonmyp_enis | i like to fuck my gfs autistic kids when she isnt around |
| 21:50 | slideonmyp_enis | my dick gets so hard |
| 21:51 | slideonmyp_enis | autistic kids are so dumb |
| 21:51 | slideonmyp_enis | stupid fuckers |
| 21:51 | slideonmyp_enis | i like taking them to victorias secret |
| 21:51 | slideonmyp_enis | and pimping them out |
| 21:51 | slideonmyp_enis | then fucking them |
| 21:52 | slideonmyp_enis | god i am so horny |
| 21:52 | slideonmyp_enis | i am going to see her tonight |
| 21:52 | slideonmyp_enis | going to buy her tickets to a play lolol |
| 21:52 | slideonmyp_enis | then when shes gone im gonna fuck them ! |
| 21:53 | slideonmyp_enis | does any1 here talk |
| 21:53 | slideonmyp_enis | ? |
| 21:53 | slideonmyp_enis | why doesnt any1 here talk |
| 21:53 | slideonmyp_enis | dick in jailbait |
| 21:53 | slideonmyp_enis | dick `n`jailbait |
| 21:53 | slideonmyp_enis | lol |
| 21:54 | slideonmyp_enis | its not abuse if it is consent ! |
| 21:54 | slideonmyp_enis | they think it is part of sex education |
| 21:54 | slideonmyp_enis | i teach them everything |
| 21:54 | slideonmyp_enis | ughh |
| 21:54 | slideonmyp_enis | 30 more minutes |
| 21:54 | slideonmyp_enis | until she goes away h |
| 21:55 | slideonmyp_enis | slide my dick into little children, |
| 21:55 | slideonmyp_enis | here them moan, |
| 21:55 | slideonmyp_enis | beg for me to stop, |
| 21:55 | slideonmyp_enis | but i dont |
| 21:55 | slideonmyp_enis | daddys gonna fuck u up |
| 21:55 | slideonmyp_enis | like the little slut |
| 21:55 | slideonmyp_enis | u are |
| 21:56 | slideonmyp_enis | shes on my lap now |
| 21:56 | slideonmyp_enis | my dick is so hard |
| 21:57 | slideonmyp_enis | *strokes daughters hair * |
| 22:00 | slideonmyp_enis | *hits daughter i face ** |
| 22:00 | slideonmyp_enis | yoga pants on children are so hot |
| 22:01 | slideonmyp_enis | slide my dick into little children, |
| 22:01 | slideonmyp_enis | slide my dick into little children, |
| 22:01 | slideonmyp_enis | slide my dick into little children, |
| 22:01 | slideonmyp_enis | slide my dick into little children, |
| 22:01 | slideonmyp_enis | slide my dick into little children, |
| 22:01 | slideonmyp_enis | slide my dick into little children, |
| 22:01 | slideonmyp_enis | slide my dick into little children, |
| 22:02 | demophoon | amalloy_: ^ |
| 22:36 | @amalloy | demophoon: there's not much i can do with a webchat user who doesn't mind closing the tab and logging back in with a new username. i banned that guy once, and he was back 30 seconds later. the only thing you can really do is ignore them |
| 22:41 | slideonmyp_enis | ahhh |
| 22:41 | slideonmyp_enis | that was a refreshing fuck |
| 22:41 | slideonmyp_enis | would u guys be interested in recordings on skype? |
| 22:42 | slideonmyp_enis | i can upload them to TOR |