#clojure log - Jan 02 2016

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

0:03 princeso: any one having this same issue? "clojure 1.7.0 evaluates function at compile time" http://pastebin.com/J0ceA3yE

0:04 justin_smith: princeso: macros are intended to run at compile time, it's expected clojure behavior

0:06 princeso: justin_smith: i dont get it. How is that?

0:06 justin_smith: princeso: macros run at compile time. That's when they are supposed to run.

0:06 well, technically they run between read, and compilation, so they run before compilation

0:07 princeso: but the thing being evaluated is a function. Im missing something

0:07 justin_smith: princeso: when you ask clojure to compile a file, it does three things: it reads, it runs all the macros, and it compiles the byte code

0:07 princeso: it's a macro

0:07 princeso: observe is a macro, so it is run before compiling

0:08 princeso: justin_smith and how that macro knows of the x variable?

0:08 justin_smith: princeso: perhaps you are confused about how macros work. macros should contain the code that should run before compilation, and the return value of the macro determines the form that runs at run time.

0:08 princeso: because at read time x is known

0:09 princeso: your macro is actually returning nil, and nil is the form at runtime as far as the compiler is concerned

0:09 your macro should be returning the form that you want evaluated at runtime

0:12 princeso: in this case, I think (defmacro observe [thing] (list 'println &env)) would do what you expect here

0:12 notice unlike your version, it isn't running println, it is returning a list containing println

0:12 and that will be the code used when the code runs

0:17 princeso: justin_smith ah yes, now i get it. Yes when the compiler hits the observe cal it compiles the macro etc... Thanks justin_smith :D

0:19 justin_smith: np

0:27 princeso: justin_smith yo should write a book about this things.

0:28 justin_smith: princeso: thx, maybe I'll try some day

0:33 p_l: princeso: in the mean time, you could use some of the ancient common lisp lore about macros, from which clojure macros appear to be derived mostly

0:39 princeso: p_l. thx. ill search. lisp was always my todo list

0:40 justin_smith: the classic is paul graham's "on lisp"

0:40 yes, that paul graham

0:44 princeso: paul graham lets check it out

0:44 justin_smith: last I checked there were legit pdfs of it available

0:45 princeso: also, stuart halloway has translated code from that book to clojure http://thinkrelevance.com/blog/2008/12/12/on-lisp-clojure

0:45 link there also to the port by fogus

0:50 mindbender1: what's the fastest way of throwing '((a 1) (b 2)) into a {} ?

0:50 justin_smith: having them in vectors instead of lists

0:50 failing that (into {} (map vec ...))

0:51 mindbender1: justin_smith: thanks

0:51 justin_smith: (reduce #(conj % (vec %2)) {} l) might be faster perf wise

0:51 if that really matters

0:54 mindbender1: justin_smith: my system tells me your first advice is faster.

0:54 justin_smith: oh, cool

1:03 mindbender1: criterium says the reduce version is twice as fast as the into / map combo, now trying an into/map transducing combo which I expect to be the fastest of the three

1:03 mindbender1: Please do share!

1:04 justin_smith: when this last benchmark is done running I'll paste it all up - oh, interesting, reduce was still fastest

1:04 mindbender1: https://gist.github.com/noisesmith/8752dba8efde182852e4

1:05 it was definitely a close call

1:06 princeso: justin_smith thats good. thx mate

1:07 mindbender1: justin_smith: Yes. Very interesting results. I was using the basic time fn to evaluate.

1:08 justin_smith: mindbender1: the readme of the criterium github page explains the gotchas with using time to do micro-benchmarks

1:08 tl;dr the jvm is tricky and does weird things to make the code that runs the most faster

1:08 so if your code's speed really matters, you have to measure what happens when that optimization is applies

1:08 *applied

1:11 mindbender1: Right. Thanks for bringing my attention to criterium. I guess it's a must use for things like this.

1:12 justin_smith: mindbender1: also, something like visualvm or yourkit in order to know which code will actually make a difference if you speed it up

1:12 with a real app, often the bottlenecks are not where you expect

1:13 mindbender1: Ho do you use either of those with clojure?

1:14 *How do

1:14 Is there some kind of clojure wrapper?

1:14 justin_smith: mindbender1: you run your clojure program, then start up the profiler, and pick your clojure's vm from the list of running java processes to profile

1:15 mindbender1: Oh cool!

1:15 justin_smith: visualvm is free, and comes with the jdk

1:16 mindbender1: the biggest gotcha that I find though is that the profiler wants to give you info based on class / method, and in idiomatic clojure, it's the same classes and methods everywhere in the code!

1:16 (persistentFoo data structures, conj, cons, IFn.apply / IFn.eval*)

1:16 which means extra digging compared to what you might need for a java program

1:17 mindbender1: Lol. What tricks have you come uup with for handling those?

1:17 justin_smith: mindbender1: making a defrecord to use instead of a map

1:17 mindbender1: Ha

1:17 Won't that be too much work?

1:17 justin_smith: not because I am implementing an interface - but because that way I can track memory usage / method usage on that defrecord

1:18 it's not much work at all

1:18 (defrecord MyWhatever [])

1:18 and then use (->MyWhatever) instead of {} or use into

1:19 that makes it easier to track usage of one record type separate from all other hash map usage

1:19 mindbender1: defrecords for special cases or in all cases. Is there a yardstick you use to decide?

1:19 justin_smith: this is specifically when I was trying to figure out who was generating all the data filling the heap

1:20 I had suspicions based on stack traces and other perf stuff, and made records for the things I suspected

1:20 mindbender1: Okay just plain defrecords with any special protocols?

1:21 *without

1:21 justin_smith: right - just defrecord tso I can isolate what's using the heap

1:21 mindbender1: Okay

1:21 justin_smith: for methods / CPU the stack traces and thread traces are more usable

1:21 (though deep, because this is clojure after all :P)

1:22 mindbender1: That shouldn't be much work then. Especially when valuable info is at stake!

5:27 taspat: hi, i cannot execute "lein repl" neither in windows nor in linux, I get this error: https://gist.github.com/anonymous/9be771673ec7d6af93b0

5:28 ridcully_: linode (and therefor clojars) has ongoing ddos attacks

5:29 rsync your ~/.m2 over from a machine, that got it loaded at some point in time

5:30 taspat: I never had loaded

5:30 anyway, thanks ridcully_

5:46 l1x: hi guys

5:46 is there a tool that recompiles my code when I change something in the file?

5:46 (for clojure)

5:48 lokien: you mean compiling while working on the code?

6:13 hellofunk: is clojars.org having some issues?

6:14 lokien: it's down for me too

6:14 hellofunk: the website is not loading for me and when I load a local clojure project, NREPL reports: (java.net.NoRouteToHostException) caught when connecting to {s}->https://clojars.org: No route to host

6:14 beaky: me too

6:15 maybe they ar ehosted on linode :D

6:15 ridcully_: they _are_ hosted on linode

6:15 hellofunk: yes they are, just checked

6:15 i wonder why all the hate against linode by the attackers?

6:16 ridcully_: blackmail most likely

6:16 lokien: "99.9% uptime guaranteed" :^)

6:17 Petazz: Hi guys! Trying to run this https://devcenter.heroku.com/articles/clojure-web-application but I end up getting PSQLException The server requested password-based authentication, but no password was provided.

6:17 hellofunk: just shows that even something as simple as ddos can swamp good companies without easy resolution

6:17 Petazz: How can I grant access to PG for my clojure connection?

6:17 hellofunk: Petazz: are you running locally or on heroku?

6:17 if on heroku, you need to use the postgres password they assign to you

6:18 Petazz: it will usually be in your config, and then you must access this environmennt variable inside your app, using clojure's environ library is a good way to do so

6:19 Petazz: hellofunk: locally

6:19 Trying to just get started with a real application :)

6:19 hellofunk: Petazz: well, same idea, except you must have postgres running locally first of all, then you have to be using the credentials into your local db

6:20 Petazz: I tried fiddling with the pg_hba.conf file..

6:20 hellofunk: Petazz: should not be necessary

6:23 taspat: is there some way to be able to run "lein repl" without connecting to clojars (some offline setup)?

6:24 Petazz: hellofunk: Hmm I'm quite lost with postgres. How do I add a user?

6:24 The heroku instructions seem weird, they just init a db and it should work?

6:25 hellofunk: Petazz: doing things locally with postgres is not likely going to be covered by a heroku tutorial since that is not really heroku-specific. i'd recommend a postgres tutorial

6:26 Petazz: it will also be easier to understand the clojure interaction with postgres if you can first create and modify tables within postgres itself at the commandline, so you have an idea of what is happening under the hood

6:26 ridcully_: either use `createuser` on commandline or `create user` in psql

9:32 taspat: that is weird, being a newbie and wanting to play with clojure is imposible while clojars webserver is dead

9:33 lokien: taspat: implement space invaders then

9:33 with core only

9:34 taspat: :D

9:34 lokien: :^)

9:39 does someone use typed clojure here?

9:43 or schema?

10:26 codefinger: Petazz: you can use the Heroku database from you local machine too. Use the host, port, user, password found in the DATABASE_URL when running `heroku config` and then add "ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory" to the JDBC URL

10:40 favetelinguis: clojars is down?

10:45 jonh: favetelinguis: i think (i could be wrong) but where they are hosted linode is currently being dos'd so it's effecting clojars

10:45 suspicious_e: seems so, https://twitter.com/clojars/status/683010552608722944

10:51 favetelinguis: wow that tweet is 20h old?

10:52 must be some serious dos..

10:58 jonh: favetelinguis: looks like it

11:12 l1x: huh

11:13 linode needs bigger pipes :)

11:13 they should try AWS, so i heard

11:20 favetelinguis: how can i make a (Thread/sleep ..) in cljs?

11:21 justin_smith: favetelinguis: perhaps js/setTimeout

11:21 there are no threads, so sleeping everything is not usually the right thing

11:23 favetelinguis: justin_smith: ok, i need the restat of websockets to happen before i try to login to a service, im doing a super naive implementation as a poc but it is starting to get ugly :)

11:24 justin_smith: the annoying thing about setTimeout is that it needs a function as an arg and that function is what gets called after the timeout

11:24 but it can totally be used in eg. a wait-loop

11:40 tcrawley: anyone want to help me test a clojars mirror?

11:40 I have one set up, based on an rsync from last night

11:40 this is an "official" mirror, since I'm the maintainer of clojars

11:40 justin_smith: tcrawley: sure, I'll try it out

11:41 tcrawley: justin_smith: https://clojars-mirror.tcrawley.org/repo/

11:41 justin_smith: tcrawley: I assume temporarily move my current .m2, then bootstrap a project with plenty of deps with that mirror replacing clojars in my project.clj?

11:41 tcrawley: yeah, that would do it

11:42 you'll need: :mirrors {#"clojars" {:name "clojars mirror"

11:42 :url "https://clojars-mirror.tcrawley.org/repo"}}

11:42 engblom: Could anyone give a suggestion on how to get this function to compile: http://pastebin.com/BBxRgkip The offending line is 16 because recur is not in the tail.

11:43 tcrawley: you can add that to ~/.lein/profiles.clj under the :user profile

11:43 engblom: Also general suggestions on how to improve it are welcome

11:45 justin_smith: tcrawley: Could not transfer artifact lein-figwheel:lein-figwheel:pom:0.3.7 from/to clojars (https://clojars-mirror.tcrawley.org/repo/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

11:46 tcrawley: hmm, what version of java are you using?

11:46 justin_smith: Java(TM) SE Runtime Environment (build 1.8.0_05-b13)

11:46 tcrawley: I'm using a letsencrypt cert, which may not work with some javas?

11:46 justin_smith: yeah, my java definitely does not like it

11:47 tcrawley: it works for me with OpenJDK Runtime Environment (build 1.8.0_65-b17), but I can't require everyone to update java

11:53 anyone have recommendations of where to buy ssl certs that will work with java 6+?

11:55 p_l: hmm, letsencrypt should work with Java, it's not like they are using ECDHE

11:55 justin_smith: p_l: any insight on that error?

11:59 p_l: does "openssl s_client -verify_host -connect clojars-mirror.tcrawley.org:433 " report any problems?

12:01 justin_smith: p_l: getting errors about the command line syntax

12:02 p_l: change -verify_host to -showcerts

12:02 that said, I get connection refused

12:02 tcrawley: p_l: try port 443

12:03 p_l: ... right

12:03 not enough sleep

12:03 justin_smith: at the end I get Verify return code: 20 (unable to get local issuer certificate)

12:04 (after fiddling the command line a bunch)

12:04 tcrawley: I get Verify return code: 0

12:04 p_l: justin_smith: sounds like you have outdated ca-certificates?

12:04 tcrawley: https://gist.github.com/bda9ce355887cbb1b88a

12:05 justin_smith: https://gist.github.com/noisesmith/bbe5f0d2c33ab187cafa

12:06 p_l: you have outdated ca certs

12:06 justin_smith: p_l: cool, updating now (it's been way too long since I ran aptitude it seems)

12:09 tcrawley: cool, let me know if it works for you after

12:32 justin_smith: tcrawley: still getting the same error, so unless I need certificates that are newer than any my OS provides I'm not sure what's up

12:33 it might just be me though, someone else should try using the mirror for sure

12:33 tcrawley: hmm, I've had a few other folks try it with success

12:33 does openssl still complain?

12:33 justin_smith: yeah, same result

12:33 tcrawley: what version of debian/ubuntu are you on?

12:35 justin_smith: OK, just explicitly ran "update-ca-certificates" - same error

12:35 trusty

12:35 which is probably pathetically old now

12:36 tcrawley: yah, it may not get cert updates anymore

12:37 justin_smith: in 2014 they said trusty would be supported for 5 years

12:38 tcrawley: hmm

12:39 justin_smith: oh, now I get an OK

12:39 (for the openssl check)

12:41 favetelinguis: what is the idomatic way of handling state in long running go-loop blocks? my guess is to use a var here?

12:42 justin_smith: favetelinguis: the idiomatic thing is to make it a loop binding

12:43 no, definitely not idiomatic at all to modify a var inside a go loop

12:46 favetelinguis: justin_smith: the state will be saved in a map so you say i should just pass the new map in each recursive call? makes sense

12:47 justin_smith: right, make the map one of the loop args

12:47 favetelinguis: nice thanks (as always :))

12:57 jonathanj: am i being stupid here? https://pb.codehash.net/39e9bd94fd424c96853e7b9041e43b86

12:57 https://github.com/haraldk/TwelveMonkeys/blob/twelvemonkeys-3.2.1/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/jpeg/JPEGQuality.java#L85

12:57 that's the source for the version i'm using from maven

12:59 trying to invoke it seems to fail too:

12:59 => (JPEGQuality/getJPEGQuality (-> "/Users/jonathan/Downloads/6703c8e9-89aa-481c-a07a-1ec0365fc91b.jpeg" clojure.java.io/file clojure.java.io/input-stream))

12:59 IllegalArgumentException No matching method found: getJPEGQuality clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)

13:00 justin_smith: jonathanj: it wants a List of JPEGSegment

13:00 oh never mind

13:00 wrong version

13:08 jonathanj: is there any way i can inspect the class/function from a repl?

13:09 justin_smith: jonathanj: clojure.reflect

13:10 jonathanj: okay, so this method is present

13:10 and it's public

13:10 oh hang on

13:10 and ImageInputStream isn't an InputStream

13:12 doh

13:13 that was a waste of 30 minutes staring at code

14:20 danlentz: So, is clojars.org down?

14:21 justin_smith: danlentz: looks down again, yeah, it's been down as much as up the past few days

14:22 danlentz: Dammit I knew I should have contributed to that Kickstarter ;)

14:22 justin_smith: danlentz: tcrawley shared a mirror he set up - it's not working for me (likely for config reasons) but is working for others

14:23 :url "https://clojars-mirror.tcrawley.org/repo"

14:25 tcrawley: justin_smith: I just replaced the ssl cert - can you try again?

14:25 justin_smith: sure thing

14:26 tcrawley: danlentz: see https://github.com/clojars/clojars-web/wiki/Mirrors

14:26 justin_smith: tcrawley: this one works

14:26 tcrawley: yay!

14:26 justin_smith: thanks man

14:26 tcrawley: also, you might have gotten false positives from others, because the :repositories key merges by default, but I use the ^:replace metadata

14:27 or would the key "clojars" have made it replace the other?

14:27 danlentz: Much appreciated will give it a try

14:27 tcrawley: did you set it up as a mirror, or just replace the :repositories key?

14:27 (see the wiki link above)

14:28 momerath: sorry if everyone is asking: is clojars down?

14:28 justin_smith: tcrawley: I did not set it as a mirror, I replaced the repositories - in fact I cheated, I already had a project that for its own reasons was overriding the repositories

14:28 tcrawley: gotcha

14:28 justin_smith: momerath: tcrawley has a mirror you can use

14:28 tcrawley: momerath: https://github.com/clojars/clojars-web/wiki/Mirrors

14:28 momerath: cool- thanks!

14:30 justin_smith: wow the dep list for this project is really, really, sadly huge

14:38 lokien: Hey guys, what would you recommend to implement for exercise? 4Clojure problems are too short, I'm seeking something bigger.

14:39 justin_smith: lokien: project euler?

14:39 advent of code?

14:40 lokien: justin_smith: something standalone? not "someone has built a rpg, you have to write a combat system for it"

14:40 justin_smith: lokien: how are project euler problems not standalone?

14:41 lokien: justin_smith: oh, I talked about advent of code. project euler gets me focused on maths, not on the language :(

14:45 I'll do advent of code then, thanks justin_smith

15:08 amalloy: lokien: did you try the harder 4clojure problems? i wouldn't call those short

15:10 eg http://www.4clojure.com/problem/140 or http://www.4clojure.com/problem/127

15:15 lokien: amalloy: no, I'll check it now

15:17 amalloy: damn, they're hard

15:17 amalloy: well i linked you to two of the hardest, since you wanted hard ones

15:17 there's plenty in the middle too

15:18 lokien: you overestimate me

15:18 amalloy: like http://www.4clojure.com/problem/96 is much easier

15:18 but not so easy as the intro problems

15:18 lokien: anyway, how to change some sequence in a string to another sequence? like :s/foo/bar/g in vim

15:19 justin_smith: ,(clojure.string/replace "hello, world!" "world" "shoes")

15:19 clojurebot: "hello, shoes!"

15:19 amalloy: but advent of code is also great, and i don't want to discourage you from doing those. i used them to practice haskell

15:20 lokien: eh, I was looking at clojure.core/replace. thanks, justin_smith

15:21 amalloy: haskell is too spooky for me now (just as ocaml)

15:21 these problems make me anxious too, but I have to start doing *something*

15:41 advent of code would be so easy with imperative approach, ugh.

15:46 engblom: I have created my very first library and I wish to be able to put it directly as a dependency project.clj. How should I upload it so lein will be able to download it?

15:46 justin_smith: engblom: for local usage you can run "lein install" and that will make it available in other projects

15:47 engblom: to share on the network, you could upload it to clojars or some other maven server

15:47 engblom: clojars.org seem to be down...

15:47 justin_smith: if you want to share publicly on clojars, "lein deploy clojars" should do that

15:47 there is that

15:48 lokien: can I have haskell's x:xs destructuring here (on a string)? or do I have to do (first string) etc?

15:48 justin_smith: ,(let [[x & xs] "hello"] [x xs])

15:48 clojurebot: [\h (\e \l \l \o)]

15:48 lokien: oh.

15:49 justin_smith: unlike in haskell, a list of char is not a string

15:50 lokien: (apply str (flatten list-of-chars))?

15:50 justin_smith: you don't need flatten

15:50 lokien: oh, right

16:06 engblom: Do I have a bad value in my DNS servers or is clojars.org really down?

16:06 justin_smith: ~you don't need flatten

16:06 clojurebot: excusez-moi

16:06 justin_smith: engblom: linode has been under attack, clojars has been down

16:06 lokien: it is, servers are being ddosed

16:06 justin_smith: engblom: one of the attacks has been against DNS, but that's not all

16:07 engblom: Ok, thanks

16:15 lokien: justin_smith: clojure says "Parameter declaration "loop" should be a vector" when I use your destructuring

16:16 and I'm pretty sure it's a vector (but I'm sure in a minute you'll prove it actually isn't)

16:17 justin_smith: lokien: can you show me the code?

16:17 ,(fn loop)

16:17 clojurebot: #error {\n :cause "Parameter declaration missing"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Parameter declaration missing"\n :at [clojure.core$fn invokeStatic "core.clj" 4354]}]\n :trace\n [[clojure.core$fn invokeStatic "core.clj" 4354]\n [clojure.core$fn doInvoke "core.clj" -1]\n [clojure.lang.RestFn invoke "RestFn.java" 442]\n [clojure.lang.Var invoke "Var.java" 388]...

16:17 justin_smith: ,(let loop)

16:17 clojurebot: #error {\n :cause "let requires a vector for its binding in sandbox:"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "let requires a vector for its binding in sandbox:"\n :at [clojure.core$let invokeStatic "core.clj" 4312]}]\n :trace\n [[clojure.core$let invokeStatic "core.clj" 4312]\n [clojure.core$let doInvoke "core.clj" -1]\n [clojure.lang.RestFn invoke "RestFn.java" 445]\...

16:17 justin_smith: hmm

16:17 lokien: minute

16:18 justin_smith: ,(fn (loop)) ; lokien this is how you get that error

16:18 clojurebot: #error {\n :cause "Parameter declaration loop should be a vector"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Parameter declaration loop should be a vector, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.IllegalArgumentException\n :message "Parameter declaration loop ...

16:18 lokien: eh, I forgot an argument list to my function, I only made it for loop

16:26 justin_smith: it still doesn't work (returns nil every time). do you mind if I send you my code? ~12 lines

16:26 justin_smith: sure, or you could paste it somewhere

16:27 not on this channel though

16:27 lokien: I pasted it on lpaste, can I send a link here?

16:27 justin_smith: sure

16:27 lokien: http://lpaste.net/3871394851014574080

16:29 * lokien hopes it won't become a "how I fixed the worst clojure code ever" blog entry

16:30 sampwing: anyone familiar w/ figwheel have any ptrs? Trying to start figwheel w/ base lein fighwheel template. Output and traceback: https://gist.github.com/sampwing/1b43d5f70c5b44057f48

16:31 justin_smith: lokien: one potential issue - you won't ever reach -1

16:31 rhg135: That's not too bad

16:32 justin_smith: ,(- 1 10)

16:32 clojurebot: -9

16:32 lokien: why won't I?

16:32 justin_smith: lokien: look at the code above

16:32 that's what you do if x is equal to )

16:33 lokien: oh

16:33 prefix notation rocks /s

16:33 justin_smith: I mean you might hit -1 by accident, but for most inputs you won't ever

16:33 lokien: for this we have inc / dec

16:33 but also prefix is great, it just takes a minute to learn

16:34 ,(< 0 1 2 3 10) ; just try doing this with infix as nicely

16:34 clojurebot: true

16:34 lokien: yeah, you're right

16:34 but it still returns nil immediately

16:36 it should return the last expression.. how would counter be nil?

16:36 justin_smith: ,(cond nil :wat false :WAT)

16:36 clojurebot: nil

16:36 justin_smith: it is returning the last expression

16:37 you hit the end of the string, x is nil, none of your clauses match

16:37 lokien: the code works if you replace the + 1 with inc and the - 1 with dec

16:37 lokien: so, he didn't reach the basement?

16:37 justin_smith: lokien: your code is broken

16:37 lokien: http://lpaste.net/3871394851014574080

16:38 justin_smith: nil would mean never hitting -1, yes

16:38 lokien: justin_smith: I've noticed

16:38 justin_smith: but that should work if it did hit the basement

16:38 bibac: Hi, regarding the clojars outage. I added the mirrow and can pull most dependencies. Eventually it fails with "Connect to repo1.maven.org:443 [repo1.maven.org/23.235.43.209] failed: Operation timed out". Anything I can do on my end?

16:39 lokien: justin_smith: it works with a short string, I'll check what's wrong with this long dude

16:39 justin_smith: lokien: perhaps it has characters in it that are not ( or )

16:39 because that code will just return nil if it hits one

16:40 lokien: perhaps you want to add a "char other than ( or )" clause to the cond?

16:40 lokien: justin_smith: yeah, 'cause I have no :else

16:40 no, it's this file

16:40 http://adventofcode.com/day/1/input

16:40 justin_smith: lokien: right, it defaults to nil if an input is not matched - implicit :else nil

16:40 "Puzzle inputs differ by user. Please log in to get your puzzle input."

16:41 lokien: oh, sorry

16:41 it's all like "()(((()()()()()" and only that

16:41 no other characters

16:41 justin_smith: than sure, that should return nil, because it would never hit -1

16:41 MJB47: the first one

16:42 is pretty easy to solve

16:42 with 0 code

16:42 unless you are doing it to learn clojure better

16:42 lokien: MJB47: you mean?

16:42 MJB47: you can ctrl-f and see the count of 1 char

16:42 and then get the other

16:42 and then minus them

16:43 lokien: I've replaced ( to "open" and ) to "closed", parens had broken my regexp

16:43 anyway, that's the problem, my file is like "openclosedopenopen"

16:47 leftylink: silly question - newline at the end of that file?

16:47 that would be a non ( ) char

16:47 oh but eh you'd probably hit the basement before oyu get to the end, so maybe it doesn't matter

16:47 justin_smith: leftylink: lokien: wouldn't change the result - the floor never goes to -1, so it will return nil

16:47 right

16:48 lokien: umm, let's see

16:48 yeah, nil leftylink

16:48 amalloy: iirc the input files don't have newlines

16:49 but your text editor might add one, if you save it locally

16:49 lokien: ")(((((()))(()(\n"

16:49 maybe, I saved it with vim

16:49 amalloy: right. i saved mine with emacs, and it added a newline, but that was fine with me, i love newlines

16:50 lokien: unless it breaks your app on windows

16:51 ( \n vs \r vs \r\n, thank you hickey for (newline))

16:58 itissid: clojars is down?

16:58 justin_smith: mostly, yeah

16:58 itissid: there's a mirror

16:59 itissid: https://github.com/clojars/clojars-web/wiki/Mirrors

17:00 itissid: Thansk justin_smith, setting it up now..

17:08 felixn: do I have to add the mirror to my project file as well?

17:09 https://gist.github.com/munro/7c8915bff75b1d9271a3 <-- I followed the instructions, but it didn't set up correctly

17:14 pilne: waitasecond... i can have macros, monads, actors, and futures in clojure?!??!!!??!?!!

17:15 felixn: pilne: and logic programming!

17:15 * pilne goes off to teach clojure how to make the perfect sammich

17:16 pilne: it really is a secret weapon in a coding arsenel

17:17 felixn: oh, and it's the only language that stands on it's own, and compiles to javascript extremely well. (ignore haxe XD)

17:18 pilne: played with haxe... felt very... hacked together and a bit of dependency hell-ish

17:19 well, it stands on the jvm, but that isn't inherenly a bad thing anymore with how good (and tune-able) the gc has gotten, and how prevalent it is *everywhere*

17:20 and pixie seems to be getting some development again after a bit of a hiatus

17:20 felixn: jvm is super slow to start up, but the key is just never restart the vm, you can reload modules to rerun tests

17:21 pilne: yeah, and the startup isn't a big deal for a program you expect the user to start and then run for a while (like a "useful" desktop app, or a game)

17:21 justin_smith: itissid: oh, is this the initial bootstrap of the lein install?

17:21 itissid: if so, it might be using clojars hard coded :(

17:24 felixn: justin_smith: hey sorry to bug you directly, but do you know what's wrong with my setup with switching to a mirror? https://gist.github.com/munro/7c8915bff75b1d9271a3

17:24 tcrawley: felixn: it looks like lein *may* not honor mirrors when resolving plugins. I'm trying to debug that now

17:24 felixn: tcrawley: ah thanks a lot

17:24 justin_smith: felixn: I was able to use that mirror as a regular repo

17:25 felixn: and it downloaded plugins with no trouble

17:26 itissid: justin_smith: It was when I ran it. Setting up `~/.lein/profiles.clj` with the mirror fixed the run command.

17:26 felixn: justin_smith: hmm, what's the exact code you used in your project file? :repositories {"...." "https://clojars-mirror.tcrawley.org/repo/&quot;}

17:27 justin_smith: felixn: https://gist.github.com/noisesmith/bb2804c8c3624ca9aaa4

17:27 felixn: it needs all of the entries, because the ^:replace key overwrites the normal locations, rather than merging

17:30 felixn: justin_smith: ah nice that works. should that be put in the channel topic?

17:30 justin_smith: felixn: well, it isn't supposed to be the official way to do this...

18:09 m4ck: Why is the use function apparently frowned upon for use in production code?

18:10 justin_smith: it makes refactoring harder than it needs to be

18:11 m4ck: justin_smith: oh, how so?

18:12 justin_smith: if I want to move a function to a new namespace, which namespaces do I need to use in order for that function to work

18:12 is it safe to remove those namespaces from the use of the other ns?

18:13 it's easy to answer these questions if you don't use use, it's not if you do

18:13 clojurebot: No entiendo

18:15 m4ck: I'm struggling to see how using require & refer alleviates issues surrounding that

18:15 justin_smith: m4ck: easy - don't use refer

18:15 require with refer is just like use with only

18:15 amalloy: require :refer solves this just fine too

18:15 what you shouldn't do is (require ...) (refer ...), but (require ... :refer ...) works

18:16 because it explicitly lists all the things you're using

18:16 clojurebot: It's greek to me.

18:16 amalloy: whenever you see a function used in the namespace, you know you can look up at the ns clause and see exactly where it came from

18:17 m4ck: amalloy & justin_smith: right, is the reason it's easier simply because you're explicitly listing the symbols being used?

18:17 amalloy: yes

18:18 or use require :as, and then prefix each with the ns it came from

18:18 m4ck: Gotcha, that makes complete sense then. Seems to be the same advice as "don't do import x.y.z.*; in Java"

18:18 justin_smith: exactly

18:18 m4ck: notice that kind of import is impossible in clojure too

18:19 m4ck: justin_smith: isn't that exactly what use is doing though?

18:20 Taking a wildcard underneath a known namespace, and making them all accessible indiscriminately in the current one

18:22 justin_smith: m4ck: right. When I said import, I meant import. Like the thing that does what java import does, but doesn't accept wildcards.

18:22 ,(doc import)

18:22 clojurebot: "([& import-symbols-or-lists]); import-list => (package-symbol class-name-symbols*) For each name in class-name-symbols, adds a mapping from name to the class named by package.name to the current namespace. Use :import in the ns macro in preference to calling this directly."

18:22 justin_smith: m4ck: namespaces are not packages and vars are not classes, we have both kinds of thing

18:23 m4ck: Ah, I think I'm with you now

18:23 Thanks

18:34 rhg135: a thing I've started to do is to only use symbols that are in the code file

18:34 justin_smith: rhg135: plus clojure.core I hope?

18:35 rhg135: of course

18:37 usually those are obvious. like I see map/filter/reduce in my dreams they're so common

18:38 taspat: hi, I'm getting this error when doing cider-jack-in from emacs: https://gist.github.com/anonymous/aae2f1f3049fdd538353

18:39 Im really confused about this nrepl cider thing

18:41 justin_smith: taspat: it wants 0.11.0-SNAPSHOT and you have 0.10.0

18:42 rhg135: justin_smith: but it's saying he's running 0.8.x

18:42 justin_smith: yes, that is weird

18:42 taspat: if I edit my .lein/profiles.clj to 0.11.0, lein repl doesnt even complete (gets error from clojars)

18:42 tolstoy: taspat: Try putting those outside the :repl map.

18:42 rhg135: probably being overwritten but by what

18:43 justin_smith: taspat: there is no such thing as 0.11.0 yet afaik

18:43 taspat: the clojars error is because clojars is down, but if clojars were not down (or if you use a mirror) it should find 0.11.0-SNAPSHOT

21:29 pilne: do you have a ~/.lein/profiles.clj with the appropriate info in it?

21:29 what version cider are you using?

21:30 it is saying you don't have 0.11.0-SNAPSHOT installed

21:30 try it with 0.8.2

21:31 justin_smith: pilne: the problem is that the version you have in clj has to match the version in elc

21:31 and it's not easy to switch out elc versions

21:40 pilne: ahhhh, so emacs has some peculiarities

21:41 justin_smith: pilne: yeah, it doesn't have versioned deps like our clojure ecosystem

21:42 pilne: granted, versions probably didn't change as regularly back when emacs was created

21:43 justin_smith: emacs predated many of our modern concepts of versioning

21:43 hell, emacs predates source control

21:43 pilne: yeah, i wonder when there will be a "neomacs" like someone made "neovim"

21:43 justin_smith: pilne: there have been many, none caught on

21:43 pilne: hrm... clojure might be the language to do it in too....

21:44 just for historical prescidence

21:45 justin_smith: emacs has been redone in haskell, ocaml, common lisp, scheme (they are still talking about doing scheme again), likely others I am forgetting

21:45 pilne: and yet the only one that survives is the grand old elisp version >.<

21:46 justin_smith: and there were various redos of the elisp (or even attempts to do everything without elisp), that have also all faded away by now

21:46 in fact gosmacs was one of the reasons for the first GPL

21:47 stallman had contributed extensively to the shared ball of source they called "emacs", and then gosling copyrighted a bunch of it and sold it with the name gosmacs, and stallman was like fuck that, gpl from now on

21:49 tolstoy: Do you think the lispiness of elisp is what makes Emacs so much more, I don't know, fun, than say, Atom or Sublime?

21:53 I'm not sure what the difference is. Emacs is mostly written in its extension langage, but not Atom?

21:53 Plugins vs interpreter?

21:53 justin_smith: hmm... you can use the browser without atom, you can't use the C core of emacs without elisp

21:53 it would literally be useless

21:54 but then, comparing js in the browser to elisp in emacs might be a better comparison, for modern browsers where much of the UI is in fact js

21:55 tolstoy: Maybe firefox especially, with the Xul stuff?

21:55 justin_smith: tolstoy: if the only difference between firefox and chrome was which js you told them to read by default at boot - that would be getting closer maybe

21:55 sdegutis: justin_smith: I finally have reason to learn what tries are!

21:56 kenrestivo: does anyone use xul anymore?

21:56 justin_smith: sdegutis: interesting, what's the use case?

21:56 sdegutis: justin_smith: I've decided to write immutable strings/vectors/linked-lists/hash-maps in C, and mikera posted in a comment on S.O. that Clojure uses "32-way hash array mapped tries https://en.wikipedia.org/wiki/Hash_array_mapped_trie" whatever the hell that means

21:56 tolstoy: kenrestivo: No idea. I've not paid attention to Firefox in a long times, but wasn't it used to implement most of Firefox?

21:57 sdegutis: kenrestivo: that weird emacs-like browser does afiak

21:58 tolstoy: I used to use TextMate which had a plugin architecture, but it was too high a barrier of entry for me.

21:58 justin_smith: sdegutis: immutable things in c - I hope you plan on using a garbage collector because otherwise that sounds very painful

21:58 tolstoy: Emacs, on the other hand, I can enter one line and fix something. After a while, you're doing stuff you'd never attempt in other editors because yak shaving.

22:00 sdegutis: justin_smith: I came up with something I think is probably overly clever last night while trying to sleep (man I was so friggen tired) that might make garbage collection easier for me.. https://github.com/sdegutis/Paladin/blob/master/paladin.c#L69-L97

22:00 tolstoy: Anyway, I'm kind curious if Emacs' lack of a "plugin" system (outside of convention) is actually a really good thing.

22:01 sdegutis: justin_smith: i felt so proud because it allowed O(1) getting a "free" object, and O(n) traversing in-use objects when mark/sweep'ing

22:11 pilne: i'm pretty happy with atom, i've been toying around with emacs and spacemacs some, i made the choice to learn vim years ago because... modal made sense to me

22:17 and light table is quite interesting, a bit... quirky and rough, but interesting nonetheless

22:46 retrogradeorbit: hey people. I was doing some work and clojars went offline

22:46 lein now just hangs

22:46 I tried LEIN_OFFLINE=y

22:46 justin_smith: retrogradeorbit: there's info to use a mirror on the clojars repo

22:47 retrogradeorbit: lein new checks for updated templates...

22:47 retrogradeorbit: justin_smith: cant get to clojars repo to read the mirror

22:47 justin_smith: retrogradeorbit: no, the github repo for clojars, one moment

22:48 retrogradeorbit: https://github.com/clojars/clojars-web/blob/master/MIRRORS ?

22:48 justin_smith: retrogradeorbit: https://github.com/clojars/clojars-web/wiki/Mirrors

22:49 and if that doesn't work, there's this hack that I figured out: https://gist.github.com/noisesmith/bb2804c8c3624ca9aaa4 but try the first one first, that's the real way

22:50 retrogradeorbit: is there anyway to make leiningen not go online?

22:50 theres no need to do so in the situation Im in

22:50 its all in the maven cache

22:50 yet it just hangs wanting to connect?

22:50 I dont have a profile at all. So I have to google how to set one up

22:50 justin_smith: retrogradeorbit: lein thinks making a new repo means looking for the newest version of the template

22:50 retrogradeorbit: so I can add the mirror

22:51 Im not making a new repo

22:51 justin_smith: *new project, sorry

22:51 retrogradeorbit: just tring to build

22:51 lein figwheel actually

22:51 $ lein figwheel

22:51 Jan 03, 2016 11:45:01 AM org.apache.http.impl.execchain.RetryExec execute

22:51 INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://clojars.org:443: Network is unreachable

22:51 repeatedly says that over and over every 30 seconds

22:52 justin_smith: probably checking for a snapshot somewhere in your dep tree

22:52 I think there's a flag to ask lein not to check for snapshots...

22:53 retrogradeorbit: you can add :snapshots false to a repo definition

22:54 retrogradeorbit: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L82

22:54 retrogradeorbit: see also my gist, that shows how to use the mirror as the repo, and not use clojars at all (for your project at least)

22:54 the one I called a hack

22:57 retrogradeorbit: It must be figwheel.

22:57 retrogra1eorbit: wait no cljsbuild isnt working wither

22:57 I added the mirror to profile. Still not working

22:58 justin_smith: retrogradeorbit: well, there's always starting a cljsbuild jar repl, and calling build with your cljs config map by hand like some kind of caveman

22:58 you can get the cljs jar from maven central, org.clojure

22:58 retrogra1eorbit: lein should work offline. Also the mirror should work.

22:59 justin_smith: those things are both true

22:59 retrogra1eorbit: right now I cant build at all

22:59 can anyone build atm?

22:59 justin_smith: retrogradeorbit: did you try my config example where you use ^:replace to make "clojars" point at the mirror?

22:59 retrogra1eorbit: yeah I tried the mirror

22:59 in the user profile

22:59 set to the one public mirror

23:00 justin_smith: retrogradeorbit: yes, in my project using that mirror I am building an uberjar right now

23:00 which includes a clojurescript build

23:00 retrogra1eorbit: how do I know the profile is working?

23:00 or even loading?

23:01 leiningen is often frustratingly silent with errors

23:01 justin_smith: it's true

23:01 it has a verbose flag, right?

23:01 retrogra1eorbit: does it?

23:02 nope doesnt look like it

23:02 justin_smith: if you set the DEBUG env var it will be more verbose

23:02 rhg135: Lein-pprint can help

23:02 justin_smith: retrogra1eorbit: there is also LEIN_OFFLINE because :offline? does not work for plugins

23:03 maybe that would help too

23:05 retrogra1eorbit: https://www.refheap.com/113310

23:06 anything wrong with my profile?

23:06 am I invoking it right?

23:06 rhg135: That's looking like figwheel itself is calling clojars

23:07 justin_smith: that looks right - in my project, with the :repositories ^:replace trick, figwheel starts up

23:07 let me change that setting and see if it fails like it does for you

23:08 retrogra1eorbit: funny, even when I change to look for the old clojars address instead, figwheel still starts up like normal for me

23:09 retrogra1eorbit: what if you provide the LEIN_OFFLINE env var too?

23:16 retrogradeorbit: https://www.refheap.com/113311

23:17 justin_smith: whats your figwheel version?

23:17 justin_smith: weird, I guess that's a bug on figwheel if it doesn't respect the LEIN_OFFLINE flag

23:18 0.3.7 - probably not up to date

23:18 retrogradeorbit: right yeah. old

23:18 I'll investigate the figwheel code

23:24 someone else is having my problem

23:24 http://stackoverflow.com/questions/34573135/using-a-mirror-of-clojars-from-leiningen

23:24 thats not me

23:24 asked 34 minutes ago

23:24 justin_smith: yeah, with this unprecedented clojars downtime, a few features of various lein related projects are being tested for the first time

23:25 retrogradeorbit: its a good smoketest

23:27 pilne: this figwheel looks interesting

23:28 justin_smith: it's pretty cool, when it works

23:28 retrogradeorbit: yeah its amazing... when it runs

23:28 :P

23:29 pilne: lol

23:30 retrogradeorbit: openned ticket for posterity

23:30 https://github.com/bhauman/lein-figwheel/issues/316

23:54 clojars back online.

23:58 rhg135: Yay

Logging service provided by n01se.net