#clojure logs

2015-08-08

00:35Kwhy_NotInfo
02:56tmtwdhttp://pastebin.com/8bzEsdWr
02:57tmtwdCan anyone explain this function to me?
03:00justin_smithtmtwd: that looks like a react component
03:01tmtwdjustin_smith, is that what props is or is that an observation?
03:01tmtwd:)
03:02tmtwdbut yeah, it is
03:02tmtwdhm, maybe there is something about reagent I'm just not getting
03:25oddcullytmtwd: the function returns a function, that takes the props. not knowning reagent, i'd say it gets called to render the component (later) and the props come from reagent (later)
03:26tmtwdoh, I see, the anonymous function is being returned, then it gets passed props, which then gets evaluated
03:27tmtwdwhat does {:keys [title on-save on-stop]} do?
03:29oddcullydestructuring
03:29arav93How do I start off sampling clojure.zip. The entire namespace and functions in it seem really confusing!
03:30oddcully~destructuring
03:30clojurebotdestructuring is http://clojure.org/special_forms#binding-forms
03:30oddcullyi knew it!
03:35tmtwdoddcully, thanks, I could not find that for some reason
03:37tmtwdhow come this returns nil? ( {:keys [yolo]} {:yolo 23})
03:38tmtwdit has to be in scope or something?
03:39oddcullybecause you call map on a map
03:39oddcullyyou lack the let
03:39tmtwdoh
03:39oddcully,(let [{:keys [x]} {:x 666}] x)
03:39clojurebot666
03:40tmtwdohhh
03:40tmtwdodd
03:40oddcullys/odd/awesome!/
03:41tmtwdhehe, what is s?
03:43clarkencielhttp://vim.wikia.com/wiki/Search_and_replace
05:17crocketCan clojure be used to create something like https://github.com/phpsysinfo/phpsysinfo ?
09:32Bronsaambrosebs: ping
09:52Bronsaambrosebs: I saw your ast-ref commits -- thanks! in case you find something else that's not updated, please run spec/buildref.sh so that the html doc gets rebuild too
11:30Arcaed0xHi there...?
11:39xcthulhuHey, is there a nifty way of getting a random free port?
11:40xcthulhu(I’m doing integration tests for a webserver)
11:40xcthulhuHey cemerick, how do I get a random free port so I can do little integration tests with a real webserver?
11:40xcthulhuWith, say, http-kit or whatever
11:42cemerickxcthulhu: pass 0 for port number, that will allocate a random available port
11:42xcthulhuSweet how do I grab the port once it picks a random one?
11:43xcthulhu(I recognize there are docs)
11:45xcthulhuHere’s where you can grab it: https://github.com/http-kit/http-kit/blob/master/src/org/httpkit/server.clj#L32
11:45xcthulhu(for all of you future google people who stumble across this IRC chat)
12:14weebzdoes anyone know off the top of their head how to get cider in emacs to not have errors/exceptions display in a new buffer? it's a little annoying constantly closing and switching out of that buffer
12:15weebzi'm not sure where else it could be displayed, just looking to have something that isn't as interrupting if that makes sense?
12:17wasamasait can pop it to a window
12:18justin_smithweebz: best fix is winner mode http://emacswiki.org/emacs/WinnerMode
12:18justin_smithweebz: with winner mode you can undo any random popped up anything easily
12:29weebzwasamasa, so it'll open in a new window that I can just C-x 0?
12:29justin_smithweebz: that would be c-x 5 0
12:29justin_smithit's easier to turn on winner-mode and hit C-c <left-arrow>
12:33weebzI'm a little confused how the undo is working. My issue right now is that I'm working with 2 windows (one source code, one REPL), and when I type an error in the REPL it opens up the error buffer in the source code window
12:34weebzwinner undo just closes the window when I hit C-c <left>
12:34justin_smiththen your history is not set up right...
12:34justin_smithtry starting with one window, then splitting, then opening the right buffer in each half
12:34weebzvery likely, I'm still quite new to Emacs
12:35justin_smithafter you do all that, C-c left will take you back to the original window / buffer setup you wanted
12:35justin_smithalso you can use C-c left / C-c right repeatedly to get all window / buffer configurations back as you like
12:37weebzit does what I want if I switch back to the REPL window and hit C-c <left>
12:38weebzbut if I hit C-c <left> while the cursor is in the error window/buffer it reverts both windows to the source code buffer
12:38justin_smithweird...
12:38justin_smithwhat about just hitting q when the error buffer pops up?
12:38wasamasaweebz: no, q suffices
13:28jonathanjhrm, manifold.stream/put! returns synchronously?
13:29jonathanjis there a case where one might want to wait one put to complete before doing the next?
13:29jonathanji guess they will appear on the stream in the order they were put so getting the order mixed up is probably unlikely, and anything else is probably application specific
13:36jonathanjhrm
13:45jonathanji have a seq of strings ["a" "b" "c" "d"] i'd like to join all but the last with " " and the last with ": "
13:45jonathanji'm not quite sure how to efficiently construct this, i'd also like to avoid using (count)
13:46jonathanj(interleave) and (repeat) seem like they might work but i'm not sure how to get the special case separator at the end
13:50justin_smithjonathanj: butlast / last?
13:50oddcully,(let [l ["a" "b" "c"]] (str (clojure.string/join " " (butlast l)) ": " (last l)))
13:50clojurebot"a b: c"
13:50tmtwdcider is giving me an error of input not complete and will freeze up
13:50tmtwdhow do I quit the current "input"?
13:50jonathanjit probably doesn't actually matter for my case but i was trying to avoid those because they talk about linear time
13:51justin_smithjonathanj: then use a vector and peek and pop which are much faster
13:52justin_smith,(let [l ["a" "b" "c"]] (str (clojure.string/join " " (pop l)) ": " (peek l)))
13:52clojurebot"a b: c"
13:52justin_smithdoes not work with lazy-seqs, and does not work as you would expect with lists
13:53oddcullypopl and peekl could be a cartoon show
13:53jonathanjjustin_smith:great, that would work perfectly for my use case
13:56tmtwd(without restarting cider, that is)
13:56justin_smithtmtwd: C-cC-c should cancel the current input
13:56tmtwdjustin_smith, :) thansk
14:00justin_smithjonathanj: of course creating a vector is linear time
14:00jonathanjjustin_smith: i find myself wondering if there is a nice solution with lazy seqs without last/butlast
14:01justin_smithjonathanj: a recursive function on the lazy-seq could do it
14:02justin_smithit would involve testing if you are at the next-to-last item on each iteration, and using a stringbuilder if you want speed (or a bunch of intermediate strings if you don't care about speed)
14:05tmtwdAh, for some reason cider-repl-kill-input just works for me
14:05jonathanji keep forgetting this, but what is this command called: (x [1 2] [3 4]) => [[1 3] [2 4]]?
14:06jonathanj(in Python it's called zip)
14:06oddcullymap vector would result in this
14:07waynrcan anyone point to an example of using clj-logging-config to set logging configuration dynamically?
14:07jonathanjoddcully: ah, true, thank you
14:08oddcullybut bet there is an easier way i forgot
14:09amalloyoddcully: nope
14:32tmtwdwhats the proper way to define a regex string in clojure? (def the-string "\Q(youtu.be/|youtube.com/(watch?(.*&)?v=|(embed|v)/))([^?&"'>]+)\E") . I'm trying this from a stackoverflow answer, I don't think it is correct though
14:32tmtwdI keep getting a unmatched delimiter error
14:35amalloy#""
14:35clojurebotIt's greek to me.
15:27justin_smithtmtwd: there's an unescaped " in the middle of that regex
15:27tmtwdah
15:27justin_smithalso it's a string, and probably you want it to be an actuall regex (using the #"" syntax)
15:28tmtwdyes, in that example I forgot the # ----- there should be an app that inserts all the escape chars for you
15:29tmtwdand you can select whichever language you want outputted
15:29justin_smithtmtwd: there's an emacs mode that does it
15:29tmtwdwhich one?
15:29justin_smithone moment, have to look up the name (just remember my keybinding)
15:30justin_smithstring-edit, it provides the command "string-edit-at-point"
15:30tmtwdok will look into it
15:30justin_smithit opens the unescaped string in a new buffer, and when you hit C-cC-c it takes what's in the buffer, escapes it, and puts it back where your cursor was
15:30justin_smithalso you can use it recursively
15:31justin_smithto escape a string inside an escaped string...
15:32tmtwdwow
15:32tmtwdsounds like a useful tool
16:04magnarsjustin_smith: I made string-edit, and I had never considered that you could use it recursively. Thanks ^^
16:40justin_smithmagnars: haha
16:42justin_smithmagnars: thanks for making string-edit btw, it's useful
16:43magnarsjust scratching my own itches - glad it's of help :-)
17:03jonathanji'm writing an IRC client and the API i have at the moment is returning [send-command close-connection!] from the function that establishes the connection, the problem is that commands to reply to a message or say some text turn into something like (say send-command target msg) and i have to pass send-command around everywhere
17:04jonathanjin something like java or python, one might return some object that encapsulates a giant pile of state
17:04jonathanjis there an idiomatic clojure approach to this kind of problem?
17:09tdammersuse closures?
17:10wasamasajonathanj: perhaps https://github.com/stuartsierra/component
17:12jonathanjtdammers: could you elaborate?
17:13jonathanjtdammers: send-command is already a closure, it closes over the raw tcp stream and provides a slightly more high level api than "some bytes"
17:13tdammersah, ok
17:13jonathanjtdammers: it's infeasible to provide a closure for every possible command that could ever be executed though
17:13tdammersI thought the question was "how do I wrap up a bunch of state in order to pass it around"
17:14jonathanjtdammers: it is that, except it's a level up
17:16jonathanjcomponent looks like a possible solution, albeit quite a complicated one
17:17wasamasait isn't complicated actually
17:17wasamasajust a pretty disciplined way to structure an application
17:17jonathanjmaybe complicated wasn't the right word
17:17wasamasaif you take a look at the code, you'll notice it's nearly nothing
17:18jonathanji guess i always thought of (defrecord) of giving up on a functional style
17:19jonathanjas giving up*
17:20jonathanjmaybe that's just an extreme reaction?
17:21wasamasaperhaps
17:21clojurebotExcuse me?
17:21wasamasaI don't see anything wrong with them considering they're just another type of immutable data structure
17:22jonathanjthere's also the "Notes for Library Authors" section, which seems pertinent
17:36weebzDoes anyone know how to list an objects methods+properties in the CLR version on mono?
17:36weebzIt doesn't seem like I'm able to use the typeof() function for some reason
17:46weebzFigured it out. (.GetProperties (type obj)) and (.GetMethods (type obj))
18:22tmtwdis is there a way to use callbacks in reagent , like I want to do in this example? http://pastebin.com/N3y0KSiu
18:23justin_smithtmtwd: that do is redundant
18:24justin_smithdoes create-new-contact do something async?
18:24tmtwdit just adds a contact to a database , but list-contacts (which renders the list) seems to be called before the contact is added
18:25justin_smithwhat kind of database?
18:25tmtwdoh, I suppose I could just call list-contacts in create-new-contact ---
18:25justin_smithis it a call to an api?
18:25tmtwdjustin_smith, postgres via a local api
18:26justin_smithOK, then you should make sure the API gives you back its success result before you return from create-new-contact
18:27justin_smithor, if it's an AJAX call to the api, you can put (list-contacts) in the callback
18:27justin_smithor, you could use core.async
18:28tmtwdi see, I put in in (list-contacts), since it is an ajax call
18:35oddcullytmtwd: usually in react land you want to "react" on the change
18:35oddcullyso request your modification in your button
18:35tmtwdokay
18:36oddcullybut let some centract instance take care of the change
18:36oddcullyonce the change occurs, depending on your "storage" in the client, it should trigger the re-render of "everything"
18:36tmtwdcentract?
18:36oddcullyusually you have some watch on your actual data
18:36justin_smithoddcully: so you mean a component
18:37oddcullys/centract/concrete/
18:43oddcullyhmm to bad, that word is already in use
18:43oddcullyi had hoped i found a new one
20:00domokatoi have a vector created with [] and I'm trying to add more elements to it using for, but instead it creates a sequence inside of the vector. Is there a way to pull the elements out of the sequence and put them into the vector?
20:03oddcully,(let [v []] (into v (for [i (range 3)] i)))
20:03justin_smithdomokato: into
20:03clojurebot[0 1 2]
20:03justin_smithdomokato: remember that vectors are immutable, so what's really happening is that conj or into returns a new vector that you have to use
20:03domokatoah, okay, but there's no way to do it somewhere like part way inside the vector, without breaking it up
20:04justin_smithdomokato: no, vectors do not support inertion in the middle, you have to do something else (maybe concat)
20:05domokatooo okay, into or concat, thanks guys
20:07justin_smith,(let [v [:a :b :c :d :e]] (reduce into (subvec v 0 2) [[1 2 3 4] (subvec v 3 5)])
20:07clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
20:08justin_smith,(let [v [:a :b :c :d :e]] (reduce into (subvec v 0 2) [[1 2 3 4] (subvec v 3 5)]))
20:08clojurebot[:a :b 1 2 3 ...]
20:08justin_smith,(apply str (let [v [:a :b :c :d :e]] (reduce into (subvec v 0 2) [[1 2 3 4] (subvec v 3 5)])))
20:08clojurebot":a:b1234:d:e"
20:09justin_smithdomokato: whatever you come up with, you'll likely find subvec helpful
20:09amalloydomokato: notably, there is no function to do it because it is impossible to do efficiently. if it's important for you to do it, you can still do so inefficiently, but you should usually reconsider whether vectors are the right data structure
20:10justin_smithexcellent point
20:10domokatoi'm trying to create an android layout using neko, which takes a vector
20:13domokatoi think using concat i can preserve the order of ui elements in the code, for readability's sake
20:14justin_smithdomokato: into does less work, if CPU becomes an issue
20:14justin_smithalso concat returns a lazy-seq, not a vector
20:15justin_smithso you'll have the added cost of constructing a vector at the end, if the API needs a vector
20:15justin_smithunless you use into, which preserves the vector format
20:15oddcullydepending on your work you are doing, there is also mapv
20:16oddcully(only for readability - in it's guts its into)
20:22domokatocool, gotcha
20:29sdegutisWhat's an admirable technique for getting the index of a given element in coll, and for getting an element by its index?
20:30sdegutisAh, I see nth for the second part of my question.
20:31sdegutisI guess I can make do with map-indexed for the first part, if there's nothing better.
20:48sdegutisHi.
20:54jwmhello
20:57oddcullyhi
22:20AWizzArdI have an interface which I would like to reify. This interface has two methods `onFailure` that each take one arg. Those two methods are overloaded by type. How do I translate this into Clojure syntax?
22:21justin_smithAWizzArd: type hint the arguments in the declarations iirc
22:24AWizzArdTried that. Got this error message: “Mismatched return type: onFailure, expected: void, had: java.lang.Object”
22:24AWizzArdOh okay, seems I need to hint the return type as well.
22:25justin_smithmakes sense I guess - in for a penny, in for a dollar?
22:30oddcullythat is a good rule for any type system
22:45sg2002So, type hints work for reify? AFAIK they don't work for proxy.
22:47waynrcan anyone recommend a function in clojure that will pretty print just the structure of a deeply nested data structure?
22:51turbofailwhat does the "structure" mean?
22:54mistaBIZ google'd to find "the arrangement of and relations between the parts or elements ..
22:54waynri guess i mostly just don't want to look at all the dictionaries in each list since I know each dictionary has the same structure, i want to be able to see the entire structure at once so I can have confidence that i am accessing values correctly
22:56mistaBIZas in how many branches of the tree it is in?
22:57mistaBIZ* 19:47
22:59justin_smithmistaBIZ: you could do a clojure.walk/postwalk that turns instances of map m into :my/m
23:00justin_smith,(require '[clojure.walk :as walk])
23:00clojurebotnil
23:02justin_smith,(require '[clojure.walk :as walk])
23:02clojurebotnil
23:02justin_smith,(walk/postwalk #({{:a 0 :b 1} :my/m} % %) [{:a 0 :b 1} {:x {:a 0 :b 1}} [:f {:z {:a 0 :b 1 :c {:a 0 :b 1}}}]])
23:02clojurebot[:my/m {:x :my/m} [:f {:z {:a 0, :b 1, :c :my/m}}]]
23:03justin_smithmistaBIZ: is that addressing what you want at all?
23:04mistaBIZthats deep
23:04justin_smithmistaBIZ: it just finds all duplicates of a specific value and replaces them with a shorthand
23:45rpaulo\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'