#clojure logs

2015-07-14

00:07divya_Hello @all. Does anyone use Datomic? I'm just getting started with it, and would like to know how I can query the history attributes on each entity and retrieve results (for statistical purposes)
00:22justin_smithit's too bad run! doesn't take varargs
00:23TEttingermaybe it will make it into 1.7.0, justin_smith oh wait
00:43SeyleriusWith the Wunderground API, folks might buy different sets of API endpoints; what's the most clojurish way to, assuming that I've configured all the endpoints as functions, limit them to the plan they've bought?
00:44SeyleriusFor example, the 10day forecast is only available on the Cumulus and Anvil plans, whereas the Stratus level users have to make do with the 3day.
00:57SeyleriusAlso, is there somewhere app-wide I can look for a pool-size configuration, or should I just let the app define it with the same config atom I'm using for my API key and purchased rate limit?
01:16SeyleriusWhat's a good default pool size?
01:27Guest25767so I decided to tech myself Ruby as a first language about a year ago and I recently stumbled upon Clojure. interesting stuff!
01:30crocketCan a simple daemon in clojure run under 16MB?
01:53Guest25767anybody out there?
01:56engblomGuest25767:
01:56engblomGuest25767: Ye
01:56engblomGuest25767: Yes
02:04Guest25767i've always had self limiting beliefs about myself being able to program
02:04Guest25767its only when i started trying to solve problems i realized it was just illusion
02:10arrubincrocket: I packaged the example code on the front page of the http-kit site up in an uberjar and ran it with -Xmx8M.
02:10arrubinSeems to work.
02:11arrubinHmm. That does not seem to limit all memory used by java.
02:16crocketarrubin, How much RAM does it use?
02:17arrubinIn Java 8, -XX:MaxMetaspaceSize controls another chunk of memory used, but I limited that to 12MB and the heap to 4M, and the overall process is still using about 40.5MB.
02:17arrubinAnd that seems to be the minimum Metaspace that still allows it to run.
02:17arrubinI do not know which other configuration options control memory, but I am guessing that getting everything below 16MB would be difficult.
02:18PupenoI’m constructing a hashmap and I want to add :port port to it, but only if port is non-nil and not -1. What’s the most idiomatic way of doing that?
02:21wasamasathere is a certain bump involved though
02:23Seylerius,(let [m {} port 4] (if (not-any #(= port %) '(nil -1)) (assoc m :port port)))
02:23clojurebot#error {\n :cause "Unable to resolve symbol: not-any in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: not-any in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: not-any i...
02:24Seylerius,(let [m {} port 4] (if (not-any? #(= port %) '(nil -1)) (assoc m :port port)))
02:24clojurebot{:port 4}
02:24SeyleriusPupeno: Something like that, perhaps?
02:26PupenoSeylerius: I was trying to not have yet another binding as it'll make the code look messy, hard to understand.
02:26SeyleriusPupeno: Ignore the let, that's just how I made sure I had a map and a port to test with.
02:27SeyleriusThe inner bit is what you want.
02:27SeyleriusBasically, (if (not-any? #(= port %) [nil -1] (assoc m :port port)))
02:29PupenoSeylerius: you are using m in there. Let me show you the code so it makes sense what I'm talking about:
02:29Pupenohttps://gist.github.com/pupeno/a03b8863926cbed6ea2b
02:30Pupenosee the hashmap that has :db, :user, :password, :host, and :port. That's the one I'm trying to avoid complicating.
02:34SeyleriusPupeno: Have the piece-building functions return nil in the case of anything invalid, and then filter the nil keys out.
02:37SeyleriusPupeno: Something like (remove #(nil? (second %)) {:foo (get-foo)...})
02:39PupenoIn the clojure slack someone just pointed to this trick: (merge {:foo :bar :bar :foo} (if port {:port port}))
02:39SeyleriusPupeno: Hey, there's an idea.
02:40SeyleriusI'd forgotten about merge.
02:40PupenoOtherwise I was going for filter.
02:40PupenoI wasn't *very* aware that merge handled nils so nicely.
02:41crocket-XX:MaxMetaspaceSize -Xmx
02:41PupenoIs there a builtin way in Clojure of writing this without calling getPort twice? (if (not= -1 (.getPort parsed-uri)) (.getPort parsed-uri))... something like (return-if #(not= -1 %) (.getPort parsed-uri)) which would be trivial to implement.
02:43SeyleriusWait... what? I've been spending a bunch of damn time building a clojure lib for the Wunderground API, and look what there is: https://github.com/Raynes/ororo
02:50SeyleriusAlthough, that one isn't Done Right™…
02:51SeyleriusI'll have to fix it.
02:51SeyleriusStill going to need to make my own.
02:59crocketarrubin, How did you execute your small clojure program?
02:59crocketI created a standalone uberjar.
03:05SeyleriusWhat's better: http://sprunge.us/SPWg or http://sprunge.us/LJRa ?
03:24amalloythere's no real difference, Seylerius, except that i'd put a newline after the (fn []) if you choose that version
03:25Seyleriusamalloy: I'll go with the #() then. Thanks.
03:33schmirI prefer (fn []..). you immediately see how many arguments the function takes without scanning the body
03:34amalloythat's a good point
03:52SeyleriusI'm building a library for an API with both per-minute and per-day quotas (which of course vary based on what level of plan the user purchased). I'm doing the per-minute with a ScheduledThreadPoolExecutor, using an atom to track the next safe execution time, but I'm not sure what the best way to track the per-day quota would be. Should I just keep a counter for the day in an agent and reset it at midnight EST (when the provider's quota
03:52Seyleriusresets)?
03:54Seyleriusamalloy_: Did you miss my last question due to connection hiccups? The timing of your sudden nick-change looks vaguely like that...
03:56SeyleriusI'm building a library for an API with both per-minute and per-day quotas (which of course vary based on what level of plan the user purchased). I'm doing the per-minute with a ScheduledThreadPoolExecutor, using an atom (or agent, I haven't decided which) to track the next safe execution time, but I'm not sure what the best way to track the per-day quota would be.
03:56SeyleriusShould I just keep a counter for the day in an agent and reset it at midnight EST (when the provider's quota resets)?
04:06SeyleriusAch. What do I have to require to get ScheduledThreadPoolExecutor?
04:08TEttingerSeylerius: probably import, not require since it's a java class
04:08SeyleriusTEttinger: And what the hell do I have to import?
04:09TEttingerit's in java.util.concurrent
04:09TEttingerwhich is weird but true
04:09TEttingerhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html
04:09SeyleriusSo, how do I import that?
04:09SeyleriusAnd just the bit I need...
04:10TEttingerat the repl, you'd do (import '[java.util.concurrent ScheduledThreadPoolExecutor])
04:10TEttingerin an ns, it's slightly different
04:10TEttinger(:import [java.util.concurrent ScheduledThreadPoolExecutor])
04:10TEttingerthat last line would go inside an ns call at the top of your file, usually
04:10SeyleriusThere we go.
04:11TEttingerI think that should work, I'm very rusty on java interop
04:11TEttingerif it doesn't, try replacing the space after concurrent with a dot
04:11TEttinger(there's no way to mass-import everything in a package)
04:12SeyleriusThat got past that error.
04:16SeyleriusHrm. What's the clj-time way to find the next midnight-EST from now?
04:17SeyleriusAh, there we go.
04:18H4nsis there a way to wait for all threads to finish? i'm using the component library to start a few services (as threads) and now i wonder what the best way would be to wait for termination.
04:18H4nsi mean i can just sleep and loop, but maybe there is something better/more idiomatic?
04:19TEttingerisn't there a Thread.wait method or something along those lines? might even be in Object
04:20H4nsto join a thread, i first need to have a handle to it.
04:21H4nsi guess it will be best to just Thread/sleep forever
04:21TEttingerhttps://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join(long)
04:21TEttingeroh ok
04:22H4nsah, or i could join myself, that sounds clever :)
04:23H4ns(.join (Thread/currentThread)) it is
04:23TEttingerI don't really know how you wouldn't have a handle on the threads
04:23TEttingerI think you can probably iterate through them too
04:23H4nsi'm starting various components and they might start threads on their own.
04:23H4nsi don't think so. threads are not a managed resource.
04:25TEttingerhttps://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#enumerate(java.lang.Thread[]) wowza the recommendation
04:25TEttingerthat copies the active Threads into a native array of Threads
04:27H4nsTEttinger: i'm reading "thread group" and think that it won't buy me anything to go down that rabbit hole now. self joining will do fine, thanks!
04:27TEttingerheh cool
04:44SeyleriusTEttinger: Can you think of a more idiomatic way to do this? http://sprunge.us/ZjYh
04:46TEttingerSeylerius, yeah
04:47SeyleriusMaybe factor the reset and .schedule lines out into a separate function?
04:47TEttingeryou could make the reset! and .schedule the body, and set the relevant bindings with if in the binding part
04:48TEttinger(let [delay (if (t/after? (t/now) @safe-time) 0 (t/in-millis (t/interval (t/now) @safe-time)))])
04:48SeyleriusTEttinger: Wait, like use an if to return a binding vector for the let?
04:48SeyleriusOh.
04:48TEttingerno, let can't take a vector like that sadly
04:48TEttingerthere's only two!
04:49SeyleriusTEttinger: Yeah, I'd need to "if" both bindings in the let, but that might work.
04:50SeyleriusPity you can't swap the whole binding vector, but this'll be better.
04:50TEttingermaybe
04:50TEttingerit's pretty good as is
04:50TEttingernot sure if my suggestion actually helps
04:50SeyleriusHmm...
04:51SeyleriusThe kicker is that next-safe and delay are both calculated differently depending on whether we've already crossed into safe-time or not.
05:11kwladykawhat can i use to draw board in console? I need function to change position for example 3x4 without redrawing all board each time
05:12kwladykaalso will be great if i can use colours
05:12noncomkwladyka: something in the ways of ncurses? maybe http://sjl.bitbucket.org/clojure-lanterna/ ?
05:14kwladykanoncom, i need draw chess board and figures on this chess, figures will move
05:14kwladykanoncom, so i guess it is not this
05:15noncomkwladyka: well, if you're to draw in console, what can be better than ncurses? lantern is javaish ncurses.. no?
05:15kwladykanoncom, i didn't use them so i don't know
05:15kwladykafast looking in the internet show me something else :)
05:15noncomwhat was that?
05:16kwladykai wrote ncurses in google and found https://pl.wikipedia.org/wiki/Ncurses
05:16kwladykais in my language but from this i can read read is more to draw things like on image on this site
05:17noncomit just allows you to draw whatever you like in the terminal
05:17noncommany roguelikes use ncurses
05:17noncom(all of them to be precise)
05:17kwladykahttp://sjl.bitbucket.org/clojure-lanterna/ <- but it can be what i am looking
05:18kwladykaso now i have to learn that :)
05:18noncomsure you will have to do the chess-drawing routines yourself. but at least, ncurses let you paint in the terminal... otherwise.. how is it possible...
05:18noncomfrankly, i've never used that. but i read lots about it and it seems like it fits with your aims, so maybe yeah, maybe it will work. i am pretty sure it will...
05:21kwladykabut i am feeling like that http://devopsreactions.tumblr.com/post/115748298481/logging-in-to-an-old-server-to-update-bash
05:21kwladykai want do something and all the time i have to something to do something :)
05:25SeyleriusGrr... What does it take to make clj-time.format parse "12:57 AM PDT" to the most recent "12:57 AM PDT" that's not in the future?
05:28Niac(:require [clojure.core.async :as async :refer [go >! >!! <! chan]]
05:28Niacwhat's for ">!"
05:46dstocktonThere has been talk in the past of a datomic whitepaper. Is that still around somewhere? All links i've found seem to 404.
06:07SeyleriusOkay, this shit is frustrating. I'm trying to add proper clj-time timestamps to this JSON (http://jsoneditoronline.org/?url=http://api.wunderground.com/api/8db70ebffc8a6252/forecast10day/q/NY/New_York.json), specifically the txt_forecast.
06:08SeyleriusReplacing simpleforecast's date map with an actual clj-time date-time is trivial, but txt_forecast is a pain.
06:08SeyleriusAny ideas how to attach a date-time to each entry in the txt_forecast?
06:14kwladykaHow https://clojuredocs.org/clojure.core/ref https://clojuredocs.org/clojure.core/ref-set works? I am not sure what they do. (def terminal-size (ref [0 0])) set terminal-size as vector [0 0] but each time when i call (defn handle-resize [cols rows] (dosync (ref-set terminal-size [cols rows]))) i will update this value?
06:15kwladykayeah i think like i said :)
06:16noncomkwladyka: yeah! things tail one another...
06:16noncomkwladyka: (regrding the video clip you poseted)
06:17noncomkwladyka: refs are just ways to store state.. something like atoms but more concurrency-enabled
06:18noncomkwladyka: the author uses refs because they allow to ensure the order of changes in a concurrent environment
06:18noncomsee the (dosync ...) magic - it does that
06:19noncomin a more simple case you could go with atom, reset! and swap! but that would not allow for syncing *the order* of operations between threads
06:19noncommaybe the example you're citing implies that terminal is a process and you may be hooked on one or more processes through it, and also there is input and could be network...
06:21SeyleriusHah, nailed it.
06:25kwladykanoncom, thx
06:29SeyleriusWeird. The println on line 143 is getting called, but the println on 150 isn't. http://sprunge.us/jbae
06:30noncomSeylerius: apparently, the if predicate passes for false?
06:31SeyleriusYeah, I figured that one out, now, but something else is breaking...
06:31noncomSeylerius: maybe you wanted to wrap the 'else' branch with a (do ...)
06:31noncomoh, you figured, ok
06:31noncom* the 'then' branch, sry
06:47kaiyinhow should translate (use '(incanter core datasets)) into (ns (:use ...))?
06:47kwladykahmm there is no more colours http://sjl.bitbucket.org/clojure-lanterna/reference/#colors ? Only this? Can i get brown?
06:48kwladykahttps://github.com/sjl/clojure-lanterna/blob/master/src/lanterna/constants.clj <- it look not simple
06:48kwladykaand why googlecode?
06:54SeyleriusHow do I get the result of an event `.schedule`d onto a ScheduledThreadPoolExecutor?
07:03SeyleriusTEttinger: You got any experience with ScheduledThreadPoolExecutors?
07:03TEttingernope
07:06SeyleriusDamnit. How the hell is a person supposed to get the result out of ScheduledThreadPoolExecutor.schedule?
07:09lokeSeylerius: you don't?
07:11Seyleriusloke: That'd be mightily lame... Do I have to stick what would be the return values onto a channel or something?
07:11lokeSeylerius: Sorry. I double-checked the APIdocs
07:11lokeyou can
07:12Seyleriusloke: How?
07:12loke.submot() returns a Future, and you simply call .get() on it
07:12loke.submit() even
07:12Seyleriusloke: So I take the ScheduledFutureTask object that I get back from .schedule and pass it through .submit and .get?
07:13SeyleriusNo, that doesn't work.
07:14lokeWhat is ShceuledFutureTask? .schedule() returns a ScheduledFuture which is a subclass of Future
07:14lokeyou can call .get() ont hat
07:14Seyleriusloke: I tried calling .get on the output of .schedule, and got a lovely nil
07:15SeyleriusEven though I pprint'd the value that was to be returned immediately before returning it in the scheduled function, and it was exactly the value I wanted.
07:15lokeSeylerius: did you call .schedule() with a Callable? If you call it with a Runnable you get the wrong type of ScheduledFuture back.
07:16Seyleriusloke: Look at do-api-call, line 133-169 (http://sprunge.us/IbHQ). It's calling .schedule with a bound-fn
07:17lokeYeah, I think that results in a Runnable being created behind the scenes
07:18lokeYou want to ensure a Callable is created
07:18Seyleriusloke: How do I do that?
07:18lokeI have no idea. I'I don't know the Java integration too well (I do Clojure using Clojurescript, but I know Java quite well)
07:19Seylerius(If I ever manage to understand this thing properly, I may just write a clojure wrapper around STPE that guarantees the right kinds of callables and gives back return values with some certainty.)
07:19lokeSeylerius: Yes.
07:19lokeThat should work.
07:19SeyleriusBut at the moment, I don't even get what the difference is between a Callable and a Runnable.
07:20SeyleriusAnd how to produce each in Clojure.
07:20lokeI think Clojure is being clever and create the class for your automatically, but it fails here because the API has overloaded .schedule() to accept both Runnable and Callable, and clojure chose the former.
07:20lokeA Callable can return a value while Runnable does not.
07:20lokea Callable can also thorw exceptions.
07:21Seyleriusloke: That much seems clear, but why is Clojure picking Runnable, and how do I tell it that it's being stupid?
07:21lokeSeylerius: 1) Because it's the first one to be retirned, probably. 2) I have no idea.
07:22tcrayford____`fn` implements both runnable and callable
07:22tcrayford____you wanna (cast Callable (fn [] blah))
07:22Seyleriustcrayford____: YAY!
07:22lokeOh. Clever
07:22Seylerius(inc loke)
07:22lazybot⇒ 1
07:22Seylerius(inc tcrayford____)
07:22lazybot⇒ 3
07:22SeyleriusThe answer has been found!
07:23Seyleriustcrayford____: Should be the return value of the Callable.
07:24cflemingYou should be able to just type hint it rather than casting, too ^Callable #(whatever)
07:24tcrayford____right, but scheduled = it runs more than once…
07:24Seyleriustcrayford____: Wrong schedule. This is the run-one-after-a-delay schedule.
07:24tcrayford____ahhh, that makes sense
07:24clojurebotExcuse me?
07:24SeyleriusThere are a few others that do periodic.
07:24tcrayford____I've only ever used the periodic ones ;)
07:25tcrayford____cfleming: type hints are weird though because of metadata. Unsure if `fn` discards it's metadata like every other macro ever though
07:25SeyleriusCan I just (deref (.schedule)), or @(.schedule)? or something?
07:26cflemingtcrayford____: Ah, good point - it probably does.
07:26tcrayford____don't think so - deref is clojure internal, not a java thing
07:26SeyleriusOkay. So (.get (.schedule))?
07:26tcrayford____yeah
07:26cflemingtcrayford____: That may be the only use case ever I've seen for cast - I don't think I've ever used it, and I do a lot of interop.
07:27tcrayford____cfleming: ```richard-p-fineman-2.local:app(1d|master) $ ag "cast" src | wc -l
07:27tcrayford____ 2```
07:27tcrayford____https://www.irccloud.com/pastebin/Y12DPfZ8/
07:27tcrayford____both of those are functions passed to `ScheduledThreadPoolExecutor`
07:27cflemingHaha, there you go
07:28SeyleriusGreat. For some finicky java reason, it's still not working.
07:28tcrayford____honestly kinda thinking about metadata being discarded by macros as a compiler bug
07:28Seyleriustcrayford____, cfleming: are you two going to be around here in about 6-8 hours?
07:28tcrayford____wondering if the compiler should try and merge metadata back in (e.g. if `:tag` isn't present on the metadata of the return value of a macro)
07:28cflemingtcrayford____: https://www.refheap.com/106552
07:29SeyleriusI need to sleep soon, and want to pick this crap up later. You two seem to get the interop better than most.
07:29tcrayford____reminder that (.startsWith ^String (or a b) "a") gets a reflection warning
07:29tcrayford____Seylerius: I make no promises about my availability
07:30Seyleriustcrayford____: Ballpark guesstimate if I promise not to shoot you for it being wrong?
07:30cflemingSeylerius: probably not, but if you drop a message here or in slack I'll see it sooner or later. Lots of other people here know interop though.
07:30SeyleriusI oughta start hovering in the Clojure slack.
07:30cflemingtcrayford____: yeah, I'm planning an inspection in Cursive for those cases.
07:31cflemingtcrayford____: And yeah, I definitely consider that a bug.
07:31tcrayford____yeah, likewise with having scrollback be a real thing, I'll see it eventually
07:31SeyleriusOkay, well, I'm going to hit the hay. I need to be functional and at the office in 7 hours.
07:31tcrayford____just, the only folk who get promises about availability are friends, family and Yeller customers ;)
07:31SeyleriusHeh.
07:31Seyleriustcrayford____: You a Yeller person?
07:31cflemingEven my family get no promises :)
07:32tcrayford____I'm *the* Yeller person - CEO, Founder, Sole Dev etc. I'm the only person in the company
07:32SeyleriusOnly people who get promises from me are my girlfriend and my boss. Everyone else gets vague guesstimates.
07:32SeyleriusThanks for the help
07:32tcrayford____np, happy we could
07:33tcrayford____cfleming: having that as an inspection would be rad
07:33cflemingtcrayford____: Yup. With the new inference stuff I'll be able to highlight unnecessary hints, too.
07:33tcrayford____doope
07:33cflemingAnd suggest them when needed etc
07:34tcrayford____(BUY COLIN'S PRODUCT)
07:34cfleming^^^ WHAT HE SAID
07:34cflemingOh, wait, you can't yet - that's my fault.
07:34cflemingOr rather, my bank's.
07:34cfleminggrumble grumble
07:54noogaafter playing with manifold, deferred deferred vector of deferreds is my new name
07:58smithHi guys, a quick newbie question: how can I cast string to int in a clojure way?
07:58smithThat is, without using Integer/Parse
08:04dstocktonsmith: whats wrong with parseInt?
08:04dstocktonoops, ignore
08:04dstocktonthought this was cljs
08:05dstocktonno, Integer/parseInt is in fact right
08:05tcrayford____smith: Long/parseLong
08:05tcrayford____(assuming you want a long - you probably do)
08:06smithAh, I see. Thanks.
08:06smithI was wondering if there is a way to avoid calling underlying Java methods.
08:06smithGuess not.
08:07noogawhat's wrong with calling Java?
08:08tcrayford____smith: typical clojure style calls java quite a bit where it's needed. You can of course write your own wrappers
08:08smithThanks, if that's how to do things in Clojure, then I don't have any problems.
08:09noogait's free, easy enough and does not require typing java code
08:09smithIt's just felt a liitle weird at first, that's all. :P
08:09wasamasaclojure's tight interop is at odds with writing code that could run on another clojure implementation
08:09smithwasamasa: That's another concern of mind too.
08:11rarebreedIsn't that what the new clojure 1.7 reader condition #$ is supposed to make easier?
08:11noogaI took Java libs for MS Azure stuff and wrapped Azure queues in core.async channels using ~7 lines of code
08:11rarebreedso you can have some stuff in :clj and other code in :cljs?
08:11rarebreedoops, I mean reader conditional
08:12rarebreedso that you can minimize or at least factor out clojure implementation specific code
08:13smithrarebreed: You mean this? http://dev.clojure.org/display/design/Reader+Conditionals
08:13rarebreedsmith: yeah
08:14rarebreedmy understanding is that you can place clj or cljs specific code wrapped in the reader conditional
08:14rarebreedI never looked at the .net version of clojure, and I didn't see any mention of it in that page
08:15rarebreedjust out of curiousity, is anyone else here from Red Hat? :)
08:16crocketHow do I launch a new thread and block the current thread indefinitely until the program receives a kill signal?
08:16crocketIs there an elegant way to block the current thread indefinitely until the program receives a kill signal?
08:16H4nscrocket: (.join (Thread/currentThread)) it is
08:17noogararebreed: red hat MTV?
08:17crocketH4ns, What is it?
08:18rarebreednooga: MTV? not sure what that is...I'm out in RDU :)
08:18noogararebreed: mountain view
08:18rarebreedand tomorrow I get to start at a new position and do some clojure ;)
08:18H4nscrocket: the answer to your question - sorry about the "it is", that was from earlier today when i chose to use that as a solution to my similar problem.
08:18rarebreednooga: ah, hadn't seen MTV before. Most of the guys I work with are in BRN or TLV
08:18dnolenrarebreed: reader conditionals indeed work well. Indeed ClojureScript's implementation is either 11000 lines of Clojure or 21000 lines of ClojureScript depending on your perspective :)
08:19crocketH4ns, Is there a clojure idiomatic way to do it?
08:19rarebreeddnolen: oh, is the clojurescript implementation itself using reader conditionals? cool :)
08:19crocketThat's java way
08:19dnolenrarebreed: it does now
08:19dnolenfor optional bootstrapping to JavaScript
08:19H4nscrocket: scroll back for the "parse integer" question that was discussed a few minutes ago.
08:20noogararebreed: I spent some time floor above RH MTV and met amny people in elevators :D
08:20noogamany*
08:20crocketH4ns, I wasn't here a few minutes ago
08:20rarebreeddnolen: well, that's good to know. I've done bits and pieces of clojure here and there. But soon I'm going to be doing clojurescript too.
08:20rarebreedso I need to check out how to use reader conditionals
08:20H4nscrocket: calling java is not unidiomatic in clojure.
08:21crocketI wonder if clojure has a function for that.
08:21H4nscrocket: it does not.
08:21rarebreednooga: never been out to MTV. My hope is to convert more people to the clojure way ;)
08:21rarebreedI already got one of my coworkers on Openstack on it
08:21rarebreedand failing that...to use hy as a gateway drug to clojure hehe
08:22rarebreedcrocket: maybe you can try to dereference the result of a future? that will block your main thread
08:23crocketrarebreed, How do I block a future?
08:23noogaWell I run a startup and we just binged on super smart talks about clj and cljs (nod dnolen) and then decided to use clj everywhere we can :D
08:23crocketfuture, delay, etc...
08:23rarebreed@(future (some-fn ...))
08:24noogacoming from node.js, java ee, python etc.
08:24rarebreedor (def result (future (some-fn ...)))
08:24rarebreed@resuilt
08:24rarebreed@result
08:24H4nsrarebreed: what would some-fn do?
08:24rarebreedthe some-fn would be the function that is called in another thread
08:25rarebreednooga: yeah, it seems like startups are the big pushers for clojure. I actually started writing some helper libraries for Openstack in clojure
08:25rarebreedit was not well received :p
08:26nooga:D
08:26crocketHow do I trigger a form to be executed when I press Ctrl+C while (.join (Thread/currentThread)) is blocking?
08:26puredangerstartups like Walmart, eBay, Netflix, etc
08:26rarebreedH4ns and crocket, when you dereference a future it will block the main thread until there's a result
08:26noogapuredanger: they always have some form of "internal startup"
08:27rarebreedpuredanger: there are those too. and you forgot Staples :)
08:27H4nsrarebreed: yes, but we asked for blocking the main thread without having handles to other threads that may have been started.
08:27noogaR&D, consultants etc.
08:27puredangerI could go on for a while :) it's not always some "internal startup" either
08:28puredangeralthough that is certainly one important vector into bigger companies
08:28H4nscrocket: you'll need to reach out into java again. you could start here: http://stackoverflow.com/questions/11709639/how-to-catch-ctrlc-in-clojure
08:28rarebreedpuredanger: I talked with some other guys at Red Hat who used to be on JBoss...apparently some testing uses clojure
08:28rarebreedand there's also immutant
08:29noogaI imagine, that most of the time, it starts with a side project like testing stuff, utilities
08:29noogaand then somebody goes "look, this took 2 hours"
08:29puredangerSee: http://cognitect.com/clojure#successstories and http://clojure.org/companies
08:29crocketOh java
08:29rarebreedH4ns: does it count not having a handle to a thread if you do @(future (some-fn ...))?
08:29crocketH4ns, I don't think a shutdown hook will be called if I press Ctrl+C to kill a block on REPL.
08:30H4nsrarebreed: i don't have handles to my threads right now, so self-joining works fine
08:30H4nscrocket: so you say that the answer on SO is wrong?
08:32H4nscrocket: ah, i hear what you say. sorry, no idea.
08:32crocketH4ns, a shutdown hook
08:32H4nscrocket: you want an sigint handler, not a shutdown hook.
08:32rarebreedso speaking of clojure evangelism....has anyone had success converting python shops to clojure|scipt ?
08:32rarebreedarggh can't type today
08:33noogaI converted 3 pythonistas on my team :D
08:33rarebreednooga: really? how'd you do it?
08:33noogaant this has nothing to do with me being CTO
08:33smithrarebreed: just show them the benchmark
08:33noogaand*
08:34rarebreedso, until today, I've been a QE on the openstack project. Nova in particular
08:34rarebreedand lots of guys are dyed in the wool python guys
08:34rarebreedI haven't found a way to broach the "lispiness" of clojure
08:35crocketWhat
08:35crocketpython is ok
08:35crocketpython is ok for three day projects.
08:35rarebreedit's ok...but I'd like to introduce more people to clojure|script
08:36rarebreedand there's like this immediate resistance to it
08:36rarebreedmaybe bad memories of lisp or scheme in college...I dunno :)
08:37noogashow them your code and say "oh yeah, this took me about a week to write this awesome distributed data driven thingamajic so now I can update the config file and do magic"
08:37tcrawleyrarebreed: what project are you on at RHT where you get to do clojure?
08:37smithrarebreed: in my experiences, most people are just more used to C/Java syntax
08:37clojurebotTitim gan éirí ort.
08:38rarebreedtcrawley: actually, I'm a quality engineer. Some of our testing code for candlepin/subscription-manager (believe it or not) is in clojure
08:38rarebreedcandlepin itself is java/ruby
08:38tcrawleyah, neato. I'm at RHT as well, on Immutant
08:38rarebreedand subscription-manager is python
08:39rarebreedtcrawley: awesome...I'm just starting to learn immutatnt
08:39tcrawleycome join us in #immutant if you have any questions
08:39rarebreedsmith: yeah, I think you're right. most people just look at the syntax and get this knee-jerk reaction
08:40smithrarebreed: I'm an-ex Python programmer too, now I'm transition fulltime to Lisp/Clojure
08:40rarebreedthe only thing I can counter with is "I bet when you first learned python you were like, 'white space matters? what kind of stupid language has white space that matters?'"
08:40noogabut lips have almost no syntax
08:41rarebreedthat was my first impression with python :) and after 3 weeks, I didn't think about it anymore
08:41noogaI can't even start with Scala because syntax
08:41smithrarebreed: what made me switch was: 1. speed (while still a dynamic language) 2. REPL (Python "REPL" has nothing on Lisp/Clojure REPL 3. Gradual typing
08:41noogaand python with its whitespace
08:41rarebreednooga: I tried learning haskell...and I will get back to it....but learning all the special syntax is such a drain
08:41noogayeah
08:41r4viyou can actually make python repl work closer to lisp repl
08:41noogaexactly
08:41r4viusing ipython autorealod stuff
08:42rarebreedtcrawley: yeah, I'm sure I will. I'm actually new to the web programming scene. I'm still learning luminus, the DOM and a bunch of other things
08:43rarebreedmy background has mostly been in hardware. embedded firmware, device drivers, and testing thereof
08:45rarebreedbut I'm stoked I can actually do clojure and/or clojurescript full time now, and without it being skunkworks :D
08:51tcrawleyrarebreed: good deal!
08:52rarebreedtcrawley: yeah. I found the position totally by accident too
08:53rarebreedtcrawley: just out of curiosity are you in Raleigh?
08:53tcrawleyno, I'm in Asheville - remote
08:54rarebreedI just moved up here a year ago. I probably should see if there are any meetups around here. Cognitect isn't that far away in Durham
08:54rarebreedor is that Think Relevance...I forgot now
08:55tcrawleyrarebreed: http://www.meetup.com/TriClojure/ is a great group of people
08:55rarebreedtcrawley: that's near the mountains right? I should go there sometime or Boone. I've been here a year and I've hardly seen North Carolina
08:56tcrawleyyeah, Asheville is in the mountains
08:56rarebreedtcrawley: oh nice...looks like there's a meetup on the 30th :)
09:01kwladykahow (mod -10 3) gives 2 and (mod -2 5) gives 3?
09:02kwladyka'(mod -2 5)
09:02kwladyka`(mod -2 5)
09:03kwladyka,(mod -2 5)
09:03clojurebot3
09:07TMAkwladyka: because -10 = -4 * 3 + 2 and -2 = -1 * 5 + 3
09:07H4ns"lein ring" fails for me because somehow, tools.nrepl 0.2.6 is loaded even though i have tools.nrepl 0.2.10 as explicit dependency. Does that sound known to anyone?
09:08kwladykaTMA, thx
09:13justin_smithH4ns: a) lein sucks b) cider sucks c) all of the above d) ???
09:13lazybotjustin_smith: How could that be wrong?
09:15winkH4ns: hm, there might be an open bug report about that
09:15H4nsjustin_smith: that was helpful, thanks!
09:15justin_smithhaha
09:15wink(or even several)
09:15justin_smithI promise, I wasn't trying to be helpful, but maybe I was accidentally so
09:19kwladykawhat can i use instead "ref" to not parallel state?
09:22kwladykaTo be more precise:
09:22kwladyka(def terminal-size (ref [0 0]))
09:22kwladyka(defn handle-resize [cols rows]
09:22kwladyka (dosync (ref-set terminal-size [cols rows])))
09:22kwladykacan i do this more simple if i dont need parallel?
09:22justin_smithkwladyka: if retries are OK and you don't need coordination you can use an atom
09:22justin_smithkwladyka: if you can't do retries, you can use an agent
09:23kwladykajustin_smith, retries?
09:24justin_smithatoms and refs retry - they redo the transformation if there is any parallel modification
09:24kwladykajustin_smith, i just want remember state to not pass it as parameter to all functions
09:24justin_smithkwladyka: all of these are ways to have global state
09:24justin_smithkwladyka: http://stackoverflow.com/questions/9132346/clojure-differences-between-ref-var-agent-atom-with-examples
09:31kwladykajustin_smith, thx
10:09CookedGryphonHey, I'm doing some java interop with a static class, and the compile is failing with a verifyerror "Expecting a stackmap frame at branch target 17"
10:10CookedGryphonhas anyone seen anything similary before?
10:10CookedGryphonit's in an extend-type
10:13catonanowith clj-time I want to parse this datetime "25/03/2012 2.00"
10:13catonanothis is my parser (let [multiparser (f/formatter (t/default-time-zone) "dd/MM/YYYY HH.mm" "YYYY-MM-dd HH:mm:ss")] ...
10:13catonanoand
10:13catonano(f/parse multiparser source-datetime)
10:14catonanoand I get
10:14catonanollegalInstantException Cannot parse "25/03/2012 2.00": Illegal instant due to time zone offset transition (Europe/Rome) org.joda.time.format.DateTimeParserBucket.computeMillis (DateTimeParserBucket.java:471)
10:14catonanoI found this https://stackoverflow.com/questions/26162702/cannot-parse-datetime-illegal-instant-due-to-time-zone-offset-transition-euro?rq=1
10:14catonanobut how do I deal with this with clj-time ?
10:17catonanooh with to-timezone
10:17catonanoI see now
10:22crocketHow do I extract two keywords from a map concisely?
10:22crocketUsing a function, I can use destructuring. Without it, I don't know.
10:23tcrayford____crocket: select-keys?
10:24tcrayford____,(select-keys {:a 1 :b 2 :c 3} [:a :b])
10:24clojurebot{:a 1, :b 2}
10:24mmeixor maybe
10:24mmeix,((juxt :foo :baz) {:foo 1 :bar 2 :baz 3})
10:24clojurebot[1 3]
10:24crocketok
10:24tcrayford____select-keys is designed for this though, and much less confusing than juxt imo
10:25mmeixjuxt, if one only needs the vals, of course
10:25perplexacatonano: i also think "2.00" might cause an error with "HH.mm"
10:26catonanoperplexa: thanks I'll check that
10:26crocketHow do I convert a map into a pretty-print string?
10:27tcrayford____,(with-out-str (clojure.pprint/pprint {:a 1}))
10:27clojurebot#error {\n :cause "clojure.pprint"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: clojure.pprint, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.ClassNotFoundException\n :message "clojure.pprint"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :tra...
10:28tcrayford____bah
10:28tcrayford____it's that
10:28tcrayford____just clojurebot don't know about pprint
10:28catonanoperplexa: no, it's the same even with 25/03/2012 2.00
10:28catonanoI mean 25/03/2012 02.00
10:28catonanooh wait
10:29catonanoperplexa: here http://pastebin.com/KdhgDsYu
10:30devnAnyone in here an amateur cryptographer? I have some nasty Java code I've written to do PBKDF2 with HMAC SHA1, AES256/CBC/PKCS5Padding
10:30devnbut I'd like to clean it up and use Buddy
10:30CookedGryphoncrocket: you might want to look at something like fipp if you're doing pprint as part of your program, it's much faster and nicer output imo
10:30devnI'm trying to figure out how to compose all the right pieces in buddy to get the same result
10:32perplexacatonano: what is your multi-parser?
10:33catonano(def multi-parser (f/formatter (t/default-time-zone) "dd/MM/YYYY HH.mm" "YYYY-MM-dd HH:mm:ss"))
10:35perplexacatonano: havn't used multi formatters yet, docs suggest your syntax is right. maybe try without the default tz
10:35catonanoright away
10:36crocketCookedGryphon, FIPP!
10:37catonanoperplexa: it seems to be required. An exception claim the argument could not be parsed as a timezone
10:37catonanooh well
10:37perplexalikely the one you're trying to parse
10:38catonanoperplexa: yeah ClassCastException java.lang.String cannot be cast to org.joda.time.DateTimeZone
10:38crocketWhat is a simple way to save configs in a file?
10:38catonanoand the sttring is supposedly the datetime string
10:38crocketShould I just save a clojure map in a text file and read it?
10:39devnAnyone here using one of the kafka libraries?
10:39devnI have to say, I'm not all that impressed with what I've seen thus far.
10:39perplexacatonano: (tf/parse (tf/formatter "yyyyMMddHH") "2015010100") does that work for you?
10:39devnWhich, don't get me wrong: I'm grateful for the free stuff! I guess I'm just surprised there isn't anything a little more complete out there.
10:39perplexatf is clj-time.format
10:46jcromartieCIDER says it is connected, but it doesn't open a REPL.
10:46jcromartienREPL server started on port 51573 on host 127.0.0.1 - nrepl://127.0.0.1:51573
10:46jcromartieI can connect to that from lein repl :connect...
10:46jcromartiebut CIDER inside Emacs itself just sits there
10:47jcromartieI have CIDER version 20150713.1614
10:48jcromartielesson learned: never update CIDER
10:48devnheh
10:48devnmelpa-stable FTW
10:51crocketDoes clojure 1.6 have clojure.edn namespace?
10:52jcromartieis there a way to install a version of CIDER that works without changing my MELPA archive ?
10:54jcromartieah ha
10:54jcromartie(add-to-list 'package-pinned-packages '(cider . "melpa-stable") t)
10:55jcromartieI've been bitten by this before
10:55jcromartieI should have learned by now
10:55catonanoperplexa: just a minute
10:55devncrocket: yes
10:56jcromartieoh
10:56jcromartieI can't do ththat (pinned packages)
10:56devnim pretty sure i have an error or two at the moment
10:57devn; CIDER 0.9.1 (Java 1.8.0_11, Clojure 1.7.0, nREPL 0.2.6)
10:57devnWARNING: CIDER requires nREPL 0.2.7 (or newer) to work properly
10:57devnI'm not sure why...
10:57devnwell, I guess I'm not sure where I go to update nREPL
10:57catonanoperplexa: yes, it works
10:59devnwelp, I added [org.clojure/tools.nrepl "0.2.7"] to my ~/.lein/profiles.clj :dependencies [...]
10:59devnseemed to do the trick
11:00catonanoperplexa: also (f/parse (f/formatter "yyyyMMddHH") "2012032502")
11:00catonanoworks
11:01catonanoit's the same sate that can't be parsed with my multi-parser
11:02perplexacatonano: maybe ditch the multiparser or look into the lib what it's doing
11:02perplexacan't check right now, unfortunately
11:02catonanoperplexa: thanks, I'll take a look at the lib code
11:08crocketWhat is a simple log library for clojure?
11:09algernoncrocket: https://github.com/pyr/unilog
11:12Empperialso https://github.com/ptaoussanis/timbre
11:13catonanoperplexa: I found the solution. It works with multiparsers too
11:14perplexawhat was the error?
11:15catonanoI used "parse-local" rather than "parse" That calls the java method "parseLocalDateTime" rather than the vanilla one
11:15catonanoI saw it skimming through the code
11:16perplexa:)
11:16catonanothe read me didn't mention it
11:16catonanoperplexa: thanks !
11:18perplexacatonano: yw!
11:20crockettimber!!!
11:27timvisheranyone have a favorite way to set up an ssh port forward from clojure?
11:29adgtlGuys seeing this when I do cider-jack-in
11:29adgtl CIDER requires nREPL 0.2.7 (or newer) to work properly
11:30timvisheradgtl: i'll bite. :) do you have nrepl 0.2.7?
11:30timvisherkeep in mind you need both the plugin and server for cider to work properly, afair
11:30vaitelhttps://github.com/clojure-emacs/cider#warning-saying-you-have-to-use-nrepl-027
11:31timvisherooo… a FAQ!
11:39adgtltimvisher: Had to add https://gist.github.com/b12cdd1b65df187a58c5 to fix that
11:48gzmaskHow is the job market for Clojure right now? I am Canadian Web developer and looking for a clojure related job (preferable cljs).
12:01crocketyay
12:18TimMcgzmask: There are definitely some employers. Have you checked functionaljobs?
12:19gzmaskYes, there are the reuter one and couple others (mostly in UK)
12:19arrubinThere are actually more Clojure jobs here: http://careers.stackoverflow.com/jobs?searchTerm=clojure
12:19gzmaskapplied for the reuter job, but not willing to relocated to UK at the moment
12:21gzmaskI have checked that too. I am more interested in startups with interesting projects
12:21arrubinOne moment.
12:21arrubinhttps://news.ycombinator.com/item?id=9812245
12:21arrubinSearch for Clojure there.
12:21arrubinWatch that account on the first of each month.
12:22gzmaskespecially those ones who is going to use clojurescript with OM/Reagent and reactive native
12:23gzmaskThanks, looks like a good place to start :)
12:23hiredmanthe amount of clojure jobs where they want you on site is very disappointing
12:23gzmaskI bet most of these jobs are database/business centric?
12:23gzmask@hiredman
12:24hiredmangzmask: a lot of them are for clojurescript
12:25gzmaskclojurescript is exactly what I am after
12:28arrubingzmask: I do not know how effective it is, but that same HN account has a "Who wants to be hired?" submission on the first of each month too.
12:32TimMcgzmask: Not back-end stuff?
12:33gzmaskthanks, I am looking at his submissions.
12:34TimMcMy employer might be hiring soon. I can't promise Clojure, but we've racked up a few Clojure projects so far.
12:34gzmaskTimMc: I did MySQL/Oracle and server administration tasks, so I have a little bit server side experience
12:35gzmaskTimMc: where are you guys located?
12:38TimMcgzmask: Boston.
12:41gzmaskGood city. PMed.
12:45edoloughlinl/nick edoloughlin_
14:38SeyleriusOkay, java interop time: How the fsck do you get the result out of scheduling a task into a ScheduledThreadPoolExecutor?
14:38SeyleriusIt's not deref or .get
14:40hiredmanit is
14:40puredangerit returns a future of some kind I presume which I would expect to work with deref?
14:40SeyleriusWell, both of those failed.
14:41hiredmanI (and others I am sure) happen to know that they work, so you should re-examine what you are doing for errors or share more of what you are doing
14:41SeyleriusI've told the scheduled task to pprint the value before returning it, and it's the value I wanted, but both deref and .get on the future that results give me a nil.
14:41hiredmanpprint returns nil
14:42Seyleriushiredman: It was (let [data foo] (pprint data) data)
14:42SeyleriusTo ensure that the data was still returned
14:42SeyleriusAnd I've since removed that pprint.
14:43Seyleriushttp://sprunge.us/CfCJ
14:44hiredmanso deref and .get do work, but they are returning nil?
14:44Seyleriusdo-api-call (133-173) actually does the scheduling, while forecast-10day calls do-api-call and wants to deref the future
14:44Seyleriushiredman: Yep.
14:44SeyleriusThey don't error out, but they return nil.
14:45hiredmanwhich, I am guessing here, if you read the docs for scheduled tasks is what the futures return
14:45hiredmanhttp://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html#schedule%28java.lang.Runnable,%20long,%20java.util.concurrent.TimeUnit%29
14:45hiredmancheckout Returns:
14:46Seyleriushiredman: It's the other schedule, the one that takes a callable.
14:46blake_OK...back to this old problem. =P I've got a ring app and I want some code in there to run ONLY when the app is actually deployed. (It's a scheduler so if I just let it execute on compilation, the compilation never actually comes back.)
14:46SeyleriusBecause I cast the function to a callable.
14:47hiredmanSeylerius: it seems pretty obvious that in fact the runnable method is being called
14:47hiredmanwhat makes you think the Callable one is being called?
14:49Seyleriushiredman: Maybe the fact that the only difference between them is whether they're called with a Callable or a Runnable and I cast the function it's called on to a Callable?
14:49hiredmana quick test would be to replace the casting stuff with (let [f (bound-fn ...)] (reify Callable (call [_] (f))))
14:49SeyleriusOkay.
14:49hiredmanSeylerius: cast is more subtle than that
14:49SeyleriusGreat.
14:49SeyleriusThe only time Clojure ever frustrates me is when I have to fight with Java.
14:50devnhiredman: a couple of years ago you posted a gist of yours that was a core.async pipeline thingamajig.
14:50devnyou don't happen to have that handy, do you?
14:50hiredmanthe clojure compiler doesn't know the result of (thread-pool) is a thread pool, so the method call is falling back to reflection, in which case your cast is ignored
14:51hiredmanthe thread pool atom thing is a race condition too, you should consider using a delay
14:52devnhiredman: nevermind, found it at https://gist.github.com/hiredman/11194485
14:53Seyleriushiredman: What would you do there, to fix the thread-pool atom?
14:54hiredmanthat is complicated, but the quickest "fix" would be (def pool (delay (ScheduledthredPool...)))
14:55hiredmanand @pool as required
14:55seangroveWhat function would transform "a/b/c/d/e" -> ["a" "a/b" "a/b/c" "a/b/c/d" "a/b/c/d/e"] ?
14:56Seyleriushiredman: The reify bit fixed it.
14:57hiredmananother possible fix (but more fragile because it relies are type hints for correct behavior vs. type hints to remove reflection for speed) would be to type hint the call to (thread-pool)
14:57hiredmanrelies on
14:58SeyleriusHmm... I'm going to look up the delay tool
14:59Seyleriushiredman: Ah, a delay basically /is/ the thread-pool function.
15:00SeyleriusGive the thing, or make one if we don't got one yet.
15:00hiredmanyeah, but with the right locking around it to not be a race condition
15:00SeyleriusRight.
15:01SeyleriusWhen the language designers have already made a thing that does what I want, use that, because they've probably accounted for some crap I didn't think of.
15:04TimMcseangrove: feels a bit like clojure.core/reductions
15:05TimMcor iterate with removing stuff from the end, then reverse it
15:11justin_smithTimMc: with a take-while. I should totally make a function that composes iterate with take-while
15:11justin_smithiterate-while
15:16gfredericksis there a good repl tool for getting enhanced docs from somewhere?
15:18andyf_gfredericks: Not sure if these are anywhere near your question. There is a library called cd-client that retrieves examples from ClojureDocs.org and can work at the REPL. Unfortunately the last time I checked, its examples are frozen at the state of ClojureDocs.org from Sep 2014, I think when they updated the web site implementation to Clojure.
15:19andyf_gfredericks: My thalia library monkey-patches clojure.core Vars to change the doc strings, but only for a few Vars that I've written doc strings for.
15:20andyf_gfredericks: Brian Marick announced such wow on the Clojure Google group recently, which I've read does something similar, but I haven't tried it yet, or looked at his enhanced doc strings.
15:21andyf_There is a bit of discussion in that thread about how to combine the best of such things, and maybe it dovetails with a current Google Summer of Code project for Clojure
15:27seangroveTimMc: I like the iterate idea
15:28TimMcreduce would be easier to understand, I think
15:29TimMc&(reductions #(str % \/ %2) (.split "a/b/c/d/e" "/"))
15:29lazybot⇒ ("a" "a/b" "a/b/c" "a/b/c/d" "a/b/c/d/e")
15:29amalloyi think it's reductions
15:31seangroveTimMc: Much better that what I just wrote with iterate, yes
15:32TimMc&(take-while some? (iterate #(let [li (.lastIndexOf % "/")] (when (<= 0 li) (.substring % 0 li))) "a/b/c/d/e"))
15:32lazybot⇒ ("a/b/c/d/e" "a/b/c/d" "a/b/c" "a/b" "a")
15:32TimMcyuck!
15:32TimMc'course you still need the reverse on the first one
15:40scriptor,(let [s "a/b/c/d/e"] (map #(subs s 0 (inc %)) (range 0 (count s))))
15:40clojurebot("a" "a/" "a/b" "a/b/" "a/b/c" ...)
15:41scriptorhmm...
15:41scriptor,(let [s "a/b/c/d/e"] (map #(subs s 0 (inc %)) (range 0 (count s) 2)))
15:41clojurebot("a" "a/b" "a/b/c" "a/b/c/d" "a/b/c/d/e")
15:41scriptorthere we go
15:41TimMcscriptor: I don't think we can count on the segments always being length 1.
15:41TimMcseangrove: ^?
15:42TimMcbut that's an interesting idea... if there were a way to get the positions of all the slashes easily...
15:42scriptoryeah, this is entirely assuming it's one char per slash
15:53justin_smith.indexOf "/" or some such
15:53justin_smith(for generating the split position number)
16:03justin_smithany source for a good intro to using kafka from clojure? I tried to follow the readme for clj-kafka but I think I'm using some of the magic numbers wrong, or my kafka setup is fucky, or I don't even know, I'm just getting a lot of errors I don't understand
16:06blkcatkafka really lives up to its namesake sometimes :)
16:43Cr8,(let [s "a,bcde,f,gh" h ","] (for [x (range (count s)) :when (.startsWith (subs s x) h)] x))
16:43clojurebot(1 6 8)
17:03TimMcCr8: hah!
17:03justin_smithduplicate linear searches though
17:05justin_smithwait, no, never mind
17:10justin_smith,(take-while #(>= % 0) (iterate #(.indexOf "a,bcde,f,gh" (int \,) (inc %)) 0))
17:10clojurebot(0 1 6 8)
17:10justin_smiththe 0 is noise, of course
17:11justin_smith,(take-while pos? (rest (iterate #(.indexOf "a,bcde,f,gh" (int \,) (inc %)) 0)))
17:11clojurebot(1 6 8)
17:11justin_smithmuch better
17:12blake_Somewhere along the line my Widlfly deployment stopped working and it seems to be related to the security constraint. My WAR redirects 8080 to 8443 but now responds at 8443 with an SSL connection error.
17:13justin_smithblake_: someone was asking about something very similar recently (within the last week?), you may want to check the logs for the channel for Wildfly / immutant mentions
17:14blake_tx, justin_smith
17:15jonathanjis there some way to avoid the redundancy of declaring liberator resource decision functions when using compojure's (context) macro?
17:24blake_justin_smith: Although actually that might have been me, too.
17:27csd_hi does anyone know if its possible to pass an async channel into a quartzite job?
17:28justin_smithblake_: heh, iirc tcrawley-away is the guy working on immutant, right?
17:33blake_justin_smith: I think he and jcrossley3 have been my big helps in the past on this.
17:36jcrossley3blake_: what's the issue?
17:37jcrossley3csd_: that should be fine as long as you're only using the default in-memory persistence
17:37blake_jcrossley3: I have an app with a web.xml file that contains a security-constraint section.
17:37jcrossley3right, didn't we already discuss this a while back?
17:38blake_jcrossley3: So when I go to my-server:8080, it gets pushed over to my-server:8443.
17:39blake_jcrossley3: Yeah! But at the time I thought the issue was the java-servlet version.
17:40jcrossley3blake_: so do you want the redirect, but you're getting an error from wildfly's https handler? if so, then #wildfly might be more helpful.
17:51blake_jcrossley3: I've got to deploy with HTTPs, yeah, but Wildfly actually shows no error. It returns an error to the client.
17:52blake_jcrossley3: Yeah, I trolled #Wildfly for a while with no luck.
17:52jcrossley3blake_: what error?
17:53blake_jcrossley3: A standard SSL connection error. "Unable to make a secure conneciton to the server..."
17:54jcrossley3blake_: have you set up your keys and a self-signed cert?
17:55blake_jcrossley3: Not locally, no. I guess I should start there.
17:55xemdetiablake_, what does openssl s_client -connect thehost:8443 if anything
17:55xemdetiashort output=bad, long output=good
17:56blake_xemdetia: Bad file descrptor, errno=10061
17:56blake_(so, short)
17:56jcrossley3blake_: http://stackoverflow.com/questions/29138478/how-to-configure-ssl-in-wildfly-8-2-0-server
17:57jcrossley3blake_: it's easier in immutant ;) (but you still need to create keys)
17:57blake_jcrossley3: Thanks. I was trying to figure out if it changed 9.0. Previously, I've had the same web.xml running with the same security constraints, and it worked locally and remotely.
17:58cryptack_hey, if I have a namespace in an EDN file (e.g. {:namespace ‘my-ns}) and I pull it into a var (e.g. (let [{n :namespace}])) I’m wondering how do I call a function, say “my-fun” under this namespace….I can’t perform (n/my-fun) as when compling “n” doesn’t match a namespace
17:58jcrossley3blake_: and it was being successfully redirected to 8443? strange
17:58blake_jcrossley3: I'm close to using immutant. =P
17:58blake_jcrossley3: Yeah, it's been making me crazy. I've been going back to an earlier version that's actually IN production to see if I can recreate the working WAR and have had no luck.
18:00xemdetiasorry blake sounds like an app problem not at tls problem :(
18:01blake_xemdetia: Yeah, I know. I did a mass update of project dependencies right before this and thought maybe THAT broke it. But even rolling back didn't seem to help.
18:01xemdetiayuck
18:01jcrossley3blake_: can you grab a copy of the war in production and crack it open to verify the web.xml is as you expect?
18:01blake_jcrossley3: I can't personally but I might be able to get it. Good idea.
18:02jcrossley3blake_: if it does in fact have that PRIVATE constraint in there, then i would expect your standalone.xml to include a 'certificate-key-file' attribute
18:03blake_jcrossley3: I can guarantee the security constraint is in there and that there is no certificate-key-file attribute. Well 99% sure, anyway. I'll see if I can grab the WAR.
18:12jcrossley3blake_: maybe not a certificate-key-file, but at least an https-listener element, and i don't believe there is one configured in the default wildfly config (either 8 or 9)
18:14blake_jcrossley3: Could it be something that was included in (say) lein-ring or some other library that was removed? I mean, I thought I undid my lein-ring upgrade but maybe not.
18:16jcrossley3blake_: i tend to doubt it. if you know for a fact that ssl is working in your production environment, and you're passing ssl requests to wildfly, i.e. no reverse proxy involved, it's likely because someone added an https-listener to your standalone.xml
18:18blake_jcrossley3: I would expect that to use the local git repository and be visible but I guess it could be done in Chef. I'll be pissed if that's the case.
18:18jcrossley3blake_: if there is a reverse proxy involved, all bets are off, because it may be doing the redirect itself
18:19blake_jcrossley3: That could be. They don't like to tell us what they're doing. =)
18:19jcrossley3:)
18:20blake_It does happen that they mess with things without telling us and then weeks later, after we've torn our hair out trying to debug our stuff, say "Oh, yeah, we tweaked some stuff. Nobody noticed."
18:22justin_smithblake_: I would take a statement like "Oh, yeah, we tweaked some stuff. Nobody noticed."
18:23blake_justin_smith: lol
18:23justin_smithas an invitation to ask them as your first resort if anything isn't working
18:24justin_smithif nothing else it means next time they know "someone noticed"
18:24blake_justin_smith: High turnover. There's no departmental memory. It's like Memnto meets Groundhog Day.
18:24jcrossley3blake_: i'm happy to help once you know what's going on. and ping us in #immutant if you decide to go that route.
18:25blake_jcrossley3: Thanks! Much appreciated. Might've spared me some angst.
18:25blake_bbl
18:54rhg135is there a good way to debug a profiles.clj? I can't figure out why a dependency (alembic) isn't being loaded. but when I move it to my project.clj it is.
18:55justin_smithrhg135: do any of your profiles.clj deps work?
18:56rhg135yes, justin_smith, all but this one it seems
18:56rhg135well, I had tried spyscope and it also failed
18:56justin_smithbecause the simplest explanation would be that your profiles.clj is merely malformatted
18:58SeyleriusIf I've got a coll of several strings that might occasionally be intermixed with numbers, and I want them to just be numbers, how does one accomplish this?
18:59rhg135(filter number? coll)
19:00Seyleriusrhg135: Nah, I want to transform the strings to numbers.
19:00rhg135oh
19:00Seylerius["2015" "07" 09 12 "00"]
19:00SeyleriusNeeds to become [2015 7 9 12 0]
19:01rhg135try ##(keep #(try (Integer/parseInt %) (catch Exception _ nil)) ["1"])
19:01lazybotjava.lang.SecurityException: You tripped the alarm! catch is bad!
19:01rhg135well
19:01rhg135try it at home I guess
19:03rhg135I think I may just be overlooking something https://www.refheap.com/106576, and no, lein deps :tree just lists my project's deps
19:11TEttinger,(map read-string ["2015" "07" 09 12 "00"])
19:11clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>
19:11TEttinger,09
19:11clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>
19:12amalloyTEttinger: you want integer/parseint
19:12TEttingerSeylerius: 09 is not valid as a number
19:12amalloywith the radix 10 specified
19:12justin_smith,017
19:12clojurebot15
19:12amalloyit doesn't really matter for [09], because you can't have a value that prints that way
19:12TEttingeramalloy: the example he gave had non-string number 09
19:13amalloyTEttinger: sure, it was an example he made up, because it is impossible to have such a thing
19:13TEttingerk
19:13justin_smith,0123
19:13clojurebot83
19:13TEttingeryes justin_smith they're octal
19:13justin_smithyes, for some reason I find that amusing
19:13justin_smith,0xdeadbeef
19:13clojurebot3735928559
19:14TEttinger,36rILIKEPIE
19:14clojurebot1457390052518
19:14amalloybecause if there's one tradition from C that we need to keep carrying over to new languages, it is the ability to write numbers in base 8
19:14TEttingerand in clojure's case, base 27
19:14amalloyi guess i don't mind the ability to do that, like 8r755
19:14amalloybut to use something innocuous like 0755 is confusing
19:15TEttinger,27rGAMBLE
19:15clojurebot235338548
19:16TEttinger,(map #(read-string (str "10r" %)) ["2015" "07" 09 12 "00"])
19:16clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>
19:16TEttingerhm
19:17TEttinger,10r09
19:17clojurebot9
19:17TEttingerright it's before that
19:17TEttinger,(map #(read-string (str "10r" %)) ["2015" "07" 9 12 "00"])
19:17clojurebot(2015 7 9 12 0)
19:18justin_smithTEttinger: from a coworker ##(identity 36rwhatisthemeaningoflife`
19:18justin_smitherr
19:18TEttinger,36rwhatisthemeaningoflife
19:18clojurebot15630618813727882227183131952537482N
19:18TEttinger,36rwhatisthemeaningoflifetheuniverseandeverything
19:18clojurebot350942681731242990203511395147592895386304091688071820253349265705971116N
19:19TEttinger,35rwhatisthemeaningoflifetheuniverseandeverything
19:19clojurebot98826347130333606158459885179744852531856458432998128759946017006701121N
19:19justin_smith,(.indexOf (str 35rwhatisthemeaningoflifetheuniverseandeverything) "42")
19:19clojurebot-1
19:19justin_smith:(
19:20justin_smith,(.indexOf (str 36rwhatisthemeaningoflifetheuniverseandeverything) "42")
19:20clojurebot4
19:23Seyleriusamalloy, TEttinger: The Wunderground API returned the following as a date: {:date {:pretty "July 9, 2015" :year "2015" :mon "07" :mday "09" :hour "12" :min "00" :tzname "America/Los_Angeles"}}
19:24amalloyright, and those are all strings
19:24SeyleriusAnd I want them to be numbers.
19:24SeyleriusSometimes they'll return numbers interspersed with the strings.
19:24SeyleriusWell, all except :pretty and :tzname
19:25SeyleriusBut read-string craps on "09" (first thing I tried)
19:25TEttingercorrect
19:25TEttinger09 is not a valid literal
19:25TEttingerbut you can do
19:25SeyleriusIs there a function that will trim leading 0s?
19:25TEttinger,10r09
19:25clojurebot9
19:25TEttinger10r is radix 10
19:25TEttingeror
19:26TEttinger#(Integer/parseInt % 10)
19:26TEttingerbut that will crap on strings
19:26TEttingerI guess so will 10rbob
19:26SeyleriusWell, I don't particular expect :min to hold "bob" any time soon.
19:28TEttinger,(map read-string #(re-find #"[1-9]*[0-9]$" %) ["9" "09" "0" "00"])
19:28clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: sandbox$eval48$fn__49>
19:29TEttinger,(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "0" "00"])
19:29clojurebot(9 9 0 0)
19:29TEttingerSeylerius: does that work?
19:29SeyleriusYeah, it does.
19:29SeyleriusThat strips any leading zeroes, don't it?
19:30TEttingeryep
19:30SeyleriusW1n.
19:30Seylerius(inc TEttinger)
19:30lazybot⇒ 60
19:30TEttingerlet me do some more testing!
19:30SeyleriusI'll give more karma for more testing.
19:31SeyleriusYou've been warned.
19:31TEttinger&(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016"])
19:31lazybot⇒ (9 9 9 0 0 0 16 16)
19:31TEttingerso far so good
19:32TEttinger&(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160"])
19:32fmzakarihi, does anyone have any code examples of doing pagination in a ring web app?
19:32lazybot⇒ (9 9 9 0 0 0 16 16 160 160)
19:32Seylerius&(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])
19:32lazybot⇒ (9 9 9 0 0 0 16 16 160 160 15)
19:32fmzakariI'm specifically using https://github.com/krisajenkins/yesql and wondering how to do it clojure-idiomatic
19:32TEttingera ha!
19:34justin_smithfmzakari: we have pagination in caribou, which is not updated very often, and I'd have to double check if there is a place where it is coherently / readably defined
19:34TEttinger&(map #(read-string (re-find #"^(?:0*)[0-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160"])
19:34lazybotjava.lang.NumberFormatException: Invalid number: 09
19:34TEttingerhm
19:34fmzakariis caribou an OSS site or framework?
19:34fmzakarilet me lookit up.
19:35TEttinger&(map #(read-string (re-find #"^(?:0*?)[0-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160"])
19:35lazybotjava.lang.NumberFormatException: Invalid number: 09
19:35justin_smithfmzakari: it's a clojure web thing that's either kind of tightly bundled for a collection of libs, or very loosely put together for a framework
19:36justin_smithcomes with a db abstraction using clojure data and an in-browser CMS app that's friendly for eg. frontend guys or producers to use to define basic data models or input data
19:36Seylerius&(map #(read-string (re-find #"(?=0+)[1-9][0-9]*$" %)) ["9" "09"
19:36Seylerius "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])
19:36Seylerius&(map #(read-string (re-find #"(?=0+)[1-9][0-9]*$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])
19:36SeyleriusDid I crash lazybot?
19:36lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
19:36lazybotjava.lang.NullPointerException
19:36Seylerius,(map #(read-string (re-find #"(?=0+)[1-9][0-9]*$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])
19:36SeyleriusWhooo! lag!
19:36clojurebot#<NullPointerException java.lang.NullPointerException>
19:36justin_smithSeylerius: you were lagged, and then spammy
19:36SeyleriusYep
19:37SeyleriusLet's try this properly now
19:37Seylerius&(map #(read-string (re-find #"^(?=0+)[1-9][0-9]*$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])
19:37lazybotjava.lang.NullPointerException
19:37SeyleriusHuh.
19:37fmzakarijustin_smith: Couldn't find a pagination example https://github.com/caribou in a sub-project
19:37justin_smithfmzakari: it's a huge project, I'll look real quick
19:38fmzakarii'm trying to think of something where your jdbc connection returns a lazy-sequence and you can (drop/take) from there i guess ?
19:39justin_smithfmzakari: or you can specify an offset and count with the request
19:40justin_smithwith the query that is
19:40fmzakarijustin_smith: right but im thinking of whether i would just plug those into my SQL query (limit offset) or apply it to the lazy-seq of the clojure list
19:41justin_smiththe former makes more sense if possible
19:42justin_smithfmzakari: I took a quick look but I am not sure where that is in the various caribou projects at this point any more
19:42fmzakariJustin_smith: okay thnx
19:42fmzakarii'll try to keep browsing github. I'd like to see something neat. I'm still learning so i might not think of something very idiomatic right away
19:49TEttingerSeylerius:
19:50TEttinger&(map #(read-string (second (re-find #"^0*([0-9]+)$" %))) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])
19:50lazybot⇒ (9 9 9 0 0 0 16 16 160 160 2015)
19:50TEttingerusing grouping to get multiple captures
20:07SeyleriusTEttinger: That did it, thanks.
20:07Seylerius(inc TEttinger)
20:07lazybot⇒ 61
20:13TEttingerwoo
21:23crocketWhat is the best way to handle unix signals?
21:23crocketI want to handle SIGINT emitted by Ctrl+C.
21:54crocketIf I press Ctrl+C while Thread.join() is blocking, is InterruptedException thrown?
23:10mercwithamouthso would you all say using Buddy is 'scary'
23:10mercwithamouthi'm looking over it (haven't toyed with it yet) but it seems daunting
23:57crocketI want to get a polymorphic behavior over a set of functions.
23:58crocketShould I use defprotocol and defrecord?
23:58crocketI don't particularly have a data structure over which to define a polymorphic behavior.
23:58crocketI'm writing a DDNS client.
23:58crocketAccording to DDNS provider string, I should choose an implementation.
23:58crocketIf the DDNS provider is dnsever, I want to get dnsever-specific behaviors.
23:59crocketDefining an empty defrecord just to get polymorphic behaviors feels awkward.
23:59crocketDo you know a better abstraction?