#clojure logs

2013-05-08

00:23devnHow did I miss the-ns for so long?
00:26Raynesdevn: Because you never tried to break clojail. ;)
00:26RaynesWe have a long history of abusive namespace hackory based around the-ns.
00:28technomancygdev: you only use emacs for one clojure project?
00:28gdevtechnomancy, yeah, one at a time
00:29Raynestechnomancy: I'm curious how many people use multiple vim instances.
00:29RaynesIf I had to use more than one I'd cut people.
00:29technomancyRaynes: I thought everyone did?
00:29RaynesI certainly don't
00:30RaynesHave no reason to.
00:30technomancybecause then you can make fun of emacs's >1s startup time
00:30RaynesI open things in split buffers, tabs, etc.
00:30RaynesAnd you can of course switch to background buffers like with Emacs.
00:30technomancyso you have like your work buffers in the same buffer list as your OSS stuff?
00:31RaynesMy work *is* open source.
00:32RaynesI don't think I've worked on a single thing not open source since I got to Geni.
00:32technomancynice!
00:32technomancygood work if you can get it =)
00:32technomancybut I mean your work projects and side projects
00:34gdevi'm still trying to understand the original question; what gave the impression that I only use emacs for one project?
00:35technomancygdev: otherwise having nrepl launch on emacs boot would be pretty annoying
00:36gdevtechnomancy, ah, well usually when I'm opening emacs its to edit a clojure file; even if I wasn't it wouldn't bother me having it going
00:36technomancyright, but each project will have a different classpath
00:37technomancyI guess if you always had a .clj file as the argument to emacs it could work
00:37arrdemI tried to have nrepl open whenever I edited a .clj but I didn't get it right :/
00:38gdevso my workflow would be, cd <project dir>/<src dir>, emacs core.clj, ??? profit
00:38gdevwhat could possibly go wrong?
00:38technomancygdev: guess it's fine if you never use gui emacs
00:39technomancyI have it so emacs starts a shell when it launches
00:39technomancythen I cd to the project and hit C-c C-j for jack-in
00:41gdevwhat I'm trying to do now is if I'm in a file and i hit C-x C-e, instead of saying "no lisp subprocess" it just says "starting nrepl-jack-in"
00:42technomancy(eval-after-load 'clojure-mode '(define-key clojure-mode-map (kbd "C-x C-e") 'nrepl-jack-in)) ; maybe
00:47gdevi'll have to put that on my to-do list for tomorrow. I have a rule, no configuration changes after 10 pm.
00:48arrdemgdev: that's one way to keep insomnia at bay
00:49gdevarrdem, yes and also not having to deal with that awkward moment when you wake up the next morning face down on your keyboard and when you look up you've noticed your config folder has turned into a pumpkin
00:50arrdemgdev: ah a friend of mine _wting realized that having a ~/conf dir which is git controlled and symlinking from there helps keep config pumpkins at bay
00:52technomancydinc
00:52technomancythat is to say, double inc
00:53arrdem(def dinc (comp inc inc))?
00:54technomancyexactly
00:54technomancyclojurebot: oinc?
00:54clojurebotoinc is octo-inc: (apply comp (take 8 (repeat inc)))
00:54arrdem(inc clojurebot)
00:54lazybot⇒ 23
01:05gdev,((#(apply comp (take % (repeat inc)))20)22)
01:05clojurebot42
01:05gdevodd way to add two numbers
01:31tomojdnolen: so any thought on whether supporting with-bindings* etc alongside existing binding macro (i.e. no var reification, just a bit of ugliness to let {push,pop,get}-thread-bindings get/set the values of dynamic vars) is on the table?
01:32dnolentomoj: I'm not likely to look at anything related to vars until we're much closer to bootstrapping.
01:33tomojah, well, I realize I can just throw them in my library then
01:33tomojsince no changes to existing stuff is required
01:37tomojand people who use binding will still get the benefits, and they have no need to use {get-thread-,with*-}bindings, nice
02:04tomojoh, shit, actually, I needed to change the emit for :def
02:04tomoj:(
02:04tomojso core-async will be pended on bootstrapping (or will just not work with dynamic scope)
02:08tomojwell I guess I can define a macro which adds existing dynamic vars (e.g. *print-fn*) and lets you define new ones
02:09tomojcore-async seems capable of giving us generators
02:09tomojquestion is, do we even want that? :)
02:10tomojI'm guessing no..
02:48devngood evening gents
02:49devnanyone else feel like the reader page gets way too many questions and there seem to be many variations on the answers people receive?
02:55devnyogthos: howdy
03:04ciphergothdamn, compojure generates a lovely function which handles requests as they arrive, but no statically available information on what my routes and endpoints are
03:04ciphergothso when I want to say "redirect to over here", I repeat myself specifying the URL
03:05callenciphergoth: you can return the result of passing the request to the intended function too.
03:05callenciphergoth: somewhat like middleware.
03:06callenciphergoth: that doesn't return an HTTP 3XX though.
03:06ciphergothcallen, oh you mean instead of redirecting?
03:06callenright, but you could write a wrapper that does a redirect-fn and sets the status to 3XX and spits out the alternate result by fn.
03:06callenwould take maybe...120 seconds to write.
03:06ciphergothright, but I want to do much more than redirecting, like including links in "href=" and "action="
03:06callenor less.
03:07callenI have my own ideas on how to handle that, but I doubt they apply to your use-case.
03:07ciphergothThink you'd need something that wasn't compojure!
03:08callenerm, no. I'm fine with Compojure.
03:08callenI just bundle up my routes and ship them into a universal rendering context
03:09callenthat then gives me the ability to define purpose-oriented referents for the URLs
03:09callenbut, I usually don't need to do that, because I'm not an idiot and don't change URLs.
03:09ciphergothwell, you do a (defroutes foo this that) and then a (defroutes (context "/admin" [] foo))
03:09ciphergothand it's not until the latter is written that you even know what the url for "that" is
03:09callennot quite. It sits on the template rendering side.
03:10ciphergothI'm not planning on changing my URLs, I just prefer to write code in a way that adheres to DRY and makes it harder for me to make mistakes!
03:10callenI feel you, I just don't see why you can't solve your problem.
03:11callenciphergoth: you need to understand that Lisps in general, Clojure included, are not omakase like Rails.
03:11ddellacostaciphergoth: it sounds like you are looking for something vaguely like Rails "rake routes?"
03:11callenciphergoth: you are expected to prepare your own dishes from the materials provided and craft precisely what you want.
03:11ciphergothI have never used Rails
03:11ddellacostaokay, nevermind.
03:11callenYou will not be provided a best-practices 100% all possible use-cases imagined framework for everything.
03:12callenwe even abandoned the one remotely serious micro-framework for a template oriented framework instead because it lent more power to the programmer.
03:12callenwe just don't...need that stuff.
03:12callenciphergoth: it's all data, write your own code to do what it is you have in mind.
03:12callenciphergoth: what are you using for templates?
03:12ciphergothenlive
03:12tomoj'omakase' good word
03:13ddellacostaI think DHH uses it a lot
03:13ddellacostaI wonder if he likes sushi.
03:13callentomoj: it's apropos and apolitical (no value assignment).
03:14ciphergothI'd be interested to hear what other people have done in their web applications
03:14callenI don't have any strong opinions one way or the other as it regards omakase frameworks, I've used those and I've used more minimal stacks and been happy with both. Nevertheless, I have to describe it without getting peopled riled up.
03:14tomojexcellent
03:14callenouch @ enlive.
03:14ddellacostaciphergoth: if there is one thing I've found it seems like most people are using a big variety different libraries in the web space to solve their problems
03:14callenciphergoth: I have a simple CMS on github.
03:14ddellacostavariety *of*
03:14ciphergothit seems like lots of people must have felt the need to create an endpoint with a URL in one place, and create a hyperlink to it in another place
03:15ciphergothso I'm keen to know what sort of dishes people have prepared for themselves with the ingredients provided to address this :)
03:15ddellacostathe thing is, I don't know if we'll ever have these big over-encompassing "CoC" frameworks in Clojure
03:15callenddellacosta: pedestal'ish.
03:15callen'ish.
03:15ddellacostawell, compojure/ring is quite common, obviously
03:15ddellacostayeah, pedestal…I have to learn more about it. It scares me a bit, I'll admit. haha
03:16callenciphergoth: I don't have anything open sourced that addresses your specific thing. I would strongly recommend reconsidering enlive so that it's easier to handle things like the concept of a "template context" without doing repetitive whole document processing.
03:16ddellacostaI think Noir did a bunch of stuff nicely, but the way it implemented some things was too side-effect intensive
03:16callenddellacosta: myself and most other clojure web devs aren't impressed.
03:16ddellacostacallen: re: Noir?
03:16callenno, Pedestal.
03:16ddellacostaoh, pedestal?
03:16callenI was fine with Noir.
03:17ciphergothOK so supposing I was using the templating system of your choice, what might the solution look like?
03:17ddellacostaah, yeah, again, I haven't dug into it yet
03:17callenI use compojure/ring/libnoir/luminus now.
03:17ddellacostayah, that seems like a solid stack…
03:17callenciphergoth: Clabango, which resembles Jinja/Django templates. I have a universal render-template function that handles template context.
03:17ciphergoththat sounds great, how does it address this issue?
03:17ddellacostaciphergoth: there is another question here which is, are you doing client-side-heavy development or server-side templating?
03:17callenciphergoth: if I need to add global or template context, it's simple to do so. In the process, I can munge my routes to provide injectable/renderable aliases for routes.
03:18callenddellacosta: I highly recommend Luminus if you need ideas on how to structure a Clojure web app.
03:18callenIt's quite nice.
03:18ciphergothhow does a template context help here?
03:18callenciphergoth: I described a possible solution above.
03:18ddellacostayeah, I've poked at it a bit, but otherwise just rolled my own stuff w/compojure
03:18callenciphergoth: read what I said.
03:19callenddellacosta: I poked and prodded yogthos as he's been developing Luminus. Got him to switch template libraries, bwahahahaha. :)
03:19ddellacostawhat was he using before?
03:19callenddellacosta: hiccup.
03:20ddellacostaah.
03:20ciphergothcallen: you mena the bit that starts "I just bundle up my routes..."
03:20callenciphergoth: da comrade.
03:20callenddellacosta: I've been doing web dev solo and in a team context long enough that I'm wary of anything that doesn't put my html in a file that ends in .html
03:20ddellacostacallen: haha
03:20callennormally that would mean enlive, but enlive is awful.
03:21ddellacostacallen: actually, I pretty much agree. What don't you like about enlive though? (I have my own feelings about why that is as well...)
03:21ciphergothHow do you "bundle up your routes" in compojure?
03:21ciphergothAll compojure gives you is a function that responds to requests
03:21ddellacostaciphergoth: you mean, other than using defroutes?
03:21ciphergothhow is that useful at render time?
03:22ciphergothddellacosta, defroutes composes several functions into one, but I don't see how to use what it generates at render time
03:22ciphergothno matter what templating system you have
03:22ciphergothI don't see a way to query what defroutes creates to extract a URL I can then use in a template
03:23callenciphergoth: split the data structure out and inject it into the defroutes after the fact.
03:23ddellacostaciphergoth: sorry, I'm jumping in on the conversation late, but what exactly are you trying to do? You can get route info in the request map
03:23callenddellacosta: wants URL/handler aliases or something that he can inject client-side into the HTML.
03:24callen(url "handles-stuff") => "/handles/stuff/?true
03:24ciphergothnot necessarily client-side
03:24callennot literally client-side
03:24ciphergothserver-side at the moment actually
03:24callenI mean in HTML viewed by the client
03:24ciphergothright
03:24callenrendered server-side
03:24ciphergothyes
03:25ddellacostaciphergoth: so, you want your url to be like callen's example (url "handles-stuff")
03:25ciphergothSo I refer to URLs in two places: one where I write (GET "....") and the other where I set an href property on an "a" entity. I'd like ot not repeat myself
03:25ddellacostabut be represented otherwise (/handles/stuff/?true) ?
03:25callenciphergoth: write the code you want.
03:25callenciphergoth: you're spending more time discussing it in IRC than it would take to implement, seriously.
03:25ciphergothOK so nothing currently exists to do this, if I want there to be a library with this property I should write it myself.
03:25ciphergothI'm surprised!
03:26ciphergothcallen: that really isn't my experience. If someone else had written a solution it would be far more stable, better thought out etc than what I would write when I first thought of the problem.
03:27ddellacostaciphergoth: I guess I don't get it--if you have a map of your routes somewhere, you can just easily pull out aliases. If they are systematized, then it's just a transformation of the route information.
03:27ciphergoththis seems like a need that every single webapp would need, so it's weird that no-one has written a framework that makes it easy.
03:27ddellacosta...
03:28ddellacostaciphergoth: it seems like just a simple function to me, so maybe that's why there isn't a library for it. But maybe I'm still not understanding what you are trying to do.
03:28ciphergothwhen you say a map, you mean a literal Clojure map?
03:28ddellacostaciphergoth: yes.
03:28ciphergothright, so instead of using the macros compojure provides, I should put all my routes in a map
03:28ciphergothcompletely work around compojure basically
03:29ciphergothwrite my own way of compsing route information togethe
03:29ciphergothI can do that, but I just would have thought someone else woudl already have done so!
03:29callensimple function/macro.
03:29tomojI did my own routing thing too..
03:29callenciphergoth: that's not the attitude Lisp hackers tend to take.
03:29ciphergothwill do something ugly for now. Thanks guys!
03:30callenciphergoth: you're being overly schlep sensitive and need to just "get 'er done"
03:30callensigh, gone anyway.
03:30callenso whiny.
03:30ddellacostaI still don't think I understood what he wanted.
03:30ddellacostait seemed too trivial to be under discussion…but I probably didn't get it.
03:31ddellacostaanyhow, gotta run, cheers mates
03:31callenddellacosta: toodles.
03:31callenI understood what he wanted, I just didn't understand why it was so hard to just do.
04:05winkis public/resources somehow special to lib-noir? can't find why I can't slurp outside of that dir...
04:20winkah. grep failed me...
04:28Glenjamin_Hi guys, is there a function like seq that returns strings?
04:28Glenjamin_eg (??? "string") => "string" (??? "") => nil
04:29Glenjamin_so i can do something like (or (??? potentiall-empty-string) "default")
04:31mthvedt(if (seq? %) % nil)
04:31mthvedtsorry
04:31mthvedtseq not seq?
04:31FoxboronGlenjamin_: you could use empty?
04:31Foxboronthen wrap that around something
04:31edoloughlinOr clojure.string/blank?
04:32edoloughlin,(doc clojure.string/blank?)
04:32clojurebot"([s]); True if s is nil, empty, or contains only whitespace."
04:32Glenjamin_yeah, mthvedt's approach seems sensible - was checking if there was a core functions which already wraps the pattern
04:33mthvedti sometimes wish there was a core function that did that
04:33Foxboronmake your own :)?
04:34amalloy&(doc not-empty) ;; Glenjamin_
04:34lazybot⇒ "([coll]); If coll is empty, returns nil, else coll"
04:34Foxboronohhhh
04:34Glenjamin_(def some-str #(when-not (clojure.string/blank? %1) %1))
04:34Glenjamin_oo
04:34Glenjamin_,(or (not-empty "") "default")
04:34clojurebot"default"
04:34noidiI don't think a string-specific function would be as useful as seq
04:34Foxboronamalloy: and thats the function that came right after "empty" in the quickref
04:34Glenjamin_huzzah!
04:35noidiwith seq, you don't pass it a seq but something seq-able
04:35Glenjamin_not-empty seems very similar to seq, but without the cast to a Seq type
04:35Glenjamin_which is exactly what I was after in this case
04:36noidioh, cool
04:37Glenjamin_,(inc amalloy)
04:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: amalloy in this context, compiling:(NO_SOURCE_PATH:0:0)>
04:37Glenjamin_(inc amalloy)
04:37lazybot⇒ 53
05:07AWizzArdVia “lein localrepo” I installed jcuda and jcublas, cause those libs are not available in any Maven repo. This worked nicely, until today. Now I get the message that Leiningen could not transfer the artifacts from central. I want Leiningen to just take what it has in ~/.m2 and only contact central if something is missing. Ideas?
05:13edoloughlinAWizzArd: have you tried asking on #leiningen? I've not done this with lein but I had similar problem on a Java project (using Apache Buildr). I set up a private remote repo and deployed to that. I see it might be possible to do this with lein: https://github.com/technomancy/leiningen/blob/stable/doc/DEPLOY.md
05:15edoloughlinBuldr tried the Maven repos and then fell back to the private remote...
05:15AWizzArdHmm I see.
06:01mccraigalia vs cassaforte experiences anyone ?
06:07shriphanihi. I am trying to create an infinite list using this: (def dates-list (concat (list start-date) (list (clj-time/plus (last dates-list) (clj-time/days 1))))) But the list only has length 2. Isn't referencing dates-list sufficient to create an infinite list ?
06:10stainnot sure what you are trying to do.. but (last dates-list) would just evaluate to the last element of the previous binding of dates-list
06:11stainyou would not want to look for the last element of a truly infinite list anwyay ;)
06:11shriphanistain, I just want a sequence of dates.
06:12shriphaniI expected it to lazily generate the next one as needed.
06:12mccraigshriphani: try the iterate function : (iterate (fn [old-date] (make-a-new-date old-date)) first-date)
06:13shriphanimccraig, is there a way to do it using just the lists though ?
06:15mccraigshriphani: not sure what you mean
06:15edoloughlinshriphani: why not implement something using lazy-seq?
06:15edoloughlin,(doc lazy-seq)
06:15clojurebot"([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. See also - realized?"
06:15staindo you want to call (nth) on it?
06:19shriphaniumm no. I wanted to try out somehting like this: let x = 1 : map (2*) x (that is haskell code)
06:21mccraigshriphani: (iterate #(* 2 %) 1)
06:21tomoj#3 question to ask rich if I ever get to talk to him: which dictionary do you use? :)
06:21mccraig,(take 10 (iterate #(* 2 %) 1))
06:21clojurebot(1 2 4 8 16 ...)
06:27AWizzArdWhen I make a closure (let [size 8] (defn ...)) then `size` is used as a final constant and needs no lookup time during runtime. Can I achieve the same with a def?
06:29clgvAWizzArd: yes there is ^:const
06:29clgvAWizzArd: (def ^:const pi 3.14159)
06:29AWizzArdVery good, thanks.
07:22zackzackzackHow would I go about dynamically redefining clojure.test/test-var to do something else?
07:25zackzackzackNevermind! Somebody had the foresight to make it dynamic
08:36mpenetmccraig: yeah :p but I might be biaised
08:37mpenetmccraig: imo alia is more production ready atm and covers more features (async, more config options). The main difference between the 2 libs is the api other than that, cassaforte aims to be a bit higher level, alia forces you to use execute, prepare and so on (which is a good thing imo).
08:38mpenetmccraig: under the hood both lib use the same query dsl (hayt, it's a shared library), so you can switch between the 2 quite easily anyway
08:39mpenetmccraig: both are resonably documented, but I expect the clojurewekz guys to create tons of guides soon.
09:11mpenetjust checked, cassaforte has no way of setting consistency or any per query option atm
09:47gdevhas anyone done any remote pair programming on clojure? No one in my office knows clojure or does pair programming so remote looks like my only option
09:47gdevjust curious about how to set up my workstation for it
09:48ucbgdev: you can share a tmux screen
09:48ucbs/screen/session/
09:48ucbgdev: alternatively, you can try with screenhero
09:48ucbI'd also recommend a voice channel, e.g. skype
09:49gdevoh wow, screen hero looks cool
09:49ucbyeah, it mostly works too
09:50ucb"mostly"
09:50duck1123unless you're on linux. :(
09:52gdevduck1123:) yea i just noticed that in the FAQ
09:53gdevit also has a link to contact them if you want them to support other platforms so start the penguin email storm and they migth implement it for nix
09:55gdevalthough, I haven't tried it using wine
09:55tsdhIs it possible to declare generic parameters with gen-class, e.g., Map<String,Integer> instead of just Map?
09:56ucbgdev: you could always run a vm with ... never mind ;)
09:57gdevtsdh:) did this not answer your question? http://stackoverflow.com/questions/3688730/how-to-pass-a-typed-collection-from-clojure-to-java
10:00gdevI really need to create a stack overflow account. That way I can post my questions on there and then link them in this channel
10:01tsdhgdev: Ok, there doesn't seem to be a way except for writing a Java interface first and then making the gen-class-ed class implement that.
10:02gdevtsdh:) yeah when you're dealing with gen-class it has to be AOT compiled so it needs a lot of ceremony to do what you need
10:05tsdhgdev: Yeah, just now I have to provide some student with a simple interface to my clojure lib. Just a few static methods that return maps. So for now, I'm keeping them to return just Map, although on the java side one would expect Map<String,SomeOtherType>.
10:05tsdhThat's good enough, since he only needs that for testing purposes.
10:06gdevcan you post the code on refheap.com ?
10:10tsdhgdev: Sure. https://www.refheap.com/paste/14302
10:41pjstadigi just used juxt
10:45pjstadigis there a schedule for the 2013 Clojure/West videos yet?
10:47pjstadighttps://twitter.com/ClojureWest/status/326455152586420225
11:22tomojoh, CFP for strange loop done tomorrow?
11:24Bodiltomoj: Yep.
11:24bbloomtomoj: ooh, the last day is tomorrow? hmmm probably should get on that...
11:26tomojI wonder how bad an idea it is to submit one when you haven't quite solved the problem yet
11:28Bodiltomoj: fwiw, I'm submitting an ELC talk on a language I haven't really written yet. It's a great way to make sure you get things done by September. :)
11:29tomojah, btw, I'd love to see your talk - can't remember whether I decided it was worth pinging you or not, but I was going to tell you that I have often fantasized about that language you're making :)
11:30BodilSo far it's just my fantasy too... needs a bit of work. :)
11:34ejacksonBodil: cgrand calls it TDD - talk driven development :)
11:35winkbetter than hope or desperation driven
11:35bbloomwink: that's what occurs on the plane ride to the conference
11:35winkhehe
11:35winkyep
11:36ejacksononly when you're lucky...
11:36Bodilejackson: Hah, very true. :)
11:37jtoycan anyone show me how if I had to update a count as im reading through a large file, how I would do it? I think i need to use some imperitave programming or use refs?
11:38gfredericksyou're reading lines from a file?
11:38gfredericksjust for the sake of producing this count?
11:38jtoygfredericks: im running some analytics on each line and based on the reults i want to update the counter
11:38jtoyyes
11:39gfredericksthat sounds like you could create a line-seq and just reduce over it
11:41jtoygfredericks: yes, that does sound right, it looks like reduce will make the result turn non-lazy and give methe number i want
11:41gfredericksbut the laziness still lets you process the file in a streaming fashion
11:41justin_smithI heard Hickey talk about Hammock driven development - that is when you are motivated to code for a conference in a tropical location, right?
11:42jtoygfredericks: ok, i'll test it
11:42bbloomjustin_smith: heh. i think hammock driven development is a programmer centric view of the "open mode" discussed in John Cleese's (awesome & hilarious) lecture on Creativity: http://vimeo.com/18913413
11:43justin_smithbbloom: yeah, but it seemed to fit this conference talk nicely
11:43bbloomjustin_smith: it did, i just needed an excuse to link to john cleese
11:45jtoygfredericks: I am collecting a couple of different numbers, so I dont think I can use reduce? is that correct? I thikn i still would need to increment?
11:45justin_smithjtoy: you can reduce into a vector or map
11:46jtoyjustin_smith: could you show me a simpe example of just that? Im not sure how that would work exactly
11:47justin_smith(reduce (fn [[a b] x] [(inc a x) (inc b (/ x 2))]) [0 0] [1 2 3 4 5 6])
11:47justin_smithjust define the reduce fn to take an array and return one
11:47justin_smith(or map or whathaveyou)
11:48justin_smithoops, change inc to + above, but that is not the important part of the example
11:49jtoyi see
11:50justin_smithwhen I want to gather data about a sequence I define a simple data structure that will hold the result and any intermediary values I need, then a function that takes and returns that structure, then I fill that function in to update the structure as apropriate for each element
11:50jtoyjustin_smith: great, I will use this method
11:51tomojif pedestal has a god map, does angular have a devil map?
11:53justin_smithlemme guess, god map is a rewrite of global state into a single data structure in order to make a library re-entrant?
11:53tomojI'm not terribly sure I understand the pattern (nor pedestal), but that sounds right
11:53AnderkentDoes anyone know if https://devcenter.heroku.com/articles/debugging-clojure is still up to date? I'm getting errors when trying `lein repl :connect http://server/url`
11:53tomojit's the Big Atom in the Sky
11:54tomoj(nor "re-entrant")
11:55justin_smithtomoj: I have seen a number of libs do this - a lib is written so that it refers to some global state inside the lib, and that works until someone wants to instances of what the lib does
11:55justin_smithre-entrancy is the ability to make two objects defined by some stateful library side by side without them messing each other up
11:56tomojhmm
11:56justin_smithso they create a state object/hash and shove all the globals in there (and add an extra arg to everything / create a special var / whatever)
11:57justin_smith*two instances of what the lib does
11:57tomojI see
11:57tomojwith pedestal you wire up all these pure functions and explicitly describe the connections between them and the model, and then it just runs them in a state-monad-ish way. I suspect it should have no problem running two instances
11:59justin_smithwe had to do this same thing recently when we realized our in-house lib was storing an atom referring to db config
12:00justin_smithbut if two parts of one app wanted to use different dbs?
12:00justin_smithboom, move the config out of a single atom in the lib into an arg / special var
12:00tomojright
12:00tomojlike the java.jdbc issue?
12:00justin_smithyeah
12:00justin_smithexactly
12:01justin_smiththe hilarious part is we were using clojure.java.jdbc, and the atom was supposed to be simplifying things
12:01justin_smithin the end we realize that was the right way all along
12:02tomojso in pedestal when you build a new app it has an atom in there
12:02Pure_loulouhello room :),i want to represant a graph in clojure,which data type to use?
12:02tomojbut there's no var associated with the atom
12:02tomoji.e. there is room for polytheism
12:02Pure_louloumaps is the normal way to represent a graph in clojure?
12:03justin_smithPure_loulou: there are graph libs, but I have just used a pair of maps, one describing nodes, the other describing edges
12:04justin_smitheach node/edge having keys to look up the related edge/nodes in the other map
12:04tomojthere's also inductive graphs, but I haven't seen a lib that does that yet
12:04tomojexcept my WIP
12:05jtoyjustin_smith: do you see any basic error with the way I am doing my reduce: https://www.refheap.com/paste/14308
12:06justin_smithjtoy: you are adding a boolean, which will not work
12:06justin_smithbooleans do not overload to int
12:06jtoyah, right
12:07jtoyjustin_smith: dont think it fixed my other error though, ill continue looking
12:07justin_smithI would also define the sequence separate from the reducer
12:08justin_smiththe sequence is just complex enough to benefit by standing alone
12:08jtoyjustin_smith: you mean just using let to define it to its own variable?
12:09justin_smithyeah, I tend to find bugs faster when less is generated inline
12:09justin_smith(and I think other people do to)
12:10jtoycool, ill try that too
12:32kephaleCCW question (cemerick?): is there currently a way (or a chance of a future way) of using the eclipse internal/local dependency system for external dependencies?
12:33cemerickkephale: Eclipse doesn't have a dependency system of its own...?
12:33kephalecemerick: can't you link jars from other projects?
12:33kephalefor java project at least
12:34cemerickkephale: oh, you mean adding project A to the classpath of project B?
12:34kephalecemerick: yeah!
12:34kephalenothing fancy, just for multi-project development
12:35cemerickIf you have project A set up right (i.e. so your clojure source dirs are eclipse source roots, etc), then yes. It's not automatic though.
12:36cemerickThough, you can load any Clojure file into any REPL whenever you want, regardless of the classpath. That's worked well enough for me 95% of the time.
12:37kephalecemerick: aha. good point, and that is probably better than restarting the REPL anyway
13:34chessguyhey, i'm playing with a pedestal app, because i want to show the cool tooling, but i'm missing a step somewhere. it's not generating the css somewhere. i feel like there's a lein task i need to run or something. any help?
13:40rkneufeldchessguy: You shouldn't need to do anything extra to have css work. Have you generated a new project or are you in one of the samples?
13:40chessguyrkneufeld: i'm in the todomvc example
13:41chessguyrkneufeld: the styles look right if i go to the dev link, but if i go to design mode, or render, it doesn't look right
13:42chessguyrkneufeld: and if i (watch :dev) i get a lot of FileNotFoundException: out/public/generated-js (No such file or directory)
13:43rkneufeldchessguy: there is definitely a lot broken with that sample, I'm surprised that so many people find it ;)
13:43chessguyrkneufeld: i think it's the only one for which i've been able to get recording to work
13:43chessguyrkneufeld: any suggestions?
13:43rkneufeldchessguy: at this point we've only made it work on the dev page, fwiw - so render and design mode just plain won't work.
13:43chessguyugh
13:44chessguyit seems like it's really close to working, it's just not loading the styles
13:44rkneufeldchessguy: FYI, the chat sample in the official repo should work for recording.
13:45rkneufeldchessguy: it is pretty close - we never got around to mucking with tooling vs. app templates and getting that sorted out in the rest of the sample pages.
13:45chessguylet me try that one again
13:45rkneufeld*tool pages (not samples)
13:45rkneufeldchessguy: As the originator of that todomvc sample I would definitely say it is a bad example of many things ;)
13:46chessguyrkneufeld: well, it at least looks great :)
13:46chessguyat least, when the styles work
13:46rkneufeldchessguy: heh, the funny part is that was provided by the spec
13:47tieTYT2what's the word that means the opposite of appreciation? I regret learning clojure because it's making me feel that way about java
13:48chessguyrkneufeld: well, thanks for providing some kind of example, anyway. even a bad example is better than nothing
13:48chessguyi'm really looking forward to seeing a screencast or tutorial on pedestal
13:49rkneufeldchessguy: I'm really looking forward to making one - now that we've wrapped up the data flow engine cleanup we should be a lot closer to that.
13:49chessguyrkneufeld: oh yeah, Craig said you guys were working on wildcard-matching or something
14:35kastrupRaynes: Has anyone tried to take tryclojure and turn it into a full-fledged learning system for Clojure?
14:41gfrederickswhat fledges does tryclojure lack?
15:00kastrupgfredericks: Try Clojure is sweet--I love it, but it is more of an appetite whetter. I'm wondering if it could be used as a more comprehensive teaching tool.
15:01muhooi'm trying to read a map in from a file inside project.clj to get around a requirement by a library that it have passwords in project.clj. no luck though. (-> ".lein-env" slurp read-string :migratus) appears to show up as a list even though it is a map. java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Associative
15:01muhooi refuse on matter of principle to put passwords into project.clj and thus into git.
15:02kastrupgfredericks: I'm thinking it might be interesting to expand the material and possibly add some features (like saving a user's repl session, etc).
15:03amalloykastrup: 4clojure?
15:04amalloymuhoo: nobody can help with "this thing i'm certain is a map says it's a list, what's the deal?"
15:04muhooamalloy: true, but as i'm beating on this thing, it seems that (type) says it is indeed a PersistentArrayMap. weird.
15:04amalloythen the exception is coming from something else
15:05kastrupamalloy: Nice. Few new things under the sun!
15:06muhooaha! i see the problem. defproject is a macro, and it looks like by the time it is done, any code inside it is not executed yet
15:06solussd`xb
15:06muhoo:-/
15:07muhooi suspect ~ will be needed here, or exec. wil beat on it. sorry for the thrash
15:08muhooamalloy: thank you. ~ was all i needed.
15:20tieTYT2i have a vector and I want to compare adjacent elements and sometimes return them both and sometimes return just one of the two. Is a reduce function the best way to do this?
15:28amalloytieTYT2: try combining mapcat and partition
15:34AWizzArdI am implementing some neural network stuff using CUDA. I can store weights as floats or doubles on the GPU. The code will look nearly identical for both versions, only tiny differences here and there.
15:34AWizzArdCurrently I am using a macro “emit-cuda-defrecord” which spits out both records, implementing the same protocol.
15:35AWizzArdOnly the code looks ugly, cause we are talking about 2k - 3k LOC, full of ~ and ~'.
15:35AWizzArdAny ideas? I would love to write down the code as if I were doing only one implementation, say, for doubles.
15:36AWizzArdAnd have then some maybe not so nice looking code (20-100 loc) which replicates my implementation and replaces only a few details.
15:37tieTYT2amalloy: I'll look that up, thanks
15:39tieTYT2ah what I forgot to say is, if I've got [1 2 3] I want to compare 1 to 2, and then the result of that to 3
15:40tieTYT2ah partition can do that
15:40AWizzArdsymbol-macrolet maybe?
15:43amalloyAWizzArd: i don't think anyone knows enough about your problem yet to give meaningful advice
15:45AWizzArdamalloy: think of a defprotocol for matrices with 75 functions. I want to provide several implementations of this protocol. One that uses pure Java and runs everywhere, one that uses blas and is faster but needs some extra installation, and one that uses cuda.
15:45AWizzArdamalloy: in those 75 FNs I work with double-array calls and such. I could have two cuda implementations, and not just one.
15:46AWizzArdOne that uses doubles on the GPU, and one that uses floats.
15:47AWizzArdI basically want to have 2x 75 FNs, where in the replication a few names were changed.
15:59mthvedtmaybe there's some clojure templater that can template code?
16:01AWizzArdI think for now I will go with the implementation that uses doubles, and see later if floats are worth the effort.
16:02muhoowow, all the little gems hiding in the clojure ecosphere: https://github.com/joegallo/robert-bruce
16:02muhooi was just writing some hack to retry clj-http on error 406 to deal with a broken site, and thinking "wow i wish someone had already thought of a way to to this", and here it is already
16:08tieTYT2is there a way to make clojure output more information in its exceptions? eg: clojure.lang.ArityException: Wrong number of args (1) passed to: core$reduce would be so much better if it told me the type that's being passed in
16:13dnolentieTYT2: that would be nice but you should have a line number for that exception
16:13recycleany idea on how to pass a clojure sequence as a command line param to main function ? (that is - prevent argv from being tokenized at whitespace)
16:18tieTYT2dnolen: I do, but if that line number is the middle of a threading macro, it doesn't help much
16:20dnolentieTYT2: ? even in a threading macro it should be pretty easy to spot the reduce that isn't being given enough params
16:30ppppaulrecycle,
16:30ppppaulIFS
16:30ppppaultalk to the #bash people or nDuff
16:32ppppaulIFS=\n
16:32ppppaulyour bash fn is going to get complicated...
16:32TimMcreiddraper: What's the plan for the meetup on Thursday?
16:32ppppaulrecycle, you can use commas
16:33ppppaul[1,2,3]
16:33tomojmuhoo: robert-bruce is nice indeed
16:33tomojor looks it
16:35tomojI want something better for rate-limiting
16:35TimMcrecycle: It really is a shell-specific question, but here's how I generate passwords from the shell: alias pw="java -jar ~/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1.jar -e '(println (apply str (repeatedly 20 #(rand-nth (map char (range 33 127))))))'"
16:35recycleyeah - escaping definitely does the trick
16:36recyclethanks!
16:36TimMcquoting
16:36TimMcescaping is backslashes
16:36recycleyep yep,sorry :)
16:42tomojTimMc: hmm
16:42tomojwould it be unreasonably paranoid to use SecureRandom?
16:49AWizzArdtomoj: it’s good, go ahead and use it
16:50tomojA better question would've been whether it's unreasonably unparanoid to use java.util.Random
16:51ppppauli have to buy my random numbers for the government
16:53Apage43tomoj: depends on what for
16:53Apage43-anything- having to do with access control or security, yes
16:54ordnungswidrigtomoj: what's your risk?
16:55TimMcI'm not worried about someone being ablee to gather enough random data from my computer to be able to predict the PRNG output.
16:56Apage43it doesn't take much
16:57TimMcA big source of leakage (I think) would be JS on a malicious web page calling Math.random()
16:59TimMcApage43: Unfortunately, for anything I *really* care about, I end up using a passphrase with (probably) much lower entropy. :-/
16:59Apage43That's probably not an issue, as Math.random() is probably just seeded around the time, and not pulling from any system RNG. At best they can predict the numbers that would be generated -on that page-
17:00Apage43which has implications if you do JS crypto (badly), but otherwise probably not
17:02Apage43typically though there has to be some locality involved
17:03Apage43e.g. if you generate two keys of some description with java.util.Random, anyone who can get the first can predict bits of the next one (and vice versa)
17:03rodnaph_hey - i'm trying to set up a browser connected nrepl session with piggieback, but i'm falling a bit flat as i think i may have misunderstood the intention of the library. does anyone have experience who could help?
17:05rodnaph_specifically - i'm expecting to be able to connect to nrepl via my editor and dynamically update and evaluate clojurescript straight to the connected browser... am i mistaken that this is what it provides?
17:14Apage43rodnaph_: you can get a cljs repl connected to a browser yes https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments
17:15Apage43What *piggieback* does is make the interaction with the cljs repl actually have nREPL behavior instead of behaving as if you evald' an expression in a repl that reads input from you, which is what you get if you follow that article
17:15Apage43piggieback is just for making running a repl in a repl a bit smoother, but it is not *required*
17:16Apage43should probably try to get set up without it first
17:16rodnaph_ok, i'll have to read that a few times i think ;)
17:16rodnaph_yah i have used the standard browser connected repl before, but i was using vim + slime + screen.
17:17rodnaph_i'm switched to vim-fireplace now, which afaik, speaks nrepl. so i was experminenting to see if it would talk to the repl -> and to the browser. seamlessly.
17:17Apage43ah
17:17Apage43well
17:18Apage43vim-fireplace supports code eval, but doesn't give you a repl buffer
17:18Apage43if you switched its repl session to cljs that -could- work.. but it might confuse it
17:20rodnaph_hmm... ok, i'm just going to keep on playing then and see what i can make work. thanks v much for the info.
17:36addywaddynewbie here :)
17:36addywaddygot a question regarding restructuring. https://gist.github.com/addywaddy/b3a19cc7f70fb33201d2. Any ideas?
17:38tomojaddywaddy: not clear what you want
17:38tomojyour second example is an error
17:38tomoj&([:a :b] [:c :d])
17:38lazybotjava.lang.IllegalArgumentException: Key must be integer
17:38tomojyou want to make sure there are 3 args and not 2? or you want to make sure the remaining args are all vector pairs? or..?
17:38addywaddytomoj: ah sorry
17:39tomojanyway easiest way to ensure the function is not called in an incorrect way is to not call it in an incorrect way :P
17:39addywaddywhat I want is to past on the list of arrays to bar expanded.
17:42tomoj(let [foo (fn [first & rest] [first rest])] (apply foo :name '([:a :b] [:c :d])))
17:42tomoj&(let [foo (fn [first & rest] [first rest])] (apply foo :name '([:a :b] [:c :d])))
17:42lazybot⇒ [:name ([:a :b] [:c :d])]
17:42tomojyou mean like that?
17:50mikerod_What is a good way to generate a tree structure in clojure when you have a root node, a function determining if a node has children, and a function that gets the children of a node? I'm thinking analogously to `tree-seq` except I don't have a tree to walk, instead I just have the root node.
17:51tomojmikerod_: that's what tree-seq expects
17:52tomojwell obviously you mean something different
17:52mikerod_tomoj: I know, but tree-seq doesn't return a data structure that represents the tree. At least that isn't what I gather from it.
17:53addywaddy:tomoj I think I need to use apply: https://gist.github.com/addywaddy/b3a19cc7f70fb33201d2
17:56tomojmikerod_: I see
17:57maleschtree zipper and node/edit
17:58gilleshi
17:59mikerod_What I mean is, tree-seq doesn't return a structure that preserves the hierarchy. It seems the intended use of tree-seq is to walk an existing tree data structure represented as root.
18:00mikerod_malesch: Thanks. I have started to explore the clojure.zip lib. I'll look into the node/edit.
18:01tomojhere's my stack-consuming version https://www.refheap.com/paste/7afe71b0e23cadf87de5a0e99
18:01tomojI think that's what you mean?
18:02tomojhmm, or https://www.refheap.com/paste/bb4fb39b2173a06def02d1e45
18:03tomoj?
18:05mikerod_tomoj: Thanks for these examples. This is along the lines of what I am looking for.
18:06mikerod_I'm surprised that there are no functions provided in core clojure that is similar to this already.
18:11tomojit sort of seems like cheating to use clojure.walk
18:12tomojthe clojure.zip idea is interesting since your args are almost the same as zipper's, except missing make-node
18:12tomojwhich is the thing that clojure.walk does for us in my example
18:13mikerod_tomoj: Yeah, I can see what you mean.
18:57tieTYT2why do the code snippets here use the int function? http://www.drdobbs.com/architecture-and-design/the-clojure-philosophy/240150710?pgno=3
18:58tieTYT2what would go wrong without it?
18:58hiredman,(int \c)
18:58clojurebot99
18:58dnolen,(- \A 65)
18:58clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>
18:59hiredman,(inc (int \c))
18:59clojurebot100
18:59tieTYT2oh right
18:59mebaran151I'm trying to get lein ritz to work but I think it's choking on the space in Program Files: here is the error I get on nrepl-ritz-jack-in: Exception in thread "main" java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified; right after the Compiling Clojurescript prints
18:59mebaran151
18:59tieTYT2jesus, this sample could be simpler
18:59mebaran151anybody here run lein-ritz on Windows with emacs?
19:16TimMc*sigh*
19:16TimMcShort-timer.
19:45gdev,(tree-seq even? inc [0 1 2 1 1 4 3 1 6 3 3])
19:45clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Argument must be an integer: [0 1 2 1 1 ...]>
19:45gdev,(tree-seq even? seq [0 1 2 1 1 4 3 1 6 3 3])
19:45clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Argument must be an integer: [0 1 2 1 1 ...]>
19:46gdev,(tree-seq sequential? seq [0 1 [2 1] 1 [4 3 1] 6 3 3])
19:46clojurebot([0 1 [2 1] 1 [4 3 1] ...] 0 1 [2 1] 2 ...)
21:05holohi
21:06holo,(apply merge-with (comp flatten vector) [{:a "ab"} {:a "ac"} {:a "ad"}])
21:06clojurebot{:a ("ab" "ac" "ad")}
21:06holois there a more concise way to return this result?
21:11Raynes$google flatland useful
21:11lazybot[flatland/useful · GitHub] https://github.com/flatland/useful
21:11Raynesholo: If you use that, there is a function in flatland.useful.seq that will let you do
21:11Raynes(s/groupings ffirst (comp val first) [{:a "ab"} {:a "ac"} {:a "ad"}])
21:11Raynes{:a ["ab" "ac" "ad"]}
21:11RaynesNot really more concise though.
21:13holo(inc Raynes) ; thanks, I think I may just get there some useful functions
21:13lazybot⇒ 30
21:24amalloy&(reduce #(update-in %1 [(ffirst %2)] (fnil conj []) (val (first %2))) {} [{:a "ab"} {:a "ac"} {:a "ad"}])
21:24lazybot⇒ {:a ["ab" "ac" "ad"]}
21:24amalloya no-dependencies approach
21:30holo(inc amalloy) ; fnil is amazing! didn't know about it. thanks
21:30lazybot⇒ 54
21:31n_b,(doc fnil)
21:31clojurebot"([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."
21:32holothis takes handling nil values to a different level
21:39mangeIs there a reason why fnil stops at three replacements?
21:43amalloyfour args is already a lot for a function; if you're worried 0-4 of the first four args may be nil, you need a more sophisticated approach than fnil :P
21:43xeqimaybe combine it with partial?
21:44mangeOr I might want something like (apply fnil f defaults) for something.
22:16benkayhas anyone worked with the clj-crypto library? it's throwing an error "No matching method found: init for class javax.crypto.Cipher"
22:19holoif map entries type is likely to deprecate, so is key and val?
22:31gdevRaynes, what is your talk going to be about and did you ever go shopping?
22:38Raynesgdev: Talk is about laser and I did not go shopping.
22:38Rayneshttps://github.com/Raynes/laser
22:38RaynesProbably going to pull an all nighter on this sucker.
22:39RaynesBecause I was too lazy to write but half of it a day before I give it. :p
22:42gdevcool, if you need any help lemme know
22:54shriphanihi. I am trying to read a gzipped text file in clojure and when I do this : https://www.refheap.com/paste/14332 , I get an array of size 4300 but doing zcat filename | wc -l gives me 8 million. What am I doing wrong ?
22:56hiredmanyou certainly don't get an array out of that
22:58shriphanihiredman, I thought for returned a list no?
23:03shriphanihiredman, I changed the for to a map and I still get 4300 only.
23:15benkaycan anyone hook me up with contact information for macourtney?
23:32shriphanihi. what is the alternative to using doall while line-seq-ing over a large file (several GBs).
23:32n_bshriphani: What, exactly, are yo trying to do?
23:33n_bapply a function to each line?
23:33shriphanin_b, I am going over a very large gzipped text file and yes applying a function to a line.
23:33n_band what does the fn do?
23:33n_bdoes it have side-effects, and do you need the return value?
23:33shriphanithe issue here is that when I use zcat <file> | wc -l , I get 8 million lines and using (doall (line-seq ..)), I get 4300.
23:33shriphanicurrently just identity
23:34n_bDo the results look right, or do they look like gzip junk?
23:34shriphaniusing zcat they look ok and the first 4300 look right as well
23:35shriphaniI am able to get lines beyond that using zcat
23:35shriphanibut I can't get > 4300 using doall
23:36shriphaniso my guess is that maybe I shouldn't use doall.
23:39n_bmy guess would actually be the GZip class not implementing bufferedreader
23:39n_band getting closed
23:41shriphanin_b, I used (reduce (fn [x y] (+ x 1)) 0 (line-seq in)) and then I got 4300 again
23:42shriphanin_b, I cast the GZIPInputStream as an io/reader and I cast that as a BufferedReader
23:42shriphaniis that wrong ?
23:44shriphanin_b, then is it possible to read that file in? It seems like a very simple task...
23:52n_bI'm honestly not too familiar with all the InputStream stuff in Java-land, just going off of former experience with reader issues
23:53shriphaniah. your estimate seems to be correct. GZIPInputStream doesn't implement BufferedReader (so says S/O).
23:54n_bI'm sure there's a UnbufferedInputStreamObjectFactoryAbstractFactoryImpl that'll solve it for you somewhere in java.util then :P
23:54tomojnaturally, it's not a Reader?
23:54shriphaniI am surprised at how java regularly shows up to make life hell for me...
23:55n_bClojure does very little to abstract away the host platform
23:56shriphaniso what is the work-around for this? Is there a way to read this .gz file ?