#clojure logs

2014-09-08

00:00hipitihopdanielcompton, another limitation, this is being done in clojurescript so won't have access to all libs
00:00arrdemdanielcompton: okay I found an old (2009) thread that sketched that exact same format. thanks.
00:00justin_smithI think the cljs equivalent would be switching to Object instead of map
00:01hipitihopdanielcompton, looking
00:01arrdemdanielcompton: sketching a spec of URIs for (artifacts, namespaces, vars, classes) all of which are versioned on a maven package so I thought I'd check for prior art in Maven URIs and make sure I superset it.
00:04danielcomptonarrdem: is this for grimoire?:
00:04arrdemdanielcompton: yeah but the hope is that it can be more general.
00:04justin_smith,*clojure-version*
00:04clojurebot{:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"}
00:05arrdem$google clojure-grimoire var-link
00:05lazybot[clojure-grimoire/var-link.el · GitHub] https://github.com/clojure-grimoire/var-link.el
00:05arrdemwell... that's a prototype emacs browser
00:05arrdemlinks to the spec tho
00:06danielcomptonhipitihop: could you use some XPATH to query the original XML document?
00:07hipitihopdanielcompton, don't think so, I do need all elements parsed into final seq/vect I just need to detect the duplicates to warn user of the collisions .. a subsequent pass may drop the duplicates, or apply last in best dressed etc.
00:10danielcomptonarrdem: hehe: http://oxlang.com
00:10arrdemdanielcompton: oh well.
00:10arrdemoxlang.org or oxlang.io would be hipper anyway :P
00:11hipitihopdanielcompton, experiments so far suggest it's the creation of the transient/intermediate colls (that hold the composite keys) which is the high cost but have not been able to fully profile where the bottle neck is.. digging deeper.
00:11danielcomptonarrdem: don't think anyone's heard of this oxford crowd anyway, I wouldn't worry about it.
00:11danielcomptonhipitihop: could you construct the composite keys with xslt?
00:12hipitihopdanielcompton, prior to giving it to our cljs app ? no
00:17technomancyarrdem: scopes are a strictly maven thing, profiles are a lein thing
00:20arrdemdanielcompton: eh it's a non-priority. oxlang isn't actually a thing and odds are never will be just because I think breaking compat with Clojure is requisite to do anything interesting and will be devastating to utility or at least infrastructure.
00:21arrdemtechnomancy: so... how does :scope "test" play with lein deps then? The Maven manual states that a test scoped dependency is _only_ loaded during the testing phase which Lein knows about.
00:21arrdemtechnomancy: I may be misreading tho.. actual raw maven is new to me.
00:22arrdemdanielcompton: current draft https://github.com/clojure-grimoire/var-link
00:23arrdemdanielcompton: the idea is that documentation and source code level links can become kinda portable across different documentation systems including my own ofc.
00:23technomancyarrdem: any non-default :scope means it's ignored by downstream consumers
00:24technomancyarrdem: I actually just answered this question on the lein mailing list. setting :scope in project.clj is only supported for legacy reasons, it should never be necessary
00:24arrdemtechnomancy: gotcha
00:24arrdemdanielcompton: damnit I thought I got that already. thanks :P
00:25danielcomptonarrdem: I meant to clean it up when I pasted it but I'm on a kinesis and my editing is still a bit clumsy
00:25danielcomptonarrdem: var-link is interesting, I like that the motivation is up front
00:26danielcomptonwhat's the motivation behind having var and var+doc and var+src. Don't you just want var+doc and var+src?
00:26arrdemdanielcompton: lazy users and tools like CrossCLJ which only give you one
00:27danielcomptonhaving var seems to muddy the waters for me, I'm not sure where it would take me
00:29danielcomptonarrdem: but I can see why it's there
00:30arrdemI guess my idea with the var:... class:... and ns:... types are that if you can just get to what you want you can find either source or docs. say I just want to find out something about clojure.tools.analyzer. I don't really give a damn whether you give me formatted documetation or source code as long as I can get there fast and start reading.
00:30arrdemI suppose there's an argument in here for having an artifact: type
00:30arrdembut that should probably just be mvn:
00:41danielcomptonarrdem: just a thought, maven has source jars, could you do something related there?
00:42arrdemdanielcompton: yep something like that is in the works.
00:43arrdemdanielcompton: the idea with var-link is that it's part of the same project. documentation/source artifacts that can link against each-other, so that engines like a refactored Grimoire can resolve the links to actual links.
00:44arrdembut this is all out on the horizon somewhere
01:21danielcomptonI heard that Clojure Cup winners get a lock of Rich Hickey's hair
01:23tadni_danielcompton: I saw the beginiing of a speech he gave, and was delighted to hear he made a reference to looking like the 4th Doctor.
01:23tadni_http://en.wikipedia.org/wiki/Fourth_Doctor
01:24danielcomptontadni_: bahaha
01:24tadni_No one seemed to care or get it too, which I found a bit sad. It was something along the line of "I left my tardis running outside".
01:24tadni_Or a similar motif.
02:02iamanoobHello guys, is there a prettier way (or more common) way to write this: https://www.refheap.com/89978 (it just don't look right to me, i'm a complete beginner sorry)
02:11BAMbandaCan we pull in clojar packages to an independant lein repl?
02:11BAMbandaoutside a project directory
02:35babygauprovided that f2 take 2 arguments (defn f2 [c d]...), how to write f1 that return value is f2 arguments??? => (f2 (f1 a b))
02:46babygauprovided that f2 take 2 arguments (defn f2 [c d]...), how to write f1 that returned values are f2 arguments??? => (f2 (f1 a b))
02:49gwsbabygau: (apply f2 (f1 a b))
02:50gws,(apply + [1 2])
02:50clojurebot3
02:51babygau@gws: tks mate, but is there any other way that I don't have to use `let` destructuring or `apply` function???
02:51lazybotbabygau: Yes, 100% for sure.
02:53Bronsababygau: not without changing the implementation of f2
02:53Bronsathere's no way to call f with 2 args using (f x)
02:54babygau@bronsa: so the best practice is f1 return [a b] and use `apply` on f2 which take f1 values, right?
02:55Bronsababygau: yes, assuming you can't control the implementation of f2
02:56Bronsaotherwise you could turn f2 into (defn f2 [[x y]] ..) instead of (defn f2 [x y] ..)
02:56Bronsaor, even (defn f2 ([[x y]] (f2 x y)) ([x y] ..))
02:57Bronsathis way you can call (f2 [1 2]) or (f2 1 2)
02:58babygau@Bronsa: tks bro, the second one is great answer :D
02:59Bronsababygau: np, btw there's no need to use @ to refer to someone in IRC
03:00babygaubronsa: oh, I don't know that, both #clojure & #irc are so new to me :)
03:02Bronsababygau: also your client should auto-complete names with TAB
03:02babygauBronsa, many thanks mate, i'm using #hexchat and `TAB` works indeed!!!!
03:03Bronsayou're welcome
03:03babygauBronsa, about my question, I forgot that `defn` accept multiple arity, so I can manipulate `fn` argument just the way I want :)
03:04Bronsaindeed, it's quite handy when coupled with destructuring on the args vector
03:04babygauBronsa, yours just hit right spot ;)
03:05Bronsababygau: usually nobody writes functions that way though -- unrolling the args of lesser arities -- we just use apply
03:06celwellIf I already have ring as a dependency do I need to also add clj-http as a dependency if I want to :require clj-http? I.e., if I'm already pulling in a library that depends on the library I need, do I still have to explicity depend on that latter library if I want to use it?
03:06babygauBronsa, tks mate, I could see how `apply` is more favourable, It's just my curiosity when it comes to learn a new language :)
04:40justin_smithcelwell: if you know it is a transative dep, you don't need to explicitly put it in your deps. If that fails, it will fail at build time, not in your deployed code, so it isn't a big risk.
08:42Rhainuroh man I'm so ignorant about clojure terminology that I don't even know what to google for
08:42llasramRhainur: What are you trying to figure out?
08:43Rhainurhow do I go from this vector [1 2 3] to 3 separate items. I have (def some-vector [1 2 3]) and I want to call a function with 3 arguments thusly: (some-fn 1 2 3)
08:43clgvRhainur: you can change that - there are books and online introductions to clojure ;)
08:43llasramRhainur: `apply`
08:43llasram,(apply + [1 2 3])
08:43clojurebot6
08:43Rhainurbut apply gives me 1 item
08:44RhainurI don't want to call some-fn on all the arguments
08:44Rhainursome-fn accepts 3 arguments
08:44llasramRight..
08:44llasram(apply f [x y z]) is the same as (f x y z)
08:44daniel___Rhainur: map would do that, apply is the closest to unpacking you might find in python et al
08:44hyPiRion,(map (fn [x] (+ 1 x)) [1 2 3])
08:44clojurebot(2 3 4)
08:45Rhainurllasram: ahhhh
08:49juliobarrosDatomic question: I have a bunch of entity types with several common attributes (name, active, etc.) does it make sense to make one common attribute that any entity "type" can have or to namespace each attribute for each entity x/name AND y/name, etc.
08:58Rhainurso this might be quite an unreasonable request, but I'm trying to figure out how to "think" in idiomatic Clojure and struggling a lot. For simple stuff it seems straightforward, but...
08:59llasramRhainur: My experience is that you just work in the language long enough and it eventually clicks
08:59bacon1989^
08:59RhainurI have a a piece of code in imperative style that I'm trying to redo in clojure and am just blanking on doing it any way other than imperative
08:59bacon1989Rhainur: been running into the same problems
09:00bacon1989Rhainur: if you have the oreilly book on clojure programming, i'd recommend going through the parallelism/concurrency section a few times
09:00llasramIt just takes time (again IME). I had a definite point where it flipped from feeling like I was struggling to write my code "backwards" to it feeling completely natural
09:00Rhainurhow did you start though, just reading through books? or project euler or something?
09:00bacon1989the biggest hurdle I hit was figuring out how to have 'some' state
09:00awwaiidRhainur: I kept trying to use atoms and refs and such, before realizing that I could just have a function that returns the new value, and then just conveniently forget that the old value was ever around (instead of overwriting it)
09:01bacon1989Rhainur: project euler is good as a start, but the solutions are mostly stateless
09:01llasramRhainur: I went though project Euler problems, did a few tiny projects (Mandelbrot set renderer), and re-did a few work projects in Clojure (not for production at first -- just exercise)
09:02J_ArcaneClojure, thus far, is proving a very good sandbox for *forcing* me to get better at functional style. I have too much BASIC and Python in my blood still, so it's taking some amount of practice to get out of it.;)
09:03dnolen_juliobarros: more likely to get an answer in #datomic
09:04juliobarrosdnolen_: Thanks. Did/do not see that channel ... Hmm.
09:07RhainurJ_Arcane: I went from PHP to Ruby and now I'm trying out Clojure
09:08daniel___Rhainur: 4clojure is good, a lot of those are hard to begin with
09:09daniel___and after struggling a bit, you can search for solutions and see how others solved them
09:09not3I want to try clojure and racket
09:09awwaiid4clojure?
09:09clojurebot4clojure is the place to go for Clojure exercises
09:09awwaiidhm!
09:10J_ArcaneI am working on the Clojurescript Koans myself. A few are a bit brain-bending, but it's a good way to quickly pick up the basics. I'll probably do 4clojure next.
09:12awwaiida lot of my friends like exercism.io, but I haven't tried it
09:13J_Arcaneawwaiid: I hadn't heard about that one. Looks pretty cool.
09:13J_ArcaneI'm finding I learn better through these sorts of interactive methods than with traditional books (though Practical Common Lisp was pretty good, just not sure I like CL).
09:14necronianCan someone explain to me what is happening here? (clojure.string/replace "$" #"\$" "\\\\$") => StringIndexOutOfBoundsException String index out of range: 3 java.lang.String.charAt (String.java:658)
09:15clgv,"\\\\$"
09:16clojurebot"\\\\$"
09:16clgv,#"\$"
09:16clojurebot#"\$"
09:16necronianThis (clojure.string/replace "$" #"\$" "\\$") works
09:17necronianand this also evaluates (clojure.string/replace "$" "$" "\\\\$")
09:19clgvnecronian: you have to consult the javadocs therefore Matcher/replaceAll
09:21necronianclgv: Yea that would probably be a smart idea
09:24necronianclgv: Thanks for the tip. I feel pretty stupid now. Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string.
09:27dgaffneyHey all, I'm relatively new at this and I'm trying to use the async module to make a series of calls to an API, then one final API call that uses the sum of the results from that series of API calls. What am I doing wrong here? https://gist.github.com/DGaffney/2b060bcc1a459334f65d
09:28dgaffneywait whooooops - I am in the clojure channel.
09:28dgaffneyI'm learning both at the same time :|
10:10jtacketthey, I want to be able to write a file to the desktop from my heroku app
10:10jtackettI know it is a read only file system, but I need a way for the user to save a text file they have created to their desktop
10:11justin_smithjtackett: what desktop?
10:11jtackettthe user’s desktop
10:11justin_smithoh, then send it to them as a response with a content type that triggers a download
10:12jtacketthow would you go about doing that in clojure?
10:12justin_smithtechnically they will decide where it goes
10:12justin_smithis this a webapp?
10:12jtackettyep
10:12justin_smithso, something on the client side has to send you a request, and you reply with the contents of the file
10:13justin_smitheither they click a button "click here for your file" or you have some js magic going on
10:13jtackettso thinking from a view and handler set up
10:13jtackettlet’s say they click a button for it
10:13justin_smithright, and you would have the right data in the session to associate the user with their file
10:13jtacketthow do you trigger a download?
10:13justin_smithby setting the content type such that a browser downloads rather than displaying
10:13jtackettsounds fancy
10:13jtacketthow does that work?
10:14jtackettlike what is the code for that
10:15justin_smithin your handler, you should return a map {"Content-Type" "some-content-type" :body (slurp (io/input-stream (io/file user-file)))}
10:16justin_smithwait, you probably want to leave off the slurp there
10:16justin_smithI am looking up docs for the content type setting
10:17justin_smithhttp://stackoverflow.com/questions/925854/forcing-a-file-to-download here we go
10:17justin_smiththat's how you do it
10:18justin_smithoh, and the actual map is {:headers {"Content-Type" "application/octet-stream" "Content-Disposition" "attachment"} :body (io/input-stream (io/resource user-file))}
10:20jtackettalright perfect
10:20d0kyhello does anybody know how to remove diacritics ? i'm trying:
10:20d0ky(java.text.Normalizer/normalize "áČš" java.text.Normalizer$Form/NFC) but it returns áČš instead aCs
10:20jtackettjust need to figure out where that would go in the handler/view scheme
10:21justin_smithjtackett: that map is what you return from the handler
10:21justin_smithwhere usually you would return a string or whatever
10:22mdrogalisI think I'm close to understanding transducers. I get that they somehow don't use intermediate results and are more efficient in that sense, but why doesn't normal function composition suffice *to begin with*? See: https://gist.github.com/MichaelDrogalis/51fe0e76f61e6cebb987
10:22jtackettso usually I would return a view, but I should return that map?
10:22jtackettcan I also put a string as the body?
10:22jtackettor does it need to be a file
10:22justin_smithsure
10:22justin_smithit can be a string, an input string - however you generate the thing to download
10:23jtackettso it could be: {:headers {"Content-Type" "application/octet-stream" "Content-Disposition" "attachment"} :body “Some string of text”}
10:23justin_smithif you return a map with :body key, the associated val is used the same way it would if it were the only thing you returned
10:23justin_smithright
10:23jtackettalright perfect
10:23jtackettI’ll give it a shot after this meeting
10:23jtackettthanks, I’ll be back on if I have any questions
10:24justin_smithso if it's more convenient it can also be a collection of strings, and ring will join them, for example
10:26d0kyhello is there any way how to replace accents letters with non-accents letters ? (java.text.Normalizer/normalize "ácš" java.text.Normalizer$Form/NFC) doesn't work :/
10:29justin_smith,(java.text.Normalizer/normalize "ácš" java.text.Normalizer$Form/NFKD)
10:29clojurebot#<ExceptionInInitializerError java.lang.ExceptionInInitializerError>
10:29justin_smitherr...
10:29justin_smithtry that
10:29justin_smithit separates the diacritics from the chars
10:30cbp,(java.text.Normalizer/normalize "ácš"
10:30cbp java.text.Normalizer$Form/NFD)
10:30clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
10:30cbpoops
10:31d0kywith (java.text.Normalizer/normalize "ťcš" java.text.Normalizer$Form/NFKD) or NFD i always get the same result ...
10:31justin_smithyeah, NFD and NFKD seem to give the same result
10:32d0kybut always with marks => ťcš
10:32justin_smithd0ky: it isn't meant to eliminate the diacritics, just make them separate characters, or a character plus a combining diacritic
10:33justin_smith(java.text.Normalizer/normalize "ácš" java.text.Normalizer$Form/NFD) => "ácš
10:33justin_smiththat is exact what it should be doing
10:33cbp(-> "ťcš" (java.text.Normalizer/normalize java.text.Normalizer$Form/NFD) (.replaceAll "[^\\p{ASCII}]" ""))
10:33d0kyjustin_smith: oh ... so can i get characters without marks ?
10:34justin_smithlooks like cbp answered your question right before you asked it
10:34d0kyjustin_smith: wooow that works great :)
10:34d0kythank you :)
10:35d0kycbp: sorry ... thank you :)
10:35d0kycbp: justin_smith: you both thanks :)
10:36cbp(:
10:36justin_smithd0ky: we have fake internet points we use in these situations
10:36justin_smith(inc cbp)
10:36lazybot⇒ 8
10:37d0kyjustin_smith: ok :)
11:25dgrnbrgIs (clojure.core.async/chan 0) the same as (clojure.core.async/chan)?
11:27justin_smithdgrnbrg: the docs seem to imply there is no buffer if no arg is supplied, so I guess that would be the same as explicitly supplying an n of 0?
11:28dgrnbrgthat’s what I hope, but I don’t want to manually verify this—hoping someone else already knows
11:28nick___https://github.com/clojure/core.async/blob/53bf7866f195e6ba247ff7122b99784e66e9f1bb/src/main/clojure/clojure/core/async.clj#L66
11:29justin_smithdgrnbrg: https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj#L12 this seems to imply so too
11:30dgrnbrgthe proper idiom appears to actually be to use nil instead of 0
11:30hlprmnkydgrnbrg: I just spun up a REPL and made a chan with ‘0’ and it certainly appears to behave just like a chan with no arg
11:31dgrnbrgit’s tricky to test the buffering behavior
11:31dgrnbrgbecause I want to be able to control whether or not there’s any buffering going on
11:36ghadishaybanin the reducers intro post a couple years ago, there was a reference to multi-fold / multi-reducibles being a topic of active research. does anyone know of any research?
11:37borkdudein clojure mode, can you collapse functions?
11:39justin_smithborkdude: I use hs-minor-mode and outline-minor mode for that (they each have advantages, they each know how to collapse / expand a sexp)
11:39justin_smithghadishayban: reducers for parallel reduction?
11:40Johannes`hi, is it possible to view REPL error messages in fireplace.vim?
11:40Johannes`i only get the Vim(python): Traceback: line
11:40Johannes`when code is invalid
11:41borkdudejustin_smith thanks. I\m trying hs-minor-mode, but gosh, the default keybindings... :)
11:42justin_smithborkdude: yeah, it really needs custom keys
11:42justin_smithJohannes`: (pst) should show you the stack trace for the most recent error in any repl
11:42justin_smithJohannes`: in the odd case that clojure.repl is not in scope, it will be clojure.repl/pst
11:43dgrnbrgJohannes`: use “:lopen” in vim
11:43dgrnbrgthis will open a vim stacktrace that will let you navigate the code easiyl
11:43justin_smithoh, fancy :)
11:46Johannes`dgrnbrg: it gives me "no location list"
11:46dgrnbrgJohannes`: you have fireplace installed? and you had an exception thrown?
11:46Johannes`yeah
11:46dgrnbrgweird
11:46dgrnbrgwell, it’s supposed to work then
11:46Johannes`:S
11:46technomancy/
11:46technomancy`.
11:47technomancyderp
11:47justin_smithI thought it was maybe collaborative ascii art time
11:47borkdudemaybe there is some mode that gives an overview in the left buffer, and you can select to set point to sexp in the right buffer?
11:48justin_smithborkdude: speedbar should be able to do that, if you have it configured for clojure (which I have not done, but I know is hypothetically possible)
11:48justin_smithborkdude: if you are talking about emacs that is
11:48borkdudejustin_smith yes
11:48danneuI'm having trouble writing/applying a function `ignore-assets` that takes middleware that will only be applied to a request if it's no an asset request (css, js, etc) https://www.refheap.com/89984
11:49danneuhaving trouble thinking about it. has anyone written something similar?
11:49justin_smith,(re-find #".js$|.css$|" "foo.css") ; danneu
11:49clojurebot""
11:49justin_smithI think your regex is bad
11:50danneuthe rest of it is bad too
11:51danneujustin_smith: you have trailing pipe
11:51justin_smith,(re-find #"\.js|\.css$" "foo.css")
11:51clojurebot".css"
11:51justin_smith,(re-find #"\.js|\.css$" "foocss") ; I fixed this corner case
11:51clojurebotnil
11:51danneuhaha thanks
11:51TimMcjustin_smith: "...and you should feel bad."
11:52Johannes`justin_smith: thanks, using :map <F5> :Eval (pst)<CR>
11:53justin_smithdanneu: with the fixed regex, it should be close to fixed if not fixed - your first regex actually matches anything with empty string (which is truthy)
11:53justin_smith,(if (re-find #".js$|.css$|" "foo.bar") :MATCHED)
11:53clojurebot:MATCHED
11:53justin_smith,(if (re-find #"\.js|\.css$" "foo.bar") :MATCHED :NO_MATCH)
11:53clojurebot:NO_MATCH
11:54mr-foobara webapp using cookies + db is stateful right ?
11:55ghadishaybanjustin_smith: "joining" two reductions together
11:55dm3mr-foobar: no, it's stateful if it has a session or keeps something in memory
11:55justin_smithghadishayban: ahh, so transducers
11:55justin_smithghadishayban: in particular the transduce function
11:56dm3anyone experienced with core.logic here? having trouble thinking about a problem:
11:56justin_smithdm3: well, with a db you can proxy state via api calls
11:56ghadishaybanjustin_smith: only map can reduce over multiple logical collections
11:56dnolen_dm3: ask your question
11:56Johannes`why does [3] equal '(3)?
11:56justin_smithghadishayban: I thought you meant composing reductions into one reducing action
11:56dm3basically need to reconcile two sets of records ('id 'number)
11:57justin_smithJohannes`: structural equality
11:57dm3where either 1. records are equal, 2. sum of records with the same id on one side == 1 record on the other side, 3. sums on one side == sums on the other side
11:58mr-foobarjustin_smith: isn't it simpler to throw out rest and use a stateful server then ?
11:58mr-foobari think clojure might provide execellent primitives for a server.
11:59danneumr-foobar: what are you trying to do?
11:59justin_smithmr-foobar: it is excellent for making servers. It is easy to make per-request bindings that are invisible to other requests.
11:59justin_smithmr-foobar: with persistent state via db or cookie session
11:59mr-foobardanneu: oh nothing. just got bored implementing yet another cookie seesion
12:00justin_smithmr-foobar: are you not using the standard ring middleware for that?
12:01dm3dnolen_: thought about fd, but cannot understand how to create a domain of sums which maps back to individual record ids
12:01dm3dnolen_: probably just thinking about the problem completely un-logically :)
12:01jtackettjustin_smith: the download stuff works but it does not allow the user to name the file and decide where to save it
12:01jtackettit only just downloads it
12:01justin_smithJohannes`: my response earlier was a bit glib. In clojure, since we focus on immutible values, we don't care so much about identity of objects, we do care if they have the same effective structure.
12:02danneujustin_smith: sad, i actually did have that trailing pipe in my code. the gist now works, thanks.
12:02justin_smithjtackett: I think another answer in that same SO thread had an answer for that
12:02mr-foobarjustin_smith: i am but I feel if http is like an interface ( not ring which is a level of indirection ) I think you could embed an app directly into the server.
12:03technomancyJohannes`: it's because pervasive laziness would be a lot more awkward if it affected equality
12:03justin_smithmr-foobar: I like the indirection ring provides, it adds sanity and isolation
12:03Johannes`technomancy: true
12:04technomancy,(= (map identity [1 2 3]) [1 2 3])
12:04clojurebottrue
12:05justin_smith,(= (map identity [1 2 3]) (lazy-seq [1 2 3]) (list 1 2 3) [1 2 3])
12:05clojurebottrue
12:05justin_smith,(= [1 2 3] (into-array [1 2 3])) ; but
12:05clojurebotfalse
12:06technomancywell yeah, mutability is gross
12:06technomancyif only it were consistent about that though =(
12:07justin_smithyeah, just pointing out the gotcha :) it is of course there for good reason
12:08actionshrimpit was like 52/59ths the size or something
12:12Johannes`18:03 <technomancy> Johannes`: it's because pervasive laziness would be a lot more awkward if it affected equality
12:12Johannes`out of context, this sounds like political debate
12:12technomancypoor people, amirite?
12:12Johannes`y
12:13mdrogalisHah
12:13lavokadhi, why M-x clojure-mode doesn't provide the auto-indentation? Does anyone know what is problem with this?
12:14rweiras in "I hit enter but it didn't indent the cursor"?
12:14technomancylavokad: that's what C-j does out of the box, but you can rebind to RET
12:14danneufor some reason after i updated my emacs packages, <enter> at the end of a line in a clj file always goes to col0 on the next line, but now i have to C-j to do that
12:15justin_smithlavokad: I think there is something like "electric-newline" you can set
12:15danneu<enter> used to behave like C-j
12:15Johannes`well check C-h k C-j and C-h k RET
12:15lavokadjustin_smith: haha
12:15technomancydanneu: the old behaviour was a bug
12:15lavokadu know everyhing
12:15lavokadthat is crazy
12:16danneuJohannes`: thanks. RET is evil-ret and C-j is paredit-newline
12:16justin_smithlavokad: I've been using emacs for a long time
12:16lavokadelectric-indent-mode. So this function in clojure-mode package?
12:16rweirno, it's independent of clojure-mode
12:16justin_smithit's an emacs thing
12:17J_ArcaneI have apparently completed the Clojurescript Koans.
12:17rweirshould we be koancerned?
12:17J_ArcaneHah!
12:18justin_smithJ_Arcane: there is also 4clojure
12:18justin_smithif you are looking for more
12:18lavokadSo why does one need clojure-mode?
12:18rweirlavokad, because emacs has no idea how to indent clojure code or colour it or ...
12:18J_Arcanejustin_smith: Yes. also, the CLJS version is incomplete, if I want the rest I should consider at least doing the relevant parts of the clojure koans.
12:18rweirlavokad, electric-indent-mode asks the major mode to indent the thing
12:18justin_smithlavokad: for things like highlighting, for defining clojure specific versions of the generic emacs concepts (like what a sexp is, how things should indent)
12:20justin_smithit's like a janky brittle elisp version of protocols - there are the generic definitions of things, commands that act on them, and then each mode provides the concrete actions they are bound to
12:20lavokadok. And what is best way to see clojure's function doc stuff in emacs?
12:20lavokadwhile writing code..
12:21justin_smithI think there is a mode or setting for showing the arglist in the minibuffer - dunno about the docstring though
12:21mwfoglemanlavokad: are you using CIDER?
12:21aderethC-c C-d
12:21adereth?
12:21justin_smithbut that would be part of the repl integration (swank / nrepl.el / cider) since it has to ask the clojure process for info
12:22aderethAssuming you are using CIDER
12:22mwfoglemanif so, you'll want to set up eldoc (which justin_smith was talking about), and you can use M-. to see cource code and the C-c C-d (g / h) to see Grimoire stuff... I think there are others
12:23danneuWould anyone use a bolt-on forum system where you own trumpets.com and CNAME forum.trumpets.com to trumpets.forumservice.com?
12:24rweirisn't that what discourse does
12:24dagda1paredit or smartparens, is there a reason to favour one over the other?
12:24danneurweir: isnt discourse self-hosted?
12:24rweirparedit had a better cheatsheet at least
12:24technomancydagda1: smartparens is more work to configure, but it works on non-lisps
12:24technomancyor so they say
12:25J_ArcaneI think I technically use paredit, but to be honest I also mostly rely on electric-pairs insted.
12:25dagda1technomancy: it works with ruby also
12:25danneurweir: and, at that point, discourse is even hard to self-host
12:26justin_smithlavokad: and given that my answers have been incomplete: http://media-cache-ec0.pinimg.com/236x/7a/19/bc/7a19bca2d9e429993ac39e4241d832e6.jpg
12:27lavokad;D
12:28lavokadI situate the cursor on defmacro word, then C-c C-d and waiting more in input..?
12:28justin_smithhttp://i.lvme.me/q2za7r5.jpg
12:28J_Arcaneposting my clojure fizzbuzz golf apparently gained me new twitter followers in the form of four nearly identical "famous quotes" accounts and an SQL consultant.
12:29justin_smithhah
12:33apodlavokad: If you are using cider >= 0.7, the keybinding is C-c C-d d
12:34lavokadthanks!
12:34lavokad
12:34rweirhm, still no 24.4
12:36mdrogalisRepost from earlier:
12:36mdrogalisI think I'm close to understanding transducers. I get that they somehow don't use intermediate results and are more efficient in that sense, but why doesn't normal function composition suffice *to begin with*? See: https://gist.github.com/MichaelDrogalis/51fe0e76f61e6cebb987
12:39CookedGryphonmdrogalis: the bottom one creates a lazy map which is fed into a lazy filter, the first one doesn't create an intermediate filter, in one shot it increments the number and looks at whether it's even
12:41tbaldridgemdrogalis: right, the second one creates lazyseqs between coll, map, filter, and dedupe
12:41joegalloCookedGryphon: making sure i'm tracking you, the difference is the amount of intermedia objects (that is, garbage) that are created?
12:41CookedGryphonyeah
12:41joegalloheh, intermedia --> intermediate ;)
12:42joegallowould be very neat to see a comparison of the two in a profiler
12:42CookedGryphonsay your coll is 50meg, and for simplicity's sake, each transformation you're doing on it the result also takes up 50 meg, with the first example you only end up with 50 meg in and 50 meg out, the second one, you end up with 50+ 50 for the result of the map + 50 for the result of the filter .... etc. which has to be GCd
12:43joegalloand gc is cheap, but it isn't *free*
12:44technomancystill, I get the feeling this isn't going to be a bottleneck in the large majority of applications
12:44CookedGryphonI think there's extra indirection too
12:45CookedGryphonin terms of the number of function calls
12:45technomancysimilar to how multimethods are rarely a bottleneck, but it's good to have a faster alternative for those rare cases
12:45joegallotechnomancy: maybe not on your debian-based system. but i'm running gentoo with the most incredible CFLAGS in the universe.
12:45joegallojk jk
12:47justin_smithanother thing to consider is the number of heap lookups that are eliminated when transducers are composed - not that clojure is anything close to being a cache-line-coherent language, but every little bit helps
12:47justin_smith*cache-line-friendly I mean
12:47justin_smithcoherency is another thing altogether
12:47justin_smith(provided by CPU, not language)
12:48CookedGryphonI personally am really excited about it. All my app does is pile up transformations on channels to respond to events
12:48justin_smithyeah, that seems like a perfect use-case
12:48mdrogalisCookedGryphon / tbaldridge: Sorry, got pulled away. Yep, I get that there's less garbage. But here's a more directed question: Why does core.async need to provide map/filter/etc mirrors in the first place?
12:48mdrogalisWhy couldnt it take an aribitrary function?
12:49tbaldridgemdrogalis: "arbitrary function" ?
12:49CookedGryphon... what do you mean? It doesn't provide map/filter etc any more, it takes the transducers versions now
12:50mdrogalisCookedGryphon: Consider pre-transcuders commits. In core.async, there's map< filter<, mapcat< etc
12:50mdrogalisWhy couldnt there be one api that takes a function instead?
12:51CookedGryphongood point... and as I understand it, entirely the logic behind having transducers...
12:52justin_smithmdrogalis: that's what transducers are, right? it's the way one defines a function that can be bolted onto a channel. Or do you mean we should be allowed to put any function on there?
12:52tbaldridgemdrogalis: you'll be at STL right?, go to Rich's talk, all will be explained, I'm sure ;-)
12:52CookedGryphonI think you *can* put any function on there, which matches the signature of the transducers
12:52mdrogalisJust throw out transcuders for a second. I dont understand what prevented us from composing functions in the first place. D:
12:52mdrogalisIm sure theres a reason, I just dont get it
12:52mdrogalistbaldridge: Yeahhh, I think Ill wait I guess.
12:53dnolen_mdrogalis: what is there to compose?
12:53dnolen_mdrogalis: map/filter/reduce too sequence like things
12:53dnolen_there are no real sequences in event streams
12:53dnolen_s/too/took
12:54mdrogalisdnolen_: Ahhhhh
12:54mdrogalisThere we go, it clicked.
12:54mdrogalisdnolen_: Thanks. I was mentally throwing .. Something out. Im not sure what, but yeah. I see now.
12:56ghadishaybanyeah the cache line sympathy is important too
12:58justin_smithghadishayban: there we go, sympathy was the word I was searching for
12:58ghadishaybanhiredman is on a crusade to get things to have reduce at the bottom rather than lazy-seq... the benefit is very nice
12:59tbaldridge+1, reduce all the things
12:59ghadishaybanhalf of the knobs on c.j.jdbc/query call are to control realization of the sequence
12:59rweirreduce or transduce?
12:59ghadishaybanthink of them similarly
13:00ghadishaybanthey can both abort through "reduced"
13:00tbaldridgeI've noticed that half the time when I used lazy-seqs I was really only using them to compose pipelines, I very rarely wanted the lazy bits. Thus all that stuff can be converted to transducers
13:00justin_smithtransduce is just a generalization of the reduce concept, no?
13:00ghadishaybannow that into uses transduce, c.j.jdbc could do this: (into (take 5000) (queryr "select * from foo"))
13:01ghadishaybanrather (into [] (take 5000) (queryr "select * from foo"))
13:01mdrogalisNice :)
13:01justin_smithghadishayban: the laziness is helpful for having control of the db connection, and not needing to transmit more results if you discover you have what you need (though reduced could do the same I guess :))
13:01jtacketthey :justin_smith couldn’t find how to get the actual download window to come up
13:01ghadishaybanthat way you don't have to tell jdbc how much you want to stream
13:01ghadishaybanjustin_smith: it's still "lazy"
13:02technomancyITYM :org.freenode.clojure/justin_smith
13:02ghadishaybanit's just not a concrete lazy-seq
13:03jtackettghadishayban: wrap that in a doall
13:03ghadishayban?
13:03justin_smithjtackett: the point here is we don't even want laziness in that context
13:03jtackettsorry came in the convo too late haha
13:04jtackettoh i got ya
13:04jtackettkind of loosing the point of clojure haha
13:04justin_smithjtackett: not sure, but maybe try taking out the content-disposition attachment part
13:04justin_smithjtackett: not at all! this is about transducers
13:05jtackettmaybe it’s a different acontent type?
13:05jtackettsorry I haven’t handled transducers at all
13:05justin_smiththey are quite new
13:05justin_smithoctet-stream should be the one for downloads in general
13:05jtackettnice, gotta love the new stuff coming out
13:05justin_smiththe disposition should be the one that effects how it is handled
13:09ghadishaybantransducers really are the shit
13:09ghadishaybana high-performance, high-level abstraction that was hiding in plain sight
13:10mikerodtransduce* all the things
13:11ghadishaybanalso plays nicely with java 8 streams api
13:12justin_smithoh really? that's awesome
13:12dnolen_ghadishayban: cool, I'm really looking forward to your Conj talk BTW :)
13:12ghadishaybanfor example java.util.regex.Pattern/splitAsStream
13:13J_ArcaneMan, sometimes I love FreeBSD ports so much. Up-to-date packages for Clojure, CIDER, and clojure-mode, all in the repos already. :D Might be time to reboot in a minut.
13:13ghadishaybantransduce over the stream, and you can get zero-allocation fun
13:13tadni_J_Arcane: Can't you just use package.el for the latter two?
13:14J_Arcanetadni_: Probably safer most times, yes.
13:15technomancyI wouldn't call it safer
13:15technomancypackage.el installs over unencrypted http
13:15ghadishaybanwrote this as a demonstration of a reducer last year, works the same under transduce https://gist.github.com/ghadishayban/7002262 string regex split that is much faster than both string/split *and* Java's Pattern/split
13:15J_ArcaneWell, I mean less from a security standpoint than from a current-ness one.
13:15tadni_FreeBSD has no Lighttable. The tradgedy.
13:16technomancyJ_Arcane: "current" isn't always a good thing with cidec
13:16J_Arcaneie. you're possibly going to get a slightly newer package from MELPA or something for some packages.
13:16technomancycider
13:18arohnercan I use data literals to make datomic queries return joda time rather than j.u.Date?
13:18ghadishaybandnolen_: Conj talk will be low-level and dirty and you'll need a shower afterwards. nashorn really is an amazing piece of engineering
13:19ghadishaybanunfortunately the current state of invokedynamic isn't all rosy
13:20nick___Whats the prblem with invokedynamic?
13:20nick___Is there a good talk or blogpost?
13:20ghadishaybanJVM current impl has some warmup issues, inferior to JRockit implementation
13:21ghadishaybannot fundamental problems with invokedynamic as a concept at all
13:22ghadishaybannick___: if you want a reference http://mail.openjdk.java.net/pipermail/mlvm-dev/2014-August/005890.html John Rose wrote a brilliant summary of future direction for fast startup
13:22ghadishaybanon the JVM as a whole, a superset of indy issues
13:23ghadishaybanthat whole thread is gold, especially Charlie Nutter, Marcus Lagergren
13:24ghadishaybanand Fredrik Ohrstrom, the originator of the JRockit impl which is able to crrrunch all the invokedynamic things and remove boxing
13:29nick___Thanks
13:29nick___So the problem is only with start up, or are there other fundamental problems?
13:31ghadishaybanwarmup that is the main issue for indy, and it's only so because of the JDK internal implementation (see LambdaForms)
13:31ghadishaybanand also indy doesn't run on android or GAE
13:32atyzI'm looking for a fn similar to interleave/zipmap but that would work with collections of different lengths. So when one collection is used it will start at the beginning and continue
13:32ghadishaybanso it would definitely have to be a compilation mode
13:32hiredmanatyz: cycle
13:32atyzthanks!
13:32atyz(inc hiredman)
13:32lazybot⇒ 55
13:34CookedGryphonDoes anyone here use expectations?
13:34CookedGryphonmy tests do a lot of partial matches of big maps, and it's just infuriating using midje when it spews a whole screen of stuff out at you with no hint as to what's different between the two
13:35CookedGryphonand expectations looks better, but I can't seem to get expectations-mode to actually run my tests in emacs
13:35CookedGryphonor in the repl for that matter
13:35technomancyCookedGryphon: https://github.com/pjstadig/humane-test-output
13:35danneui use expectations
13:36technomancybut I support getting off midje
13:36atyzI second technomancys' suggestion
13:36tbaldrid_CookedGryphon: use clojure.test ;-) the only true testing library
13:36xeqipoor unloved test.check
13:37tbaldrid_well yeah, use that when you can as well.
13:37danneuthough 75% of my tests are a menagerie of `assert`s at the bottom on each file with `TODO: Extract into test framework` that never actually happens
13:38CookedGryphonis the general consensus to stick with clojure.test with humane-output then?
13:38tbaldrid_CookedGryphon: I just use plain clojure.test, and jump to the repl when I can't understand the test ouptut
13:38CookedGryphonif so, where are some good helpers for things like "this map contains at least these key/values and ignore the rest"
13:39tbaldrid_here's one, https://github.com/brentonashworth/lein-difftest and I like that it's not on by default.
13:39atyztbaldrid_: you don't run your tests from the repl? Or are you running the entire suite at once?
13:39atyzvia lein test
13:39tbaldrid_atyz: I do both, most of the time at the REPL
13:44ckarlsenafter upgrading from 1.7 alpha1 to alpha2 i can no longer connect to datomic. 'NoSuchMethodError clojure.lang.SeqIterator.<init>(Lclojure/lang/ISeq;)V datomic.fulltext.Root (fulltext.clj:253)' -- after running `connect`. Only thing I did was replace alpha1 w/ alpha2 in project.clj and ran `lein clean`. Any tips?
13:50amalloyckarlsen: alpha2 isn't binary-compatible with alpha1, and your version of datomic is apparently compiled against the other one
13:50amalloyspecifically, https://github.com/clojure/clojure/blob/43cc1854508d655e58e377f84836ba128971f90c/src/jvm/clojure/lang/SeqIterator.java changed a method from taking ISeq to taking Object
13:51hiredman(the pains of distributing an aot compiled library)
13:55ckarlsenok thanks!
13:58justin_smith#closedsourceproblems
13:58dm3CookedGryphon: https://gist.github.com/dm3/a1dacafb11617a722a96 for the submap with humane-test
14:10ghadishaybanjustin_smith: hiredman: something like this in java.jdbc would be amenable to transduce/reduce https://gist.github.com/ghadishayban/d2f31961deba98ee4595
14:11ghadishaybanthough java.jdbc i think is still compatible with clojure 1.2 and can't use 'reduced'
14:12hiredmanghadishayban: maybe link that gist on the jdbc story?
14:13ghadishaybank
14:15llasramWhy do transducers have a special extra fast fast path for IReduce?
14:16hiredmando they?
14:16llasramYeah -- look at the implementation of `transduce`
14:16ghadishaybantransduce does
14:17ghadishaybanbasically if you are in control, reify IReduce and not CollReduce
14:17ghadishaybanCollReduce on an IReduce just calls .reduce
14:17ghadishaybanit's a little surprising, only in that there are two functionally equivalent paths...
14:18llasramBlergh. I wish protocols could just their backing interface. Or something. So we could have the same JVM interface for an abstract protocol in both Clojure and Java code
14:18llasrams,could just,could just specify,
14:18hiredmanhmmm, I can't say I like the idea of the recommended path being the java interface over the protocol
14:19hiredmanreally what you want is the ability to retro fit a protocol to an existing interface instead of generating a new one
14:19ghadishaybanyeah it strikes me as entirely pragmatic choice, and not motivated by idealistically dog-fooding protocols everywhere
14:19hiredmanI think hugod did some work on something like that a while back
14:19danneuso i have a spare domain that i use for testing my subdomain-based forum system. every time i reset the database, this guy creates a thread http://community-1.fed.nu/forums/1/topics/5
14:20danneuit's like seed data
14:20bacon1989i'm still trying to wrap my head around transducers
14:29llasrambacon1989: They're like burritos
14:29bacon1989dirty and fast?
14:29bacon1989messy and fast to consume?
14:30bacon1989I have a small inklet on how they work, it's more about use-cases I guess
14:30bacon1989like, I look at defmulti, and i can see that it's a fancy generic dispatcher
14:31TimMcllasram: Oh, they are, aren't they?
14:32ghadishaybanhiredman: something like that for jdbc?
14:32bacon1989I have a good question for you guys, say I wanted to write a website with a database
14:32ghadishaybanmy weekend yak-shave was making a fast csv parser that is reducible
14:32hiredmanghadishayban: binding a protocol to an already existing interface
14:32bacon1989where could I place the configuration optoins for my database, if it's going to be different based on deployment?
14:32hiredmanI think it was hugod I may be mistaken
14:33bacon1989I can't place it in the .jar file, how would I refernece a custom config?
14:33ghadishaybani mean the basic interface for a query
14:33ghadishayban(into [] xfn (query ...))
14:33justin_smithbacon1989: typically I have separate config files in the resource path, and use an environment variable to decide which one should be loaded
14:33hiredmanso you could, for example, have IReduce available for java interop and just bind the CollReduce protocol to use that same interface instead of creating a new one
14:34bacon1989justin_smith: can you elaborate on that? what if I wanted to change the custom config?
14:34justin_smithbacon1989: with that setup, a client who wants none of the config in the jar, could add another to the classpath, and specify that one via env
14:34bacon1989ah
14:34justin_smithie. if CONFIG=production it looks for production.edn in classpath
14:34justin_smithetc.
14:35ghadishaybanhiredman: presumably the reduction time will overwhelm protocol/interface dispatch time
14:35Bronsahiredman: I haven't read the backlog but there's a way to change the backing interface for a protocol
14:35ghadishaybanhiredman: on-interface?
14:35llasramBronsa: ooh?
14:35Bronsallasram: what ghadishayban just said :)
14:35danneubacon1989: i use `environ` library. https://github.com/danneu/bulletin/blob/master/src/bulletin/config.clj - for local dev, i have a .lein-env file (i dont commit) that has stuff like :database_url
14:35llasramoooh
14:36ghadishaybannot dynamically, but at definition time...
14:36BronsaI don't think it's documented though
14:36ghadishaybanyeah was going to say, i've never used it
14:37llasramAnd it appears to generate a new interface with the provided name, which isn't what you'd need to solve this problem
14:38bacon1989danneu: justin_smith, I like both of your solutions
14:38bacon1989danneu's solution seems easier, but justin_smith's seems more flexible
14:39justin_smithbacon1989: getting a value from System/getenv and then using that as an arg to clojure.java.io/resource is a one liner
14:40bacon1989oh I know, but a system admin is more likely to blame you if they mess up a custom EDN config file, over messing with the environment variables
14:42bacon1989in fact, i'd probably employ both. Keep database config in env, and have a custom.edn outside of the scope of configuration
14:43mbriggsHey guys, in ruby, if I did File.expand_path("~/foo.txt"), I would get "/Users/matt/foo.txt". Is there anything similar in clojure?
14:43mbriggsi.e. "turn this string into whatever bash would evaluate it to be"
14:43hiredmanBronsa: ah, well, there you go
14:44hiredmanso CollReduce should just be :on-interface on IReduce
14:44Bronsayes
14:44hiredmansomeone tell rich
14:44llasramhiredman, Bronsa: except `defprotocol` still calls `gen-interface` for the provided :on-interface name
14:44bacon1989mbriggs: if you're not afraid to do some java interop, I think java.io.File has what you need
14:44justin_smithmbriggs: java.nio.file.PathMatcher
14:44mbriggsawesome, thanks
14:45hiredmanllasram: :/
14:45Bronsallasram: does it?
14:45hiredmanllasram: gen-interface may short circuit if it already exists
14:45hiredman(also not it on telling rich)
14:45llasramBronsa: I don't see anything which would make it conditional
14:45llasramhiredman: hmmm...
14:46rweirmbriggs, does it really do what bash would do? or does it just expand ~?
14:47hiredmanit doesn't look like it
14:47llasramhiredman: No, don't see anything conditional there either. In fact "normally" expects interface might already exist, in case of redef
14:47mbriggsrweir in this case just expand ~
14:47Bronsaoh well
14:47hiredman:/
14:48Bronsainb4 classloader issues make the "shadowing" interface irrelevant
14:48Bronsa... yeah it seems to work
14:49hiredmansure, but will it continue to work in aot project without a dynamic classloader
14:50llasramBronsa: Er. Doesn't it actually make it not work, because then all the in-Java types implement one interface while the in-Clojure types implement another, where the interfaces just happen to have the same name?
14:50Bronsahttp://sprunge.us/UAjJ
14:50Bronsallasram: no that's the point
14:50hiredmanwill you end up with two IReduce.classes emitted, one from the java compiler with IFn and one from gen-interface with Object
14:50Bronsathe protocol actually uses the already existing interface rather than the one it just created
14:50llasramOh!
14:50llasramwhaaaa
14:50llasramHow?
14:51hiredman:(
14:51BronsaI have a vague understanding on why this happens
14:51hiredmanand the behaviour will be different when compiling
14:51Bronsayeah
14:51llasram`emit-protocol` has the most insane option-parsing code evar
14:52BronsaI've seen some crazy stuff w/ clojure's classloader handling
14:52llasramOOOOOOH
14:52llasramI see now. The code unconditionally will define an interface for the name of the protocol, but will actually use a provided :on-interface instead
14:53llasramThat's something special
14:53TimMcllasram: http://i.imgur.com/3OtgEyU.gif
14:53llasramTimMc: Yeah, that was pretty much me
14:54hiredmanhilarious
14:54hiredmanso :on-interface then
14:54llasramYep. Someone totes should tell Rich
14:55hiredmanof course rich will never go for changing CollReduce to :on-interface IReduce
14:55Bronsahiredman: uhm AOT compiling (defprotocol CollReduce :on-interface clojure.lang.IReduce (..)) might break things actually
14:55hiredmanchanging is verboten, only accrete
14:55Bronsait's going to overwrite the clojure.lang.IReduce class file
14:55hiredman:(
14:56llasramBronsa: Are you sure?
14:56Bronsallasram: almost
14:56llasramBecause I think the gen-interface'd interface is still named for the protocol
14:57Bronsaah?
14:57llasramAnd even if it isn't, can always wrap the `defprotocol` in `(binding [*compile-files* false] ...)` :-D
14:58Bronsanope that won't work
14:59Bronsallasram: ah you're right about the interface name
15:01llasramFinally. I knew it had to happen at least once this week.
15:04ghadishaybani fail to see what the big deal is between CollReduce IReduce
15:05justin_smithmbriggs: one option (#(clojure.java.shell/sh "sh" "-c" (str "echo -n " %)) "~") - sadly that redundant sh invocation is truly needed
15:06mbriggsjustin_smith yeah...
15:06justin_smith(#(:out (clojure.java.shell/sh "sh" "-c" (str "echo -n " %))) "~") actually
15:07mbriggsjustin_smith i ended up just treating this as a special case, and made a wrapper fn around System/getProperty "user.home" to avoid java sillyness
15:07justin_smiththat's fair
15:07mbriggshttps://gist.github.com/4af1e2eb71927111842e
15:09dbaschmbriggs: you may want to make sure there’s a slash in between
15:10dbasch(more properly a path separator)
15:10justin_smithbonus - "//" becomes "/" anyway, so there is little reason not to insert one
15:10justin_smith(slurp "/home/justin/////////////////////////////.bashrc") totally works
15:12vermawhat do you use to keep your processes up and running? like a process manager sorts, not really geared towards web/db servers, something more like a program I could give a process to and it keeps it up
15:12llasramverma: It my company we use runit
15:12noonianverma: something like runit or upstart maybe
15:12vermallasram, noonian hmm, k taking a look
15:14vermallasram, noonian failed to mention that I should be able to kill processes as well, also runit is an init system?
15:15noonianyeah, so you could do something like sudo service my-app stop and sudo service my-app start and if it dies it will get automatically restarted
15:16TimMcjustin_smith: cd //
15:16vermanoonian, hmm interesting
15:16vermanoonian, so I am basically using the OS to manage processes :)
15:16llasramverma: Yeah -- unless I've misunderstood your reqs, what you want *is* an init system. We're on Debian squeeze&wheezy, so using runit > sysvinit for our services. Would probably just use upstart on Ubuntu, and will move to systemd along with rest of world
15:16TimMcand check your prompt
15:16justin_smithTimMc: cd ////// etc. all work on my box
15:17justin_smithbut // is funny in my prompt, yeah
15:17noonianverma: yes, processes are really an os level concept
15:18vermanoonian, yeah :)
15:19TimMcjustin_smith: It's some weird special case, I think just in the shell itself.
15:19TimMcMaybe not.
15:19justin_smithinteresting
15:20dbasch“Multiple successive slashes are considered to be the same as one slash.” http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_266
15:20justin_smithyup
15:21justin_smithwhich is handy to know when constructing paths from freeform inputs
15:21TimMcdbasch: Except leading slashes. http://tiswww.case.edu/php/chet/bash/FAQ E10
15:21TimMc"POSIX.2, in its description of `cd', says that *three* or more leading slashes may be replaced with a single slash when canonicalizing the current working directory."
15:22justin_smithTimMc: lesson: insert three slashes, not just one
15:22TimMchaha
15:23DomKMWhat is the largest open-source Clojure app with Compojure routing?
15:24smizellThis might be a strange/crazy question, but is there any library that converts Clojure code to JSON? Like (def x 1) to ["def", "x", 1]?
15:25tbaldrid_smizell: "convert to JSON" for what use-case?
15:25tbaldrid_smizell: transit does this sort of thing...but it just uses JSON as a transport.
15:25smizellI'm basically curious if you could represent code with JSON
15:26smizellInteresting
15:26justin_smithsmizell: this plus cheshire? https://github.com/technomancy/serializable-fn
15:27smizelltbaldrid: I've spent a lot of time developing JSON hypermedia formats. They are usually always considered data with code provided to parse them.
15:27justin_smithI guess the problem is that js has no [] / () distinction
15:28llasramsmizell: All Clojure code may be represented as Clojure/EDN data, but the translation from Clojure/EDN data to JSON is lossy unless using a layered transport scheme like Transit
15:28turbofailhm. weird. i had a very clear case of reflection going on that *warn-on-reflection* didn't say anything about
15:28turbofailat least when i loaded the namespace
15:28justin_smithturbofail: was it on a number?
15:28turbofailno
15:29justin_smithwas it aot-compiled?
15:29turbofailwell so it was an AOT-compiled namespace so that probably explains it
15:29turbofailyeah
15:29smizellYeah, you'd have to have some way to make some distinctions. You'd also have to limit what it can do.
15:29smizellSome experimenting: https://github.com/smizell/janeml
15:29turbofailthat's the goto explanation for anything weird - AOT?
15:29justin_smithturbofail: yeah, the warnings happen at compile time, and its already compiled, so... there you go
15:30justin_smithin this case it's a simple deduction :)
15:30turbofailyeah i had forgotten that it was AOT compiled
15:31justin_smithnot to say that I wouldn't check AOT for any weird ass behavior, after I eliminate the obvious
15:32tbaldridgesmizell: LISP is basically an easy to read AST. ASTs can be represented as data, JSON is data...at least that's the way I think of it all
15:33smizelltbaldridge: Exactly.
15:34TimMcturbofail: This gets posted at work not too infrequently: http://i.qkme.me/3vb225.jpg
15:34turbofailheh
15:35justin_smithhaha
15:38smizelltbadridge: I am just curious as to how much I could express in JSON. Since JSON is everywhere, there is some cool potential to process things all over the place in different languages.
15:39tbaldridgesmizell: well sure, but it'd look like crap ( ;-) ) and writing a scheme parser isn't hard
15:39smizelltbaldridge: It would look horrible!
15:40tbaldridgesmizell: but a scheme in any language is what...1-2 KLOC?
15:41turbofaildepends on if you need to write your own GC or not
15:41turbofailalso depends on what you mean by "scheme"
15:42smizelltbaldridge: Surely something can be better than JSON Schema, though http://json-schema.org/
15:43hiredmanturbofail: a mark and sweep gc could be as few as 20 lines
15:47miberI'm building a library to communicate with a certain HTTP API - it's basically just a wrapper around clj-http
15:47miberright now it's only a bunch of functions, but now I'm facing two problems:
15:48miber1) I don't know what's a good approach to have the URL of the server configurable (currently it's a global var, which doesn't feel right)
15:48miber2) depending on how the server is configured, I might need to pass a {:basic-auth ["user" "pass"]} or even {:insecure? true} to the clj-http.client/post method
15:48miberI'm quite new to Clojure and I'm looking for a idiomatic way to do this, any pointers?
15:48justin_smithmiber: both can be handled by a config file you look for on the class path
15:49justin_smithunless you need to change those things in a single production run of the app
15:49hiredmanbest is to take them as arguments
15:49miberis there a standard way how to do it via the config file then?
15:50miberhiredman: yeah, I was thinking to do it like so
15:50owengalenjonesmiber: I would look for io/resource examples
15:51miberwould it be good if every function would then take a mandatory first argument which would be a map with the url and possibly other arguments to the post function?
15:52hiredmanloading from a config file is not all that more flexiable than defing it in the code
15:52hiredmanmiber: yeah, pass args
15:53miberok, thanks
16:05J_ArcaneOK, on second thought, maybe installing CIDER from ports (0.7.0) is a safer method than MELPA (0.8.0 and broken, apparently)
16:07xemdetiaJ_Arcane, I'm only seeing CIDER as being released at 0.7.0
16:08J_Arcanexemdetia: the MELPA release I just installed complains of a version mismatch between cider itself and cider-nrepl. One is 0.7, the other is 0.8.
16:08xemdetiahttps://github.com/clojure-emacs/cider/releases
16:08xemdetiaI'm just going off this
16:09llasramJ_Arcane: If you must MELPA, MELPA Stable
16:10xemdetiabeing bleeding edge can often be bloody
16:12J_ArcaneSeems that way. Will probably just roll back the package and install from ports instead, usually stabler option.
16:14J_ArcaneOr just try nightcode or lighttable ...
16:15justin_smithor cursive
16:19llasramJ_Arcane: The MELPA stable repository does all the magic of MELPA, but only for actual tags vs arbitrary commits
16:19dgaffneyHey - any reason why my jetty setup would return 404 when I clearly have a handler for the endpoint?
16:19Rhainurso I have a map of where the keys are all different but all the values = true, and I'd like to iterate over it, and change some of the values to false depending on the key
16:19llasramJ_Arcane: That's probably what you *actually* want
16:19Rhainurhow can I iterate over it and get a key/value pair
16:20Rhainurseq seems to break the map into 2 item vectors
16:20justin_smithRhainur: (into {} (map (fn [[k v]] [(f k) (g v)]) {my data...}))
16:20justin_smiththat is the most generic version
16:20justin_smithreally you want the k part unmodified
16:21amalloyRhainur: what do you imagine is the difference between a key/value pair and a two-item vector?
16:21Rhainuramalloy: if I change the value I want it to affect the original map
16:21Rhainurwell
16:21Rhainurwhat I mean is
16:21amalloywell, like most things in clojure, maps are immutable
16:21RhainurI want to create a new map
16:22Rhainurwith (some) different values
16:22amalloyi mean, really you just do what justin_smith said
16:22Rhainurso I knew there'd be an (into) at some point
16:22justin_smith,(into {} (map (fn [[k v]] [k (if (even? v) (inc v) v)]) {:a 0 :b 1 :c 2 :d 3}))
16:22clojurebot{:c 3, :b 1, :d 3, :a 1}
16:22RhainurI just wasn't sure whether a seq was necessary
16:23llasramRhainur: You could also use `reduce-kv` for MOAR SPEED, but the `map` via seq idiom is more flexible
16:24justin_smith,(reduce-kv (fn [m k v] (assoc m k (if (even? v) (inc v) v))) {} {:a 0 :b 1 :c 2 :d 3})
16:24clojurebot{:a 1, :d 3, :b 1, :c 3}
16:27justin_smith,(let [input {:a 0 :b 1 :c 2 :d 3}] (reduce-kv (fn [m k v] (if (even? v) (assoc m k (inc v)) m)) input input)) ; since you are only changing some keys
16:27clojurebot{:c 3, :b 1, :d 3, :a 1}
16:27justin_smithavoids needless assoc calls
16:32ired_44I'm learning Clojure and am writing my first macro, to print the docstrings of functions as they are run (eventually w/ interpolation of the arguments the function was called with, into the docstring). if anyone has a few minutes I'd appreciate comments/review of the code: https://gist.github.com/mhuebert/c03c131ca0f43f034f0c
16:36SagiCZ1is java.lang autoamtically imported to REPL?
16:36J_Arcaneyeah, to hell with this I'm gonna reboot and try light table.
16:36justin_smithSagiCZ1: java.lang is always imported, period
16:36SagiCZ1,(Math/signum 5)
16:36clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: signum>
16:36SagiCZ1where is the mistake?
16:36justin_smith,(Math/signum 5.0)
16:36clojurebot1.0
16:37SagiCZ1justin_smith: float.. ok
16:37SagiCZ1ty
16:37turbofaili hate that
16:37justin_smith5.0 in clojure is a double literal
16:37justin_smithbut float would work too yeah
16:37justin_smith,(class 5.0)
16:37clojurebotjava.lang.Double
16:37turbofailmost of the java math functions are only defined for doubles or floats or whatever, which seems silly to me
16:38SagiCZ1turbofail: seems normal to me
16:38turbofaili don't think it's too outlandish to want an integer answer for doing (Math/pow 2 12)
16:38technomancyit's only normal if you have a simplistic type system
16:40turbofailsignum and abs are probably the most annoying offenders
16:41SagiCZ1turbofail: well no one really forces you to use the lang.Math
16:41turbofailwell i think abs does work for integer-ish things
16:41dgaffney_Hey guys - any reason I would suddenly be seeing 404's from a jetty server? It's totally weird. I moved from my desktop to my laptop and pulled the repo down, and only *some* of the endpoints are 404'ing, and I've cut it every way I can think, and I'm not seeing it...
16:41justin_smith,(Math/abs -8)
16:41clojurebot8
16:43dgaffney_They are using 7.6.1 for jetty, I just checked both boxes.... this is mindblowingly annoying.
16:43amalloyired_44: what on earth are you using clojure.test/function? for? do you mean clojure.core/fn?
16:44amalloyoh my gosh, c.t/function? resolves the var. that doesn't seem like a good thing to use in general
16:54zanesWhat’s the right way to reset! an atom, and only perform a side effect if the value changed?
16:55tbaldridgezanes: I wouldn't, I'd build it via compare-and-set!
16:55zanesThat’s the answer I was looking for. Thanks!
16:55tbaldridgezanes: http://grimoire.arrdem.com/1.6.0/clojure.core/compare-and-set!/
16:55dorkmafiahow do you make the up arrow run your previous command on the lein shell interface?
16:56zanestbaldridge: In that case I need to first deref the old value, right?
16:57tbaldridgezanes: right, you deref, run code, and then run compare-and-set! if it returns true, you run your side-effects
16:57zanestbaldridge: 👍
16:58TEttinger(inc tbaldridge)
16:58lazybot⇒ 10
16:59jtackettI have a long running process that i need for the next web page view
16:59jtacketthow can I return the page and display the process output when it is finished?
17:00justin_smithjtackett: you could use a future, and block on the return value of the future
17:01justin_smithscratch that
17:01justin_smithyou'd need a web socket (misread your question at first)
17:01jtacketta web socket?
17:01jtacketthow does that work?
17:02justin_smithit lets you send data to the browser after the request is complete - it leave a data socket open
17:02jtackettdo you put that in the view?
17:02justin_smithso they get the page immediately, and the rest of the data as soon as it is ready
17:03jtackettcan i use hiccup for that?
17:03J_ArcaneInstarepl is cool.
17:03justin_smithjtackett: hiccup is orthogonal to this
17:03justin_smithjtackett: the issue here is that you need to return a page right now, and later you need to send more data
17:03jtackettso what code do I put where? haha
17:04jtackettin a view / handler set up
17:04justin_smithjtackett: http://http-kit.org/server.html#websocket this is an example, not all ring backends support websockets
17:04ired_44amalloy: i think it's specifically to resolve the var
17:05jtackettperfect thank you
17:05danielcomptonServer sent events might also be an option here
17:05justin_smithdanielcompton: true
17:05ired_44amalloy: I tried using fn?, but it always evaluates to false
17:05danielcomptonjtackett: you get a callback in the browser when new data comes from the server
17:05justin_smithdanielcompton: if you look at that http-kit example, that is what you are actually doing
17:05zanestbaldridge: I always want to do the set!, though. So I’d have to build retry logic manually?
17:06zanesI feel like I’m missing something still.
17:06danielcomptonYou wouldn't be doing a whole page reload but could get the same effect
17:06justin_smithdanielcompton: on a semantics level, if not on the impl level
17:07danielcomptonjustin_smith: right. I think i'd prefer SSE for that scenario because it stays in HTTP land
17:09danielcomptonjustin_smith: unified async/websockets looks cool http://http-kit.org/server.html#channel
17:11ired_44amalloy: do you know if there's a better way to determine whether something is a function, within the body of a macro?
17:12SagiCZ1.
17:12SagiCZ1,"."
17:12clojurebot"."
17:12J_Arcane#clojurescript
17:14zanesi.e. Is there a more succinct or idiomatic way to do this? https://gist.github.com/zane/d28a4b49935dd23d7612
17:15hiredmanwell, a. don't mix atoms and the stm
17:15hiredmanatoms are non-transactional, that dosync does nothing
17:16zanesHmm. I should probably read up before asking this question.
17:16hiredmanyep
17:19amalloyired_44: well, what you're doing is just fundamentally both weird and difficult. there are a lot of edge cases you're going to miss with your current approach
17:21amalloylike, consider (docprint (let [map {1 2, 3 4}] (count map)))
17:23dorkmafiais there a lein rc or anything?
17:24technomancydorkmafia: no, but current master will probably become 2.4.4 as soon as we are confident in its stability
17:25ired_44amalloy: good point. hmm, do you think some kind of decorator macro would be a good idea? e.g.. choose the functions that I want to docprint and redefine them to a wrapped version... something like: (decorate! docprint-fn [fns...])
17:25zaneshiredman: https://gist.github.com/zane/d28a4b49935dd23d7612
17:25amalloyired_44: that would be a much more viable approach. but you could probably just find some pre-built solution, like tools.trace or something, for that
17:26technomancydorkmafia: would be great to get some folks using it and giving it a sanity check
17:26amalloyired_44: the reason, by the way, that your macroexpand doesn't work is that macroexpand runs at runtime rather than compile time, and in the clojure.core namespace instead of in the namespace you compiled it from
17:27amalloyalthough actually when i run all this in my repl it *does* work as you intend
17:28ired_44amalloy: yeah I was confused by that. also, I was able to define other functions that it would expand, but not elect-n, and it seemed arbitrary
17:33dorkmafiatechnomancy: ah i meant .leinrc like a bashrc lol not release canidate sorry about that :) I am trying to make the up arrow show my previous command and <c-r> be the reverse search
17:33ired_44amalloy: I was looking at this decorate code: https://github.com/weavejester/decorate/blob/master/src/decorate.clj
17:34technomancydorkmafia: haha, oh. ok. yes, leiningen has several configuration files, but none of them should be needed to get the behaviour you're describing.
17:35amalloyired_44: solution: stop looking at it. something weavejester hasn't touched in five years is not a great thing to model future programs on
17:36danielcomptontechnomancy: why is the Gilardi Scenario called that?
17:36amalloydanielcompton: gilardi thought of it first, or popularized it, i always imagined
17:37technomancydanielcompton: because we were debugging this problem for like two days, and then we hired Steve Gilardi, and basically the first thing he did after starting was explain exactly what was going on and how to fix it.
17:37noonianlol
17:42xeqi.. that was named after a person that is still alive?
17:43xeqiI thought it was some historic / sci-fi reference I didn't get
17:43technomancyit's named after the guy who wrote clojure.core/require
17:43hyPiRionxeqi: hahah
17:45xeqiI might already have, but didn't put it together
17:45TEttingerGilardi Scenario?
17:45amalloyxeqi: it certainly sounds like sci-fi, but we have a real live gilardi
17:46amalloyi avoid mentioning his first name because i forget if he likes steve, steven, or stephen
17:46hyPiRionI would probably guess the same thing if I didn't see commits by gilardi within lein
17:46amalloyscgilardi: you're a legend!
17:47amalloy~gilardi scenario
17:47clojurebotI don't understand.
17:47xeqihyPiRion: whats really bad is I recognize scgilardi from emails on the clojure list, but never put the two together
17:47amalloy$google gilardi scenario
17:47lazybot[in which the perils of the gilardi scenario are overcome - Technomancy] http://technomancy.us/143
17:48amalloyclojurebot: gilardi scenario |is| http://technomancy.us/143
17:48clojurebotYou don't have to tell me twice.
17:50hoangelosanyone have any experience using amazonica. Especially that are already using a truststore.
17:50hyPiRionIt's sort of like my surprise when I read http://www.tutok.sk/fastgl/callback.html without actually looking at the author's name.
17:50hoangelosI'm getting an error whenever I set javax.net.ssl.trustStore with my trustStore for my SSL enabled app.
17:51TEttinger~gilardi scenario
17:51clojurebotgilardi scenario is http://technomancy.us/143
17:51TEttingeryay
17:51dorkmafiatechnomancy: then how do i make the up arrow take me to the previous command and <c-r> preform reverse search? right now up arrow is preforming rev search
17:51dorkmafiaas well as <c-r>
17:52scgilardiI happened across the gilardi scenario again myself recently, working on "declare+" which allows declaring in other namespaces (to be used sparingly to work around otherwise circular deps). I kept wondering why code inside '(do' would work, and inside '(try' would fail. And then it dawned on me. https://gist.github.com/scgilardi/e040cd35c85cc96b9739
17:52hyPiRionThere has to be some trust store policy change for java, because I've seen people complaining about trust store issues every day the last 3 days
17:53dorkmafiamaybe it's due to inconsistencies between my inputrc and bashrc O.o
17:53dorkmafiawhat's the default behavior for lein gen?
17:54technomancydorkmafia: try moving .inputrc out of the way. the default behaviour is C-r to do a reverse search and C-p to step through history one by one
17:54technomancyit looks like the arrows are unbound out of the box
17:54hyPiRionhoangelos: I have no idea how amazonica works, but if it's ubuntu/debian-based and you can install stuff, then `sudo apt-get install --reinstall ca-certificates-java` might help
17:55hyPiRionapologies if it's entirely wrong, I have my suspicion that it may not help you
17:55technomancyhow is it even possible to install a jdk without installing the jdk's certifdicates
17:56dorkmafiayup that was the issue sorry guys
17:56dorkmafia=P
17:56mearnshtechnomancy: idk but that happened to me as well.
17:57hyPiRiontechnomancy: I have no clue, but apparently reinstalling the java certificates solved the issue
17:57hoangeloshyPiRion: no not really
17:57hoangeloshyPiRion: but thanks anyway for saying something.
17:59technomancymearnsh: what distribution/version?
18:00hyPiRionhoangelos: if it's any help, then the same issue would exist for Java and Scala as well. Perhaps googling with any of those would help
18:00mearnshtechnomancy: i believe it was with openjdk 7
18:00TEttingerhoangelos, are you starting with the recommendations that datomic makes for their usage of truststore? -Djavax.net.ssl.trustStore=path-to-truststore -Djavax.net.ssl.trustStorePassword=**T***** -Djavax.net.ssl.keyStore=path-to-keystore -Djavax.net.ssl.keyStorePassword=**K***** my-transactor.properties
18:00jtackett_what would be the easiest way
18:01mearnshmearnsh: might be a quirk of my system or package manager. but reinstall fixed it.
18:01hyPiRiontechnomancy: I recall someone using fedora
18:01technomancyhyPiRion: ah, gotcha
18:03hoangelosTEttinger: not sure what you mean by the datomic recommendations as it pertains to amazonica. HOwever, our app, which uses truststore and keystores for it's own server<->client HTTP already successfully used. But the trustStore one specifically makes amazonica fail.
18:04TEttingerI had never heard of amazonica before today, so I am not the one to ask. it does look like this is a challenge to search for
18:05hoangelosyeah. it's just a clojure library for amazon. one of the most complete.
18:05hoangelosjust a wrapper for the amazon java library
18:07jtackett_just trying to figure out the websocket
18:13dorkmafiaater you do lein repl do you need to kill it and re run after you make changes?
18:15TEttingerdorkmafia: (require '[your.ns :reload])
18:16TEttingerI think I recall the syntax right :|
18:16mearnshdorkmafia: which editor
18:16dorkmafialein repl
18:16dorkmafiaTEttinger: what if i set the main to be my namespace
18:16mearnshsorry, which text editor do you use
18:16technomancydorkmafia: you can reload from lein repl, but it's a lot more convenient to do it from your editor.
18:16dorkmafiamearnsh: vim
18:16mearnshdorkmafia: https://github.com/tpope/vim-fireplace
18:17dorkmafiaah yes all praise the pope
18:17TEttingerI wonder how I would do that in nightcode
18:17mearnshindeed
18:17mearnshshould auto connect to your repl if you start it in your project dir
18:17technomancyprotip: tpope is short for "The Pope"
18:18mearnshotherwise just :Connect and then you can use the likes of "cpr" to reload your buffer in the repl
18:21hyPiRion,(sequential? "foo")
18:21clojurebotfalse
18:24dorkmafia(:require [clojure.string :as string]) is this correct?
18:24technomancydorkmafia: it's fine for putting in the ns macro
18:24technomancyclojurebot: the ns macro?
18:24clojurebotthe ns macro is more complicated than it needs to be, but this might help http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
18:24technomancydorkmafia: ^ kind of required reading
18:25technomancythe difference between require in the repl and in the ns macro confuses a lot of people
18:32mdrogalisDoes anybody else break out the popcorn when aphyr is about to Jepsen something?
18:33dorkmafia(ns mybot.core (:require [xmpp-clj :as xmpp] [clojure.string :as string]))
18:33dorkmafiatechnomancy: yah i had glanced over that I just wanted to make sure =B
18:33jtackett_hey looking for some more help with a long running process getting return to a web page
18:34jtackett_how do you return the web page and then update it with the result of the process when it’s finished
18:34dorkmafiacause the single quote is required on the shell
18:34jtackett_?
18:35tuftjtackett_: you need some kind of asynchronous execution it sounds like
18:35tuftjtackett_: .. and a mechanism like polling or websockets on the client
18:36tuftlots of ways to do this
18:36jtackett_could i use something like sente?
18:36jtackett_what’s the easiest way to implement?
18:36jtackett_I have a project built with compojure and hiccup
18:36jtackett_in a view and handler set up
18:37tuftjtackett_: sente looks promising
18:37nick___What is the recomend way of reading in a clojure file (and get clojure data structures)?
18:37jtackett_(slurp “filepath”)
18:38jtackett_nick: (slurp “filepath”)
18:38hiredmanno
18:38hiredmanslurp is the worst
18:38L8D(slurp "uri")
18:38hiredmanslurp returns a string
18:38L8D(slurp "file://./foo.txt")
18:38hiredmanso you have the entire string in memory, and the next thing people does is call read-string on it
18:38hiredmanterrible
18:38L8D(slurp "ftp://ftp.myserver.org")
18:38hiredman,(doc read)
18:38clojurebot"([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in*. Note that read can execute code (controlled by *read-eval*), and as such should be used only with trusted sources. For data structure interop use clojure.edn/read"
18:38L8D(slurp "http://www.google.com&quot;)
18:39L8D,(+ 1 2)
18:39clojurebot3
18:39L8D,(slurp "http://jsonip.com&quot;)
18:39clojurebot#<SecurityException java.lang.SecurityException: denied>
18:39jtackett_slurp it and call it a day
18:40L8DOr just create a stream and call it a day
18:40jtackett_tuft: how would you go about setting up the websocket?
18:40jtackett_do you have a good example?
18:41tuftjtackett_: seems like sente has some good ones. i've not used it
18:41L8DSo, as JavaScript developer with mild experience in ruby/python web servers and little-to-no experience in developing with Java and Emacs, where should I start?
18:41jtackett_what have you used?
18:41jtackett_this is my first time doing web sockets
18:42tuftjtackett_: never used them actually, only polling =)
18:42jtackett_L8D: start with java or clojure?
18:42jtackett_could I use polling instead?
18:42L8DTo learn Clojure and how to setup a dev workflow with Clojure and ClojureScript
18:42jtackett_L8D: download light table and get on youtube
18:43L8DI mean...I know the semantics of LISP and all, I've just never worked with Java or Java-based languages/systems
18:44jtackett_tuft: looks like websockets are better, but I just want the easy solution for now
18:44tuftL8D: coming from ruby/python you might enjoy just using the lein repl and whatever text editor you're used to
18:44tuftjtackett_: "easy" will probably be whatever provides the best abstraction
18:44tuftwhatever library that is
18:44L8Dtuft: I've mostly worked with JavaScript/Node.js, and I have more experience with haskell than ruby.python
18:45L8Dand I'm a hard-set Vim user
18:47tufti think there's something called "campfire" for vim
18:47aperiodicL8D: fireplace.vim
18:47benmossfireplace
18:47L8Dtuft: There's a colorscheme called campfire
18:47benmosshaha
18:47tufter, hah, fireplace
18:47tufti'm using cursive with vi emulation
18:51mearnshfireplace is pretty nifty
18:51danielcomptonjtackett_: I woudl look at Server Sent Events
18:52jtackett_is there a good example project I could look at?
18:53danielcomptonjtackett_: you could look at https://github.com/ninjudd/eventual
18:55danielcomptonjtackett_: also https://github.com/ck/samples/tree/master/server-sent-events but it's using the Pedestal framework which you likely aren't
18:55danielcomptonhttps://github.com/pedestal/samples
18:56jtackett_I’m using compojure and hiccup
18:56noonianjtackett_: if you want a nice simple abstraction on websockets you should checkout chord, it models websockets as a core async channel. If you want something more robust with fallback like socket.io i would recommend sente, but that might be overkill for just getting started
18:57noonianhttps://github.com/james-henderson/chord
18:57jtackett_there has to be an easier way to do this haha
18:57jtackett_this client server stuff sucks
18:59tuftdoesn't get much easier than core async channels
18:59tuftonce you get chord working, i guess =)
19:00jtackett_hahaha ya once I get chord working
19:01jtackett_I’m just confused how to set it up
19:01jtackett_handler or view?
19:02tuftlooks like a handler from the docs
19:02noonianjtackett_: are you using clojurescript on the client? or vanilla js? on the server you will need to setup a handler, and make sure you are using a server that supports websockets like http-kit
19:03jtackett_I am using compojure
19:03jtackett_and I’m using hiccup on the client side
19:04jtackett_so just compojure and ring to do the routes, and then basically html to serve up the views/pages
19:04Jaoodhiccup runs on cljs?
19:04noonianjtackett_: you should be able to use the handler example from the chord readme (under the 'Clojure' heading) and then hook it into your server using a compojure route
19:05jtackett_Jaood: yep
19:05jtackett_and noonian: just put that into the handler file?
19:05noonianto use websockets from your client code you will need to use javascript, either normal js using websockets or if you are using clojurescript you can use chord and treat it like an async channel from the client as well
19:06jtackett_ah shit so i need js or cljs on the client side
19:06jtackett_would love to avoid learning that for now
19:06noonianyou'll need to put the requires into your namespace form, and define the handler in your handlers file, then hook up the handler to your routes; something like (defroutes ... (GET "/my-ws" req (your-chord-handler req) ...)
19:07nooniani think you could use chord on the server side and just use vanilla js websockets if you are using a browser that supports websockets
19:07jtackett_then what would call that get request in the client end?
19:07noonianyou might want to read about JavaScript websockets
19:07jtackett_i def will
19:07dbaschjtackett_: or cljs, for example https://github.com/ptaoussanis/sente
19:08noonianvar exampleSocket = new WebSocket("ws://www.example.com/socketserver", "protocolOne");
19:08noonianhowever, the beauty of cljs is that if you already know core async then you don't have to know a thing about websockets heh
19:08jtackett_dbasch: that’s what my co-worker told me to use
19:09jtackett_ya i will probably go with sente
19:09jtackett_just need to figure it out
19:09jtackett_is there no other way to just fill in the text when the process finishes?
19:10noonianroughly: sente is to chord as socket.io was to websockets
19:14amalloyjtackett_: if you want to send an un-finished page to the client and then fill it in when the server's done with some other work, you have to have the client talk to the server somehow
19:14noonianjtackett_: you could poll the server until its finished using normal ajax requests
19:14amalloyif you're content to wait until the server-side process is done before sending anything, then of course it's easy
19:15jtackett_haha I’ll just make the jump and figure out sente
19:39dbaschjtackett: if you want to hack it as a proof-of-concept, you could have a frame that refreshes itself every X seconds
19:53danneu,(str #inst "2014-09-08T23:00:27.485207000-00:00")
19:53clojurebot#<SecurityException java.lang.SecurityException: denied>
19:53danneui like how str/.toString truncates data from the string that's in the literal
20:12qqcan I use clojure "get" on "java.util.Map"
20:13technomancyif only there were a way to attempt to perform this action and record its results, which could confirm or deny a constructed hypothesis
20:15technomancyerr--I mean...
20:15technomancytry it and see?
20:20danneuif i have a java.sql.Timestamp represented with the literal `#inst "2014-09-08T23:10:58.915549000-00:00"`, is there a trivial way to get the string that's in the literal?
20:25dbaschdanneu: pr-str
20:26amalloydanneu: (subs (pr-str sql-nonsense) 5) or something
20:28danneurofl
20:28danneuthanks
20:48joobusare there more clojure practice problems similar to clojure koans? I finished the koans.
20:52amalloyjoobus: 4clojure.com is one
20:52amalloyor you can do project euler in clojure (euler is back online again, right?)
20:56llasram,(binding [*data-readers* {'inst identity}] (read-string "#inst \"2014-09-08T23:10:58.915549000-00:00\""))
20:56clojurebot"2014-09-08T23:10:58.915549000-00:00"
20:59joobuswas just looking at 4clojure. it would be nice if the problems were doable offline, in a text editor and the repl. The web interface isn't ideal. thanks for the tip :)
21:00bbloomjoobus: just do the problems locally and then copy paste to do final verification
21:13amalloyjoobus: there are numerous tools people have devised to automate the process bbloom recommends, as well
21:13amalloya few lein plugins, an emacs mode or something...
21:43joobusi went with solving project euler problems, thanks amalloy :)
21:47clj-newbI see examples of private functions as (defn- and (defn ^:private defn- seems deprecated, but I can find no documentation to confirm this
22:08technomancynah, it's not
22:30ncthom91hi all. I'm brand new to clojure, and actually mostly interested in clojurescript, but I can't figure out how to find all matches in a string with a given regex
22:31bbloom(doc re-seq)
22:31clojurebot"([re s]); Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), each such match processed with re-groups."
22:32ncthom91bbloom perfect, thank you :)