#clojure log - Jul 14 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:07 divya_: 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)

0:22 justin_smith: it's too bad run! doesn't take varargs

0:23 TEttinger: maybe it will make it into 1.7.0, justin_smith oh wait

0:43 Seylerius: With 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?

0:44 For 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.

0:57 Also, 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?

1:16 What's a good default pool size?

1:27 Guest25767: so I decided to tech myself Ruby as a first language about a year ago and I recently stumbled upon Clojure. interesting stuff!

1:30 crocket: Can a simple daemon in clojure run under 16MB?

1:53 Guest25767: anybody out there?

1:56 engblom: Guest25767:

1:56 Guest25767: Ye

1:56 Guest25767: Yes

2:04 Guest25767: i've always had self limiting beliefs about myself being able to program

2:04 its only when i started trying to solve problems i realized it was just illusion

2:10 arrubin: crocket: I packaged the example code on the front page of the http-kit site up in an uberjar and ran it with -Xmx8M.

2:10 Seems to work.

2:11 Hmm. That does not seem to limit all memory used by java.

2:16 crocket: arrubin, How much RAM does it use?

2:17 arrubin: In 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.

2:17 And that seems to be the minimum Metaspace that still allows it to run.

2:17 I do not know which other configuration options control memory, but I am guessing that getting everything below 16MB would be difficult.

2:18 Pupeno: I’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?

2:21 wasamasa: there is a certain bump involved though

2:23 Seylerius: ,(let [m {} port 4] (if (not-any #(= port %) '(nil -1)) (assoc m :port port)))

2:23 clojurebot: #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...

2:24 Seylerius: ,(let [m {} port 4] (if (not-any? #(= port %) '(nil -1)) (assoc m :port port)))

2:24 clojurebot: {:port 4}

2:24 Seylerius: Pupeno: Something like that, perhaps?

2:26 Pupeno: Seylerius: I was trying to not have yet another binding as it'll make the code look messy, hard to understand.

2:26 Seylerius: Pupeno: Ignore the let, that's just how I made sure I had a map and a port to test with.

2:27 The inner bit is what you want.

2:27 Basically, (if (not-any? #(= port %) [nil -1] (assoc m :port port)))

2:29 Pupeno: Seylerius: you are using m in there. Let me show you the code so it makes sense what I'm talking about:

2:29 https://gist.github.com/pupeno/a03b8863926cbed6ea2b

2:30 see the hashmap that has :db, :user, :password, :host, and :port. That's the one I'm trying to avoid complicating.

2:34 Seylerius: Pupeno: Have the piece-building functions return nil in the case of anything invalid, and then filter the nil keys out.

2:37 Pupeno: Something like (remove #(nil? (second %)) {:foo (get-foo)...})

2:39 Pupeno: In the clojure slack someone just pointed to this trick: (merge {:foo :bar :bar :foo} (if port {:port port}))

2:39 Seylerius: Pupeno: Hey, there's an idea.

2:40 I'd forgotten about merge.

2:40 Pupeno: Otherwise I was going for filter.

2:40 I wasn't *very* aware that merge handled nils so nicely.

2:41 crocket: -XX:MaxMetaspaceSize -Xmx

2:41 Pupeno: Is 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.

2:43 Seylerius: Wait... 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

2:50 Although, that one isn't Done Right™…

2:51 I'll have to fix it.

2:51 Still going to need to make my own.

2:59 crocket: arrubin, How did you execute your small clojure program?

2:59 I created a standalone uberjar.

3:05 Seylerius: What's better: http://sprunge.us/SPWg or http://sprunge.us/LJRa ?

3:24 amalloy: there's no real difference, Seylerius, except that i'd put a newline after the (fn []) if you choose that version

3:25 Seylerius: amalloy: I'll go with the #() then. Thanks.

3:33 schmir: I prefer (fn []..). you immediately see how many arguments the function takes without scanning the body

3:34 amalloy: that's a good point

3:52 Seylerius: I'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

3:52 resets)?

3:54 amalloy_: Did you miss my last question due to connection hiccups? The timing of your sudden nick-change looks vaguely like that...

3:56 I'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.

3:56 Should I just keep a counter for the day in an agent and reset it at midnight EST (when the provider's quota resets)?

4:06 Ach. What do I have to require to get ScheduledThreadPoolExecutor?

4:08 TEttinger: Seylerius: probably import, not require since it's a java class

4:08 Seylerius: TEttinger: And what the hell do I have to import?

4:09 TEttinger: it's in java.util.concurrent

4:09 which is weird but true

4:09 http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html

4:09 Seylerius: So, how do I import that?

4:09 And just the bit I need...

4:10 TEttinger: at the repl, you'd do (import '[java.util.concurrent ScheduledThreadPoolExecutor])

4:10 in an ns, it's slightly different

4:10 (:import [java.util.concurrent ScheduledThreadPoolExecutor])

4:10 that last line would go inside an ns call at the top of your file, usually

4:10 Seylerius: There we go.

4:11 TEttinger: I think that should work, I'm very rusty on java interop

4:11 if it doesn't, try replacing the space after concurrent with a dot

4:11 (there's no way to mass-import everything in a package)

4:12 Seylerius: That got past that error.

4:16 Hrm. What's the clj-time way to find the next midnight-EST from now?

4:17 Ah, there we go.

4:18 H4ns: is 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.

4:18 i mean i can just sleep and loop, but maybe there is something better/more idiomatic?

4:19 TEttinger: isn't there a Thread.wait method or something along those lines? might even be in Object

4:20 H4ns: to join a thread, i first need to have a handle to it.

4:21 i guess it will be best to just Thread/sleep forever

4:21 TEttinger: https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join(long)

4:21 oh ok

4:22 H4ns: ah, or i could join myself, that sounds clever :)

4:23 (.join (Thread/currentThread)) it is

4:23 TEttinger: I don't really know how you wouldn't have a handle on the threads

4:23 I think you can probably iterate through them too

4:23 H4ns: i'm starting various components and they might start threads on their own.

4:23 i don't think so. threads are not a managed resource.

4:25 TEttinger: https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#enumerate(java.lang.Thread[]) wowza the recommendation

4:25 that copies the active Threads into a native array of Threads

4:27 H4ns: TEttinger: 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!

4:27 TEttinger: heh cool

4:44 Seylerius: TEttinger: Can you think of a more idiomatic way to do this? http://sprunge.us/ZjYh

4:46 TEttinger: Seylerius, yeah

4:47 Seylerius: Maybe factor the reset and .schedule lines out into a separate function?

4:47 TEttinger: you could make the reset! and .schedule the body, and set the relevant bindings with if in the binding part

4:48 (let [delay (if (t/after? (t/now) @safe-time) 0 (t/in-millis (t/interval (t/now) @safe-time)))])

4:48 Seylerius: TEttinger: Wait, like use an if to return a binding vector for the let?

4:48 Oh.

4:48 TEttinger: no, let can't take a vector like that sadly

4:48 there's only two!

4:49 Seylerius: TEttinger: Yeah, I'd need to "if" both bindings in the let, but that might work.

4:50 Pity you can't swap the whole binding vector, but this'll be better.

4:50 TEttinger: maybe

4:50 it's pretty good as is

4:50 not sure if my suggestion actually helps

4:50 Seylerius: Hmm...

4:51 The kicker is that next-safe and delay are both calculated differently depending on whether we've already crossed into safe-time or not.

5:11 kwladyka: what can i use to draw board in console? I need function to change position for example 3x4 without redrawing all board each time

5:12 also will be great if i can use colours

5:12 noncom: kwladyka: something in the ways of ncurses? maybe http://sjl.bitbucket.org/clojure-lanterna/ ?

5:14 kwladyka: noncom, i need draw chess board and figures on this chess, figures will move

5:14 noncom, so i guess it is not this

5:15 noncom: kwladyka: well, if you're to draw in console, what can be better than ncurses? lantern is javaish ncurses.. no?

5:15 kwladyka: noncom, i didn't use them so i don't know

5:15 fast looking in the internet show me something else :)

5:15 noncom: what was that?

5:16 kwladyka: i wrote ncurses in google and found https://pl.wikipedia.org/wiki/Ncurses

5:16 is in my language but from this i can read read is more to draw things like on image on this site

5:17 noncom: it just allows you to draw whatever you like in the terminal

5:17 many roguelikes use ncurses

5:17 (all of them to be precise)

5:17 kwladyka: http://sjl.bitbucket.org/clojure-lanterna/ <- but it can be what i am looking

5:18 so now i have to learn that :)

5:18 noncom: sure 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...

5:18 frankly, 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...

5:21 kwladyka: but i am feeling like that http://devopsreactions.tumblr.com/post/115748298481/logging-in-to-an-old-server-to-update-bash

5:21 i want do something and all the time i have to something to do something :)

5:25 Seylerius: Grr... 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?

5:28 Niac: (:require [clojure.core.async :as async :refer [go >! >!! <! chan]]

5:28 what's for ">!"

5:46 dstockton: There has been talk in the past of a datomic whitepaper. Is that still around somewhere? All links i've found seem to 404.

6:07 Seylerius: Okay, 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.

6:08 Replacing simpleforecast's date map with an actual clj-time date-time is trivial, but txt_forecast is a pain.

6:08 Any ideas how to attach a date-time to each entry in the txt_forecast?

6:14 kwladyka: How 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?

6:15 yeah i think like i said :)

6:16 noncom: kwladyka: yeah! things tail one another...

6:16 kwladyka: (regrding the video clip you poseted)

6:17 kwladyka: refs are just ways to store state.. something like atoms but more concurrency-enabled

6:18 kwladyka: the author uses refs because they allow to ensure the order of changes in a concurrent environment

6:18 see the (dosync ...) magic - it does that

6:19 in 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

6:19 maybe 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...

6:21 Seylerius: Hah, nailed it.

6:25 kwladyka: noncom, thx

6:29 Seylerius: Weird. The println on line 143 is getting called, but the println on 150 isn't. http://sprunge.us/jbae

6:30 noncom: Seylerius: apparently, the if predicate passes for false?

6:31 Seylerius: Yeah, I figured that one out, now, but something else is breaking...

6:31 noncom: Seylerius: maybe you wanted to wrap the 'else' branch with a (do ...)

6:31 oh, you figured, ok

6:31 * the 'then' branch, sry

6:47 kaiyin: how should translate (use '(incanter core datasets)) into (ns (:use ...))?

6:47 kwladyka: hmm there is no more colours http://sjl.bitbucket.org/clojure-lanterna/reference/#colors ? Only this? Can i get brown?

6:48 https://github.com/sjl/clojure-lanterna/blob/master/src/lanterna/constants.clj <- it look not simple

6:48 and why googlecode?

6:54 Seylerius: How do I get the result of an event `.schedule`d onto a ScheduledThreadPoolExecutor?

7:03 TEttinger: You got any experience with ScheduledThreadPoolExecutors?

7:03 TEttinger: nope

7:06 Seylerius: Damnit. How the hell is a person supposed to get the result out of ScheduledThreadPoolExecutor.schedule?

7:09 loke: Seylerius: you don't?

7:11 Seylerius: loke: That'd be mightily lame... Do I have to stick what would be the return values onto a channel or something?

7:11 loke: Seylerius: Sorry. I double-checked the APIdocs

7:11 you can

7:12 Seylerius: loke: How?

7:12 loke: .submot() returns a Future, and you simply call .get() on it

7:12 .submit() even

7:12 Seylerius: loke: So I take the ScheduledFutureTask object that I get back from .schedule and pass it through .submit and .get?

7:13 No, that doesn't work.

7:14 loke: What is ShceuledFutureTask? .schedule() returns a ScheduledFuture which is a subclass of Future

7:14 you can call .get() ont hat

7:14 Seylerius: loke: I tried calling .get on the output of .schedule, and got a lovely nil

7:15 Even 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.

7:15 loke: Seylerius: did you call .schedule() with a Callable? If you call it with a Runnable you get the wrong type of ScheduledFuture back.

7:16 Seylerius: loke: Look at do-api-call, line 133-169 (http://sprunge.us/IbHQ). It's calling .schedule with a bound-fn

7:17 loke: Yeah, I think that results in a Runnable being created behind the scenes

7:18 You want to ensure a Callable is created

7:18 Seylerius: loke: How do I do that?

7:18 loke: I have no idea. I'I don't know the Java integration too well (I do Clojure using Clojurescript, but I know Java quite well)

7:19 Seylerius: (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.)

7:19 loke: Seylerius: Yes.

7:19 That should work.

7:19 Seylerius: But at the moment, I don't even get what the difference is between a Callable and a Runnable.

7:20 And how to produce each in Clojure.

7:20 loke: I 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.

7:20 A Callable can return a value while Runnable does not.

7:20 a Callable can also thorw exceptions.

7:21 Seylerius: loke: That much seems clear, but why is Clojure picking Runnable, and how do I tell it that it's being stupid?

7:21 loke: Seylerius: 1) Because it's the first one to be retirned, probably. 2) I have no idea.

7:22 tcrayford____: `fn` implements both runnable and callable

7:22 you wanna (cast Callable (fn [] blah))

7:22 Seylerius: tcrayford____: YAY!

7:22 loke: Oh. Clever

7:22 Seylerius: (inc loke)

7:22 lazybot: ⇒ 1

7:22 Seylerius: (inc tcrayford____)

7:22 lazybot: ⇒ 3

7:22 Seylerius: The answer has been found!

7:23 * tcrayford____ is kinda unsure what the "result" of a scheduledfuture is though

7:23 Seylerius: tcrayford____: Should be the return value of the Callable.

7:24 cfleming: You should be able to just type hint it rather than casting, too ^Callable #(whatever)

7:24 tcrayford____: right, but scheduled = it runs more than once…

7:24 Seylerius: tcrayford____: Wrong schedule. This is the run-one-after-a-delay schedule.

7:24 tcrayford____: ahhh, that makes sense

7:24 clojurebot: Excuse me?

7:24 Seylerius: There are a few others that do periodic.

7:24 tcrayford____: I've only ever used the periodic ones ;)

7:24 * Seylerius nods

7:25 tcrayford____: cfleming: type hints are weird though because of metadata. Unsure if `fn` discards it's metadata like every other macro ever though

7:25 Seylerius: Can I just (deref (.schedule)), or @(.schedule)? or something?

7:26 cfleming: tcrayford____: Ah, good point - it probably does.

7:26 tcrayford____: don't think so - deref is clojure internal, not a java thing

7:26 Seylerius: Okay. So (.get (.schedule))?

7:26 tcrayford____: yeah

7:26 cfleming: tcrayford____: 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.

7:27 tcrayford____: cfleming: ```richard-p-fineman-2.local:app(1d|master) $ ag "cast" src | wc -l

7:27 2```

7:27 https://www.irccloud.com/pastebin/Y12DPfZ8/

7:27 both of those are functions passed to `ScheduledThreadPoolExecutor`

7:27 cfleming: Haha, there you go

7:28 * tcrayford____ may have been here before

7:28 Seylerius: Great. For some finicky java reason, it's still not working.

7:28 tcrayford____: honestly kinda thinking about metadata being discarded by macros as a compiler bug

7:28 Seylerius: tcrayford____, cfleming: are you two going to be around here in about 6-8 hours?

7:28 tcrayford____: 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)

7:28 cfleming: tcrayford____: https://www.refheap.com/106552

7:29 Seylerius: I need to sleep soon, and want to pick this crap up later. You two seem to get the interop better than most.

7:29 tcrayford____: reminder that (.startsWith ^String (or a b) "a") gets a reflection warning

7:29 Seylerius: I make no promises about my availability

7:30 Seylerius: tcrayford____: Ballpark guesstimate if I promise not to shoot you for it being wrong?

7:30 cfleming: Seylerius: 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.

7:30 Seylerius: I oughta start hovering in the Clojure slack.

7:30 cfleming: tcrayford____: yeah, I'm planning an inspection in Cursive for those cases.

7:31 tcrayford____: And yeah, I definitely consider that a bug.

7:31 tcrayford____: yeah, likewise with having scrollback be a real thing, I'll see it eventually

7:31 Seylerius: Okay, well, I'm going to hit the hay. I need to be functional and at the office in 7 hours.

7:31 tcrayford____: just, the only folk who get promises about availability are friends, family and Yeller customers ;)

7:31 Seylerius: Heh.

7:31 tcrayford____: You a Yeller person?

7:31 cfleming: Even my family get no promises :)

7:32 tcrayford____: I'm *the* Yeller person - CEO, Founder, Sole Dev etc. I'm the only person in the company

7:32 Seylerius: Only people who get promises from me are my girlfriend and my boss. Everyone else gets vague guesstimates.

7:32 Thanks for the help

7:32 tcrayford____: np, happy we could

7:33 cfleming: having that as an inspection would be rad

7:33 cfleming: tcrayford____: Yup. With the new inference stuff I'll be able to highlight unnecessary hints, too.

7:33 tcrayford____: doope

7:33 cfleming: And suggest them when needed etc

7:34 tcrayford____: (BUY COLIN'S PRODUCT)

7:34 cfleming: ^^^ WHAT HE SAID

7:34 Oh, wait, you can't yet - that's my fault.

7:34 Or rather, my bank's.

7:34 grumble grumble

7:54 nooga: after playing with manifold, deferred deferred vector of deferreds is my new name

7:58 smith: Hi guys, a quick newbie question: how can I cast string to int in a clojure way?

7:58 That is, without using Integer/Parse

8:04 dstockton: smith: whats wrong with parseInt?

8:04 oops, ignore

8:04 thought this was cljs

8:05 no, Integer/parseInt is in fact right

8:05 tcrayford____: smith: Long/parseLong

8:05 (assuming you want a long - you probably do)

8:06 smith: Ah, I see. Thanks.

8:06 I was wondering if there is a way to avoid calling underlying Java methods.

8:06 Guess not.

8:07 nooga: what's wrong with calling Java?

8:08 tcrayford____: smith: typical clojure style calls java quite a bit where it's needed. You can of course write your own wrappers

8:08 smith: Thanks, if that's how to do things in Clojure, then I don't have any problems.

8:09 nooga: it's free, easy enough and does not require typing java code

8:09 smith: It's just felt a liitle weird at first, that's all. :P

8:09 wasamasa: clojure's tight interop is at odds with writing code that could run on another clojure implementation

8:09 smith: wasamasa: That's another concern of mind too.

8:10 * wasamasa is still shocked that the implementation is way more java than clojure code

8:11 rarebreed: Isn't that what the new clojure 1.7 reader condition #$ is supposed to make easier?

8:11 nooga: I took Java libs for MS Azure stuff and wrapped Azure queues in core.async channels using ~7 lines of code

8:11 rarebreed: so you can have some stuff in :clj and other code in :cljs?

8:11 oops, I mean reader conditional

8:12 so that you can minimize or at least factor out clojure implementation specific code

8:13 smith: rarebreed: You mean this? http://dev.clojure.org/display/design/Reader+Conditionals

8:13 rarebreed: smith: yeah

8:14 my understanding is that you can place clj or cljs specific code wrapped in the reader conditional

8:14 I never looked at the .net version of clojure, and I didn't see any mention of it in that page

8:15 just out of curiousity, is anyone else here from Red Hat? :)

8:16 crocket: How do I launch a new thread and block the current thread indefinitely until the program receives a kill signal?

8:16 Is there an elegant way to block the current thread indefinitely until the program receives a kill signal?

8:16 H4ns: crocket: (.join (Thread/currentThread)) it is

8:17 nooga: rarebreed: red hat MTV?

8:17 crocket: H4ns, What is it?

8:18 rarebreed: nooga: MTV? not sure what that is...I'm out in RDU :)

8:18 nooga: rarebreed: mountain view

8:18 rarebreed: and tomorrow I get to start at a new position and do some clojure ;)

8:18 H4ns: crocket: 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.

8:18 rarebreed: nooga: ah, hadn't seen MTV before. Most of the guys I work with are in BRN or TLV

8:18 dnolen: rarebreed: reader conditionals indeed work well. Indeed ClojureScript's implementation is either 11000 lines of Clojure or 21000 lines of ClojureScript depending on your perspective :)

8:19 crocket: H4ns, Is there a clojure idiomatic way to do it?

8:19 rarebreed: dnolen: oh, is the clojurescript implementation itself using reader conditionals? cool :)

8:19 crocket: That's java way

8:19 dnolen: rarebreed: it does now

8:19 for optional bootstrapping to JavaScript

8:19 H4ns: crocket: scroll back for the "parse integer" question that was discussed a few minutes ago.

8:20 nooga: rarebreed: I spent some time floor above RH MTV and met amny people in elevators :D

8:20 many*

8:20 crocket: H4ns, I wasn't here a few minutes ago

8:20 rarebreed: dnolen: 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.

8:20 so I need to check out how to use reader conditionals

8:20 H4ns: crocket: calling java is not unidiomatic in clojure.

8:21 crocket: I wonder if clojure has a function for that.

8:21 H4ns: crocket: it does not.

8:21 rarebreed: nooga: never been out to MTV. My hope is to convert more people to the clojure way ;)

8:21 I already got one of my coworkers on Openstack on it

8:21 and failing that...to use hy as a gateway drug to clojure hehe

8:22 * crocket fizzles

8:22 rarebreed: crocket: maybe you can try to dereference the result of a future? that will block your main thread

8:23 crocket: rarebreed, How do I block a future?

8:23 nooga: Well 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

8:23 crocket: future, delay, etc...

8:23 rarebreed: @(future (some-fn ...))

8:24 nooga: coming from node.js, java ee, python etc.

8:24 rarebreed: or (def result (future (some-fn ...)))

8:24 @resuilt

8:24 @result

8:24 H4ns: rarebreed: what would some-fn do?

8:24 rarebreed: the some-fn would be the function that is called in another thread

8:25 nooga: yeah, it seems like startups are the big pushers for clojure. I actually started writing some helper libraries for Openstack in clojure

8:25 it was not well received :p

8:26 nooga: :D

8:26 crocket: How do I trigger a form to be executed when I press Ctrl+C while (.join (Thread/currentThread)) is blocking?

8:26 puredanger: startups like Walmart, eBay, Netflix, etc

8:26 rarebreed: H4ns and crocket, when you dereference a future it will block the main thread until there's a result

8:26 nooga: puredanger: they always have some form of "internal startup"

8:27 rarebreed: puredanger: there are those too. and you forgot Staples :)

8:27 H4ns: rarebreed: yes, but we asked for blocking the main thread without having handles to other threads that may have been started.

8:27 nooga: R&D, consultants etc.

8:27 puredanger: I could go on for a while :) it's not always some "internal startup" either

8:28 although that is certainly one important vector into bigger companies

8:28 H4ns: crocket: you'll need to reach out into java again. you could start here: http://stackoverflow.com/questions/11709639/how-to-catch-ctrlc-in-clojure

8:28 rarebreed: puredanger: I talked with some other guys at Red Hat who used to be on JBoss...apparently some testing uses clojure

8:28 and there's also immutant

8:29 nooga: I imagine, that most of the time, it starts with a side project like testing stuff, utilities

8:29 and then somebody goes "look, this took 2 hours"

8:29 puredanger: See: http://cognitect.com/clojure#successstories and http://clojure.org/companies

8:29 crocket: Oh java

8:29 rarebreed: H4ns: does it count not having a handle to a thread if you do @(future (some-fn ...))?

8:29 crocket: H4ns, I don't think a shutdown hook will be called if I press Ctrl+C to kill a block on REPL.

8:30 H4ns: rarebreed: i don't have handles to my threads right now, so self-joining works fine

8:30 crocket: so you say that the answer on SO is wrong?

8:32 crocket: ah, i hear what you say. sorry, no idea.

8:32 crocket: H4ns, a shutdown hook

8:32 H4ns: crocket: you want an sigint handler, not a shutdown hook.

8:32 rarebreed: so speaking of clojure evangelism....has anyone had success converting python shops to clojure|scipt ?

8:32 arggh can't type today

8:33 nooga: I converted 3 pythonistas on my team :D

8:33 rarebreed: nooga: really? how'd you do it?

8:33 nooga: ant this has nothing to do with me being CTO

8:33 smith: rarebreed: just show them the benchmark

8:33 nooga: and*

8:34 rarebreed: so, until today, I've been a QE on the openstack project. Nova in particular

8:34 and lots of guys are dyed in the wool python guys

8:34 I haven't found a way to broach the "lispiness" of clojure

8:35 crocket: What

8:35 python is ok

8:35 python is ok for three day projects.

8:35 rarebreed: it's ok...but I'd like to introduce more people to clojure|script

8:36 and there's like this immediate resistance to it

8:36 maybe bad memories of lisp or scheme in college...I dunno :)

8:37 nooga: show 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"

8:37 tcrawley: rarebreed: what project are you on at RHT where you get to do clojure?

8:37 smith: rarebreed: in my experiences, most people are just more used to C/Java syntax

8:37 clojurebot: Titim gan éirí ort.

8:38 rarebreed: tcrawley: actually, I'm a quality engineer. Some of our testing code for candlepin/subscription-manager (believe it or not) is in clojure

8:38 candlepin itself is java/ruby

8:38 tcrawley: ah, neato. I'm at RHT as well, on Immutant

8:38 rarebreed: and subscription-manager is python

8:39 tcrawley: awesome...I'm just starting to learn immutatnt

8:39 tcrawley: come join us in #immutant if you have any questions

8:39 rarebreed: smith: yeah, I think you're right. most people just look at the syntax and get this knee-jerk reaction

8:40 smith: rarebreed: I'm an-ex Python programmer too, now I'm transition fulltime to Lisp/Clojure

8:40 rarebreed: the 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?'"

8:40 nooga: but lips have almost no syntax

8:41 rarebreed: that was my first impression with python :) and after 3 weeks, I didn't think about it anymore

8:41 nooga: I can't even start with Scala because syntax

8:41 smith: rarebreed: 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

8:41 nooga: and python with its whitespace

8:41 rarebreed: nooga: I tried learning haskell...and I will get back to it....but learning all the special syntax is such a drain

8:41 nooga: yeah

8:41 r4vi: you can actually make python repl work closer to lisp repl

8:41 nooga: exactly

8:41 r4vi: using ipython autorealod stuff

8:42 rarebreed: tcrawley: 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

8:43 my background has mostly been in hardware. embedded firmware, device drivers, and testing thereof

8:45 but I'm stoked I can actually do clojure and/or clojurescript full time now, and without it being skunkworks :D

8:51 tcrawley: rarebreed: good deal!

8:52 rarebreed: tcrawley: yeah. I found the position totally by accident too

8:53 tcrawley: just out of curiosity are you in Raleigh?

8:53 tcrawley: no, I'm in Asheville - remote

8:54 rarebreed: I 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

8:54 or is that Think Relevance...I forgot now

8:55 tcrawley: rarebreed: http://www.meetup.com/TriClojure/ is a great group of people

8:55 rarebreed: tcrawley: 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

8:56 tcrawley: yeah, Asheville is in the mountains

8:56 rarebreed: tcrawley: oh nice...looks like there's a meetup on the 30th :)

9:01 kwladyka: how (mod -10 3) gives 2 and (mod -2 5) gives 3?

9:02 '(mod -2 5)

9:02 `(mod -2 5)

9:03 ,(mod -2 5)

9:03 clojurebot: 3

9:07 TMA: kwladyka: because -10 = -4 * 3 + 2 and -2 = -1 * 5 + 3

9:07 H4ns: "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?

9:08 kwladyka: TMA, thx

9:13 justin_smith: H4ns: a) lein sucks b) cider sucks c) all of the above d) ???

9:13 lazybot: justin_smith: How could that be wrong?

9:15 wink: H4ns: hm, there might be an open bug report about that

9:15 H4ns: justin_smith: that was helpful, thanks!

9:15 justin_smith: haha

9:15 wink: (or even several)

9:15 justin_smith: I promise, I wasn't trying to be helpful, but maybe I was accidentally so

9:19 kwladyka: what can i use instead "ref" to not parallel state?

9:22 To be more precise:

9:22 (def terminal-size (ref [0 0]))

9:22 (defn handle-resize [cols rows]

9:22 (dosync (ref-set terminal-size [cols rows])))

9:22 can i do this more simple if i dont need parallel?

9:22 justin_smith: kwladyka: if retries are OK and you don't need coordination you can use an atom

9:22 kwladyka: if you can't do retries, you can use an agent

9:23 kwladyka: justin_smith, retries?

9:24 justin_smith: atoms and refs retry - they redo the transformation if there is any parallel modification

9:24 kwladyka: justin_smith, i just want remember state to not pass it as parameter to all functions

9:24 justin_smith: kwladyka: all of these are ways to have global state

9:24 kwladyka: http://stackoverflow.com/questions/9132346/clojure-differences-between-ref-var-agent-atom-with-examples

9:31 kwladyka: justin_smith, thx

10:09 CookedGryphon: Hey, 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:10 has anyone seen anything similary before?

10:10 it's in an extend-type

10:13 catonano: with clj-time I want to parse this datetime "25/03/2012 2.00"

10:13 this is my parser (let [multiparser (f/formatter (t/default-time-zone) "dd/MM/YYYY HH.mm" "YYYY-MM-dd HH:mm:ss")] ...

10:13 and

10:13 (f/parse multiparser source-datetime)

10:14 and I get

10:14 llegalInstantException 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:14 I found this https://stackoverflow.com/questions/26162702/cannot-parse-datetime-illegal-instant-due-to-time-zone-offset-transition-euro?rq=1

10:14 but how do I deal with this with clj-time ?

10:17 oh with to-timezone

10:17 I see now

10:22 crocket: How do I extract two keywords from a map concisely?

10:22 Using a function, I can use destructuring. Without it, I don't know.

10:23 tcrayford____: crocket: select-keys?

10:24 ,(select-keys {:a 1 :b 2 :c 3} [:a :b])

10:24 clojurebot: {:a 1, :b 2}

10:24 mmeix: or maybe

10:24 ,((juxt :foo :baz) {:foo 1 :bar 2 :baz 3})

10:24 clojurebot: [1 3]

10:24 crocket: ok

10:24 tcrayford____: select-keys is designed for this though, and much less confusing than juxt imo

10:25 mmeix: juxt, if one only needs the vals, of course

10:25 perplexa: catonano: i also think "2.00" might cause an error with "HH.mm"

10:26 catonano: perplexa: thanks I'll check that

10:26 crocket: How do I convert a map into a pretty-print string?

10:27 tcrayford____: ,(with-out-str (clojure.pprint/pprint {:a 1}))

10:27 clojurebot: #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:28 tcrayford____: bah

10:28 it's that

10:28 just clojurebot don't know about pprint

10:28 catonano: perplexa: no, it's the same even with 25/03/2012 2.00

10:28 I mean 25/03/2012 02.00

10:28 oh wait

10:29 perplexa: here http://pastebin.com/KdhgDsYu

10:30 devn: Anyone in here an amateur cryptographer? I have some nasty Java code I've written to do PBKDF2 with HMAC SHA1, AES256/CBC/PKCS5Padding

10:30 but I'd like to clean it up and use Buddy

10:30 CookedGryphon: crocket: 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:30 devn: I'm trying to figure out how to compose all the right pieces in buddy to get the same result

10:32 perplexa: catonano: what is your multi-parser?

10:33 catonano: (def multi-parser (f/formatter (t/default-time-zone) "dd/MM/YYYY HH.mm" "YYYY-MM-dd HH:mm:ss"))

10:35 perplexa: catonano: havn't used multi formatters yet, docs suggest your syntax is right. maybe try without the default tz

10:35 catonano: right away

10:36 crocket: CookedGryphon, FIPP!

10:37 catonano: perplexa: it seems to be required. An exception claim the argument could not be parsed as a timezone

10:37 oh well

10:37 perplexa: likely the one you're trying to parse

10:38 catonano: perplexa: yeah ClassCastException java.lang.String cannot be cast to org.joda.time.DateTimeZone

10:38 crocket: What is a simple way to save configs in a file?

10:38 catonano: and the sttring is supposedly the datetime string

10:38 crocket: Should I just save a clojure map in a text file and read it?

10:39 devn: Anyone here using one of the kafka libraries?

10:39 I have to say, I'm not all that impressed with what I've seen thus far.

10:39 perplexa: catonano: (tf/parse (tf/formatter "yyyyMMddHH") "2015010100") does that work for you?

10:39 devn: Which, 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:39 perplexa: tf is clj-time.format

10:46 jcromartie: CIDER says it is connected, but it doesn't open a REPL.

10:46 nREPL server started on port 51573 on host - nrepl://

10:46 I can connect to that from lein repl :connect...

10:46 but CIDER inside Emacs itself just sits there

10:47 I have CIDER version 20150713.1614

10:48 lesson learned: never update CIDER

10:48 devn: heh

10:48 melpa-stable FTW

10:51 crocket: Does clojure 1.6 have clojure.edn namespace?

10:52 jcromartie: is there a way to install a version of CIDER that works without changing my MELPA archive ?

10:54 ah ha

10:54 (add-to-list 'package-pinned-packages '(cider . "melpa-stable") t)

10:55 I've been bitten by this before

10:55 I should have learned by now

10:55 catonano: perplexa: just a minute

10:55 devn: crocket: yes

10:56 jcromartie: oh

10:56 I can't do ththat (pinned packages)

10:56 devn: im pretty sure i have an error or two at the moment

10:57 ; CIDER 0.9.1 (Java 1.8.0_11, Clojure 1.7.0, nREPL 0.2.6)

10:57 WARNING: CIDER requires nREPL 0.2.7 (or newer) to work properly

10:57 I'm not sure why...

10:57 well, I guess I'm not sure where I go to update nREPL

10:57 catonano: perplexa: yes, it works

10:59 devn: welp, I added [org.clojure/tools.nrepl "0.2.7"] to my ~/.lein/profiles.clj :dependencies [...]

10:59 seemed to do the trick

11:00 catonano: perplexa: also (f/parse (f/formatter "yyyyMMddHH") "2012032502")

11:00 works

11:01 it's the same sate that can't be parsed with my multi-parser

11:02 perplexa: catonano: maybe ditch the multiparser or look into the lib what it's doing

11:02 can't check right now, unfortunately

11:02 catonano: perplexa: thanks, I'll take a look at the lib code

11:08 crocket: What is a simple log library for clojure?

11:09 algernon: crocket: https://github.com/pyr/unilog

11:12 Empperi: also https://github.com/ptaoussanis/timbre

11:13 catonano: perplexa: I found the solution. It works with multiparsers too

11:14 perplexa: what was the error?

11:15 catonano: I used "parse-local" rather than "parse" That calls the java method "parseLocalDateTime" rather than the vanilla one

11:15 I saw it skimming through the code

11:16 perplexa: :)

11:16 catonano: the read me didn't mention it

11:16 perplexa: thanks !

11:18 perplexa: catonano: yw!

11:20 crocket: timber!!!

11:27 timvisher: anyone have a favorite way to set up an ssh port forward from clojure?

11:29 adgtl: Guys seeing this when I do cider-jack-in

11:29 CIDER requires nREPL 0.2.7 (or newer) to work properly

11:30 timvisher: adgtl: i'll bite. :) do you have nrepl 0.2.7?

11:30 keep in mind you need both the plugin and server for cider to work properly, afair

11:30 vaitel: https://github.com/clojure-emacs/cider#warning-saying-you-have-to-use-nrepl-027

11:31 timvisher: ooo… a FAQ!

11:39 adgtl: timvisher: Had to add https://gist.github.com/b12cdd1b65df187a58c5 to fix that

11:48 gzmask: How is the job market for Clojure right now? I am Canadian Web developer and looking for a clojure related job (preferable cljs).

12:01 crocket: yay

12:18 TimMc: gzmask: There are definitely some employers. Have you checked functionaljobs?

12:19 gzmask: Yes, there are the reuter one and couple others (mostly in UK)

12:19 arrubin: There are actually more Clojure jobs here: http://careers.stackoverflow.com/jobs?searchTerm=clojure

12:19 gzmask: applied for the reuter job, but not willing to relocated to UK at the moment

12:21 I have checked that too. I am more interested in startups with interesting projects

12:21 arrubin: One moment.

12:21 https://news.ycombinator.com/item?id=9812245

12:21 Search for Clojure there.

12:21 Watch that account on the first of each month.

12:22 gzmask: especially those ones who is going to use clojurescript with OM/Reagent and reactive native

12:23 Thanks, looks like a good place to start :)

12:23 hiredman: the amount of clojure jobs where they want you on site is very disappointing

12:23 gzmask: I bet most of these jobs are database/business centric?

12:23 @hiredman

12:24 hiredman: gzmask: a lot of them are for clojurescript

12:25 gzmask: clojurescript is exactly what I am after

12:28 arrubin: gzmask: 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:32 TimMc: gzmask: Not back-end stuff?

12:33 gzmask: thanks, I am looking at his submissions.

12:34 TimMc: My employer might be hiring soon. I can't promise Clojure, but we've racked up a few Clojure projects so far.

12:34 gzmask: TimMc: I did MySQL/Oracle and server administration tasks, so I have a little bit server side experience

12:35 TimMc: where are you guys located?

12:38 TimMc: gzmask: Boston.

12:41 gzmask: Good city. PMed.

12:45 edoloughlin: l/nick edoloughlin_

14:38 Seylerius: Okay, java interop time: How the fsck do you get the result out of scheduling a task into a ScheduledThreadPoolExecutor?

14:38 It's not deref or .get

14:40 hiredman: it is

14:40 puredanger: it returns a future of some kind I presume which I would expect to work with deref?

14:40 Seylerius: Well, both of those failed.

14:41 hiredman: I (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:41 Seylerius: I'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:41 hiredman: pprint returns nil

14:42 Seylerius: hiredman: It was (let [data foo] (pprint data) data)

14:42 To ensure that the data was still returned

14:42 And I've since removed that pprint.

14:43 http://sprunge.us/CfCJ

14:44 hiredman: so deref and .get do work, but they are returning nil?

14:44 Seylerius: do-api-call (133-173) actually does the scheduling, while forecast-10day calls do-api-call and wants to deref the future

14:44 hiredman: Yep.

14:44 They don't error out, but they return nil.

14:45 hiredman: which, I am guessing here, if you read the docs for scheduled tasks is what the futures return

14:45 http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html#schedule%28java.lang.Runnable,%20long,%20java.util.concurrent.TimeUnit%29

14:45 checkout Returns:

14:46 Seylerius: hiredman: It's the other schedule, the one that takes a callable.

14:46 blake_: 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:46 Seylerius: Because I cast the function to a callable.

14:47 hiredman: Seylerius: it seems pretty obvious that in fact the runnable method is being called

14:47 what makes you think the Callable one is being called?

14:49 Seylerius: hiredman: 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:49 hiredman: a quick test would be to replace the casting stuff with (let [f (bound-fn ...)] (reify Callable (call [_] (f))))

14:49 Seylerius: Okay.

14:49 hiredman: Seylerius: cast is more subtle than that

14:49 Seylerius: Great.

14:49 The only time Clojure ever frustrates me is when I have to fight with Java.

14:50 devn: hiredman: a couple of years ago you posted a gist of yours that was a core.async pipeline thingamajig.

14:50 you don't happen to have that handy, do you?

14:50 hiredman: the 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:51 the thread pool atom thing is a race condition too, you should consider using a delay

14:52 devn: hiredman: nevermind, found it at https://gist.github.com/hiredman/11194485

14:53 Seylerius: hiredman: What would you do there, to fix the thread-pool atom?

14:54 hiredman: that is complicated, but the quickest "fix" would be (def pool (delay (ScheduledthredPool...)))

14:55 and @pool as required

14:55 seangrove: What function would transform "a/b/c/d/e" -> ["a" "a/b" "a/b/c" "a/b/c/d" "a/b/c/d/e"] ?

14:56 Seylerius: hiredman: The reify bit fixed it.

14:57 hiredman: another 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:57 relies on

14:58 Seylerius: Hmm... I'm going to look up the delay tool

14:59 hiredman: Ah, a delay basically /is/ the thread-pool function.

15:00 Give the thing, or make one if we don't got one yet.

15:00 hiredman: yeah, but with the right locking around it to not be a race condition

15:00 Seylerius: Right.

15:01 When 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:04 TimMc: seangrove: feels a bit like clojure.core/reductions

15:05 or iterate with removing stuff from the end, then reverse it

15:11 justin_smith: TimMc: with a take-while. I should totally make a function that composes iterate with take-while

15:11 iterate-while

15:16 gfredericks: is there a good repl tool for getting enhanced docs from somewhere?

15:18 andyf_: 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:19 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:20 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:21 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:27 seangrove: TimMc: I like the iterate idea

15:28 TimMc: reduce would be easier to understand, I think

15:29 &(reductions #(str % \/ %2) (.split "a/b/c/d/e" "/"))

15:29 lazybot: ⇒ ("a" "a/b" "a/b/c" "a/b/c/d" "a/b/c/d/e")

15:29 amalloy: i think it's reductions

15:31 seangrove: TimMc: Much better that what I just wrote with iterate, yes

15:32 TimMc: &(take-while some? (iterate #(let [li (.lastIndexOf % "/")] (when (<= 0 li) (.substring % 0 li))) "a/b/c/d/e"))

15:32 lazybot: ⇒ ("a/b/c/d/e" "a/b/c/d" "a/b/c" "a/b" "a")

15:32 TimMc: yuck!

15:32 'course you still need the reverse on the first one

15:40 scriptor: ,(let [s "a/b/c/d/e"] (map #(subs s 0 (inc %)) (range 0 (count s))))

15:40 clojurebot: ("a" "a/" "a/b" "a/b/" "a/b/c" ...)

15:41 scriptor: hmm...

15:41 ,(let [s "a/b/c/d/e"] (map #(subs s 0 (inc %)) (range 0 (count s) 2)))

15:41 clojurebot: ("a" "a/b" "a/b/c" "a/b/c/d" "a/b/c/d/e")

15:41 scriptor: there we go

15:41 TimMc: scriptor: I don't think we can count on the segments always being length 1.

15:41 seangrove: ^?

15:42 but that's an interesting idea... if there were a way to get the positions of all the slashes easily...

15:42 scriptor: yeah, this is entirely assuming it's one char per slash

15:53 justin_smith: .indexOf "/" or some such

15:53 (for generating the split position number)

16:03 any 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:06 blkcat: kafka really lives up to its namesake sometimes :)

16:43 Cr8: ,(let [s "a,bcde,f,gh" h ","] (for [x (range (count s)) :when (.startsWith (subs s x) h)] x))

16:43 clojurebot: (1 6 8)

17:03 TimMc: Cr8: hah!

17:03 justin_smith: duplicate linear searches though

17:05 wait, no, never mind

17:10 ,(take-while #(>= % 0) (iterate #(.indexOf "a,bcde,f,gh" (int \,) (inc %)) 0))

17:10 clojurebot: (0 1 6 8)

17:10 justin_smith: the 0 is noise, of course

17:11 ,(take-while pos? (rest (iterate #(.indexOf "a,bcde,f,gh" (int \,) (inc %)) 0)))

17:11 clojurebot: (1 6 8)

17:11 justin_smith: much better

17:12 blake_: 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:13 justin_smith: blake_: 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:14 blake_: tx, justin_smith

17:15 jonathanj: is there some way to avoid the redundancy of declaring liberator resource decision functions when using compojure's (context) macro?

17:24 blake_: justin_smith: Although actually that might have been me, too.

17:27 csd_: hi does anyone know if its possible to pass an async channel into a quartzite job?

17:28 justin_smith: blake_: heh, iirc tcrawley-away is the guy working on immutant, right?

17:33 blake_: justin_smith: I think he and jcrossley3 have been my big helps in the past on this.

17:36 jcrossley3: blake_: what's the issue?

17:37 csd_: that should be fine as long as you're only using the default in-memory persistence

17:37 blake_: jcrossley3: I have an app with a web.xml file that contains a security-constraint section.

17:37 jcrossley3: right, didn't we already discuss this a while back?

17:38 blake_: jcrossley3: So when I go to my-server:8080, it gets pushed over to my-server:8443.

17:39 jcrossley3: Yeah! But at the time I thought the issue was the java-servlet version.

17:40 jcrossley3: blake_: 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:51 blake_: jcrossley3: I've got to deploy with HTTPs, yeah, but Wildfly actually shows no error. It returns an error to the client.

17:52 jcrossley3: Yeah, I trolled #Wildfly for a while with no luck.

17:52 jcrossley3: blake_: what error?

17:53 blake_: jcrossley3: A standard SSL connection error. "Unable to make a secure conneciton to the server..."

17:54 jcrossley3: blake_: have you set up your keys and a self-signed cert?

17:55 blake_: jcrossley3: Not locally, no. I guess I should start there.

17:55 xemdetia: blake_, what does openssl s_client -connect thehost:8443 if anything

17:55 short output=bad, long output=good

17:56 blake_: xemdetia: Bad file descrptor, errno=10061

17:56 (so, short)

17:56 jcrossley3: blake_: http://stackoverflow.com/questions/29138478/how-to-configure-ssl-in-wildfly-8-2-0-server

17:57 blake_: it's easier in immutant ;) (but you still need to create keys)

17:57 blake_: 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:58 cryptack_: 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:58 jcrossley3: blake_: and it was being successfully redirected to 8443? strange

17:58 blake_: jcrossley3: I'm close to using immutant. =P

17:58 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:00 xemdetia: sorry blake sounds like an app problem not at tls problem :(

18:01 blake_: 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:01 xemdetia: yuck

18:01 jcrossley3: blake_: can you grab a copy of the war in production and crack it open to verify the web.xml is as you expect?

18:01 blake_: jcrossley3: I can't personally but I might be able to get it. Good idea.

18:02 jcrossley3: blake_: 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:03 blake_: 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:12 jcrossley3: blake_: 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:14 blake_: 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:16 jcrossley3: blake_: 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:18 blake_: 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:18 jcrossley3: blake_: if there is a reverse proxy involved, all bets are off, because it may be doing the redirect itself

18:19 blake_: jcrossley3: That could be. They don't like to tell us what they're doing. =)

18:19 jcrossley3: :)

18:20 blake_: 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:22 justin_smith: blake_: I would take a statement like "Oh, yeah, we tweaked some stuff. Nobody noticed."

18:23 blake_: justin_smith: lol

18:23 justin_smith: as an invitation to ask them as your first resort if anything isn't working

18:24 if nothing else it means next time they know "someone noticed"

18:24 blake_: justin_smith: High turnover. There's no departmental memory. It's like Memnto meets Groundhog Day.

18:24 jcrossley3: blake_: 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:25 blake_: jcrossley3: Thanks! Much appreciated. Might've spared me some angst.

18:25 bbl

18:54 rhg135: is 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:55 justin_smith: rhg135: do any of your profiles.clj deps work?

18:56 rhg135: yes, justin_smith, all but this one it seems

18:56 well, I had tried spyscope and it also failed

18:56 justin_smith: because the simplest explanation would be that your profiles.clj is merely malformatted

18:58 Seylerius: If 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:59 rhg135: (filter number? coll)

19:00 Seylerius: rhg135: Nah, I want to transform the strings to numbers.

19:00 rhg135: oh

19:00 Seylerius: ["2015" "07" 09 12 "00"]

19:00 Needs to become [2015 7 9 12 0]

19:01 rhg135: try ##(keep #(try (Integer/parseInt %) (catch Exception _ nil)) ["1"])

19:01 lazybot: java.lang.SecurityException: You tripped the alarm! catch is bad!

19:01 rhg135: well

19:01 try it at home I guess

19:03 I think I may just be overlooking something https://www.refheap.com/106576, and no, lein deps :tree just lists my project's deps

19:11 TEttinger: ,(map read-string ["2015" "07" 09 12 "00"])

19:11 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>

19:11 TEttinger: ,09

19:11 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>

19:12 amalloy: TEttinger: you want integer/parseint

19:12 TEttinger: Seylerius: 09 is not valid as a number

19:12 amalloy: with the radix 10 specified

19:12 justin_smith: ,017

19:12 clojurebot: 15

19:12 amalloy: it doesn't really matter for [09], because you can't have a value that prints that way

19:12 TEttinger: amalloy: the example he gave had non-string number 09

19:13 amalloy: TEttinger: sure, it was an example he made up, because it is impossible to have such a thing

19:13 TEttinger: k

19:13 justin_smith: ,0123

19:13 clojurebot: 83

19:13 TEttinger: yes justin_smith they're octal

19:13 justin_smith: yes, for some reason I find that amusing

19:13 ,0xdeadbeef

19:13 clojurebot: 3735928559

19:14 TEttinger: ,36rILIKEPIE

19:14 clojurebot: 1457390052518

19:14 amalloy: because 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:14 TEttinger: and in clojure's case, base 27

19:14 amalloy: i guess i don't mind the ability to do that, like 8r755

19:14 but to use something innocuous like 0755 is confusing

19:15 TEttinger: ,27rGAMBLE

19:15 clojurebot: 235338548

19:16 TEttinger: ,(map #(read-string (str "10r" %)) ["2015" "07" 09 12 "00"])

19:16 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 09>

19:16 TEttinger: hm

19:17 ,10r09

19:17 clojurebot: 9

19:17 TEttinger: right it's before that

19:17 ,(map #(read-string (str "10r" %)) ["2015" "07" 9 12 "00"])

19:17 clojurebot: (2015 7 9 12 0)

19:18 justin_smith: TEttinger: from a coworker ##(identity 36rwhatisthemeaningoflife`

19:18 err

19:18 TEttinger: ,36rwhatisthemeaningoflife

19:18 clojurebot: 15630618813727882227183131952537482N

19:18 TEttinger: ,36rwhatisthemeaningoflifetheuniverseandeverything

19:18 clojurebot: 350942681731242990203511395147592895386304091688071820253349265705971116N

19:19 TEttinger: ,35rwhatisthemeaningoflifetheuniverseandeverything

19:19 clojurebot: 98826347130333606158459885179744852531856458432998128759946017006701121N

19:19 justin_smith: ,(.indexOf (str 35rwhatisthemeaningoflifetheuniverseandeverything) "42")

19:19 clojurebot: -1

19:19 justin_smith: :(

19:20 ,(.indexOf (str 36rwhatisthemeaningoflifetheuniverseandeverything) "42")

19:20 clojurebot: 4

19:23 Seylerius: amalloy, 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:24 amalloy: right, and those are all strings

19:24 Seylerius: And I want them to be numbers.

19:24 Sometimes they'll return numbers interspersed with the strings.

19:24 Well, all except :pretty and :tzname

19:25 But read-string craps on "09" (first thing I tried)

19:25 TEttinger: correct

19:25 09 is not a valid literal

19:25 but you can do

19:25 Seylerius: Is there a function that will trim leading 0s?

19:25 TEttinger: ,10r09

19:25 clojurebot: 9

19:25 TEttinger: 10r is radix 10

19:25 or

19:26 #(Integer/parseInt % 10)

19:26 but that will crap on strings

19:26 I guess so will 10rbob

19:26 Seylerius: Well, I don't particular expect :min to hold "bob" any time soon.

19:28 TEttinger: ,(map read-string #(re-find #"[1-9]*[0-9]$" %) ["9" "09" "0" "00"])

19:28 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: sandbox$eval48$fn__49>

19:29 TEttinger: ,(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "0" "00"])

19:29 clojurebot: (9 9 0 0)

19:29 TEttinger: Seylerius: does that work?

19:29 Seylerius: Yeah, it does.

19:29 That strips any leading zeroes, don't it?

19:30 TEttinger: yep

19:30 Seylerius: W1n.

19:30 (inc TEttinger)

19:30 lazybot: ⇒ 60

19:30 TEttinger: let me do some more testing!

19:30 Seylerius: I'll give more karma for more testing.

19:31 You've been warned.

19:31 TEttinger: &(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016"])

19:31 lazybot: ⇒ (9 9 9 0 0 0 16 16)

19:31 TEttinger: so far so good

19:32 &(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160"])

19:32 fmzakari: hi, does anyone have any code examples of doing pagination in a ring web app?

19:32 lazybot: ⇒ (9 9 9 0 0 0 16 16 160 160)

19:32 Seylerius: &(map #(read-string (re-find #"[1-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])

19:32 lazybot: ⇒ (9 9 9 0 0 0 16 16 160 160 15)

19:32 fmzakari: I'm specifically using https://github.com/krisajenkins/yesql and wondering how to do it clojure-idiomatic

19:32 TEttinger: a ha!

19:34 justin_smith: fmzakari: 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:34 TEttinger: &(map #(read-string (re-find #"^(?:0*)[0-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160"])

19:34 lazybot: java.lang.NumberFormatException: Invalid number: 09

19:34 TEttinger: hm

19:34 fmzakari: is caribou an OSS site or framework?

19:34 let me lookit up.

19:35 TEttinger: &(map #(read-string (re-find #"^(?:0*?)[0-9]*[0-9]$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160"])

19:35 lazybot: java.lang.NumberFormatException: Invalid number: 09

19:35 justin_smith: fmzakari: 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:36 comes 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:36 Seylerius: &(map #(read-string (re-find #"(?=0+)[1-9][0-9]*$" %)) ["9" "09"

19:36 "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])

19:36 &(map #(read-string (re-find #"(?=0+)[1-9][0-9]*$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])

19:36 Did I crash lazybot?

19:36 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

19:36 java.lang.NullPointerException

19:36 Seylerius: ,(map #(read-string (re-find #"(?=0+)[1-9][0-9]*$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])

19:36 Whooo! lag!

19:36 clojurebot: #<NullPointerException java.lang.NullPointerException>

19:36 justin_smith: Seylerius: you were lagged, and then spammy

19:36 Seylerius: Yep

19:37 Let's try this properly now

19:37 &(map #(read-string (re-find #"^(?=0+)[1-9][0-9]*$" %)) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])

19:37 lazybot: java.lang.NullPointerException

19:37 Seylerius: Huh.

19:37 fmzakari: justin_smith: Couldn't find a pagination example https://github.com/caribou in a sub-project

19:37 justin_smith: fmzakari: it's a huge project, I'll look real quick

19:38 fmzakari: i'm trying to think of something where your jdbc connection returns a lazy-sequence and you can (drop/take) from there i guess ?

19:39 justin_smith: fmzakari: or you can specify an offset and count with the request

19:40 with the query that is

19:40 fmzakari: justin_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:41 justin_smith: the former makes more sense if possible

19:42 fmzakari: I took a quick look but I am not sure where that is in the various caribou projects at this point any more

19:42 fmzakari: Justin_smith: okay thnx

19:42 i'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:49 TEttinger: Seylerius:

19:50 &(map #(read-string (second (re-find #"^0*([0-9]+)$" %))) ["9" "09" "009" "0" "00" "000" "16" "016" "160" "0160" "2015"])

19:50 lazybot: ⇒ (9 9 9 0 0 0 16 16 160 160 2015)

19:50 TEttinger: using grouping to get multiple captures

20:07 Seylerius: TEttinger: That did it, thanks.

20:07 (inc TEttinger)

20:07 lazybot: ⇒ 61

20:13 TEttinger: woo

21:23 crocket: What is the best way to handle unix signals?

21:23 I want to handle SIGINT emitted by Ctrl+C.

21:54 If I press Ctrl+C while Thread.join() is blocking, is InterruptedException thrown?

23:10 mercwithamouth: so would you all say using Buddy is 'scary'

23:10 i'm looking over it (haven't toyed with it yet) but it seems daunting

23:57 crocket: I want to get a polymorphic behavior over a set of functions.

23:58 Should I use defprotocol and defrecord?

23:58 I don't particularly have a data structure over which to define a polymorphic behavior.

23:58 I'm writing a DDNS client.

23:58 According to DDNS provider string, I should choose an implementation.

23:58 If the DDNS provider is dnsever, I want to get dnsever-specific behaviors.

23:59 Defining an empty defrecord just to get polymorphic behaviors feels awkward.

23:59 Do you know a better abstraction?

Logging service provided by n01se.net