#clojure logs

2016-01-02

00:03princesoany one having this same issue? "clojure 1.7.0 evaluates function at compile time" http://pastebin.com/J0ceA3yE
00:04justin_smithprinceso: macros are intended to run at compile time, it's expected clojure behavior
00:06princesojustin_smith: i dont get it. How is that?
00:06justin_smithprinceso: macros run at compile time. That's when they are supposed to run.
00:06justin_smithwell, technically they run between read, and compilation, so they run before compilation
00:07princesobut the thing being evaluated is a function. Im missing something
00:07justin_smithprinceso: 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
00:07justin_smithprinceso: it's a macro
00:07justin_smithprinceso: observe is a macro, so it is run before compiling
00:08princesojustin_smith and how that macro knows of the x variable?
00:08justin_smithprinceso: 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.
00:08justin_smithprinceso: because at read time x is known
00:09justin_smithprinceso: your macro is actually returning nil, and nil is the form at runtime as far as the compiler is concerned
00:09justin_smithyour macro should be returning the form that you want evaluated at runtime
00:12justin_smithprinceso: in this case, I think (defmacro observe [thing] (list 'println &env)) would do what you expect here
00:12justin_smithnotice unlike your version, it isn't running println, it is returning a list containing println
00:12justin_smithand that will be the code used when the code runs
00:17princesojustin_smith ah yes, now i get it. Yes when the compiler hits the observe cal it compiles the macro etc... Thanks justin_smith :D
00:19justin_smithnp
00:27princesojustin_smith yo should write a book about this things.
00:28justin_smithprinceso: thx, maybe I'll try some day
00:33p_lprinceso: 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
00:39princesop_l. thx. ill search. lisp was always my todo list
00:40justin_smiththe classic is paul graham's "on lisp"
00:40justin_smithyes, that paul graham
00:44princesopaul graham lets check it out
00:44justin_smithlast I checked there were legit pdfs of it available
00:45justin_smithprinceso: also, stuart halloway has translated code from that book to clojure http://thinkrelevance.com/blog/2008/12/12/on-lisp-clojure
00:45justin_smithlink there also to the port by fogus
00:50mindbender1what's the fastest way of throwing '((a 1) (b 2)) into a {} ?
00:50justin_smithhaving them in vectors instead of lists
00:50justin_smithfailing that (into {} (map vec ...))
00:51mindbender1justin_smith: thanks
00:51justin_smith(reduce #(conj % (vec %2)) {} l) might be faster perf wise
00:51justin_smithif that really matters
00:54mindbender1justin_smith: my system tells me your first advice is faster.
00:54justin_smithoh, cool
01:03justin_smithmindbender1: 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
01:03mindbender1Please do share!
01:04justin_smithwhen this last benchmark is done running I'll paste it all up - oh, interesting, reduce was still fastest
01:04justin_smithmindbender1: https://gist.github.com/noisesmith/8752dba8efde182852e4
01:05justin_smithit was definitely a close call
01:06princesojustin_smith thats good. thx mate
01:07mindbender1justin_smith: Yes. Very interesting results. I was using the basic time fn to evaluate.
01:08justin_smithmindbender1: the readme of the criterium github page explains the gotchas with using time to do micro-benchmarks
01:08justin_smithtl;dr the jvm is tricky and does weird things to make the code that runs the most faster
01:08justin_smithso if your code's speed really matters, you have to measure what happens when that optimization is applies
01:08justin_smith*applied
01:11mindbender1Right. Thanks for bringing my attention to criterium. I guess it's a must use for things like this.
01:12justin_smithmindbender1: also, something like visualvm or yourkit in order to know which code will actually make a difference if you speed it up
01:12justin_smithwith a real app, often the bottlenecks are not where you expect
01:13mindbender1Ho do you use either of those with clojure?
01:14mindbender1*How do
01:14mindbender1Is there some kind of clojure wrapper?
01:14justin_smithmindbender1: 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
01:15mindbender1Oh cool!
01:15justin_smithvisualvm is free, and comes with the jdk
01:16justin_smithmindbender1: 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!
01:16justin_smith(persistentFoo data structures, conj, cons, IFn.apply / IFn.eval*)
01:16justin_smithwhich means extra digging compared to what you might need for a java program
01:17mindbender1Lol. What tricks have you come uup with for handling those?
01:17justin_smithmindbender1: making a defrecord to use instead of a map
01:17mindbender1Ha
01:17mindbender1Won't that be too much work?
01:17justin_smithnot because I am implementing an interface - but because that way I can track memory usage / method usage on that defrecord
01:18justin_smithit's not much work at all
01:18justin_smith(defrecord MyWhatever [])
01:18justin_smithand then use (->MyWhatever) instead of {} or use into
01:19justin_smiththat makes it easier to track usage of one record type separate from all other hash map usage
01:19mindbender1defrecords for special cases or in all cases. Is there a yardstick you use to decide?
01:19justin_smiththis is specifically when I was trying to figure out who was generating all the data filling the heap
01:20justin_smithI had suspicions based on stack traces and other perf stuff, and made records for the things I suspected
01:20mindbender1Okay just plain defrecords with any special protocols?
01:21mindbender1*without
01:21justin_smithright - just defrecord tso I can isolate what's using the heap
01:21mindbender1Okay
01:21justin_smithfor methods / CPU the stack traces and thread traces are more usable
01:21justin_smith(though deep, because this is clojure after all :P)
01:22mindbender1That shouldn't be much work then. Especially when valuable info is at stake!
05:27taspathi, i cannot execute "lein repl" neither in windows nor in linux, I get this error: https://gist.github.com/anonymous/9be771673ec7d6af93b0
05:28ridcully_linode (and therefor clojars) has ongoing ddos attacks
05:29ridcully_rsync your ~/.m2 over from a machine, that got it loaded at some point in time
05:30taspatI never had loaded
05:30taspatanyway, thanks ridcully_
05:46l1xhi guys
05:46l1xis there a tool that recompiles my code when I change something in the file?
05:46l1x(for clojure)
05:48lokienyou mean compiling while working on the code?
06:13hellofunkis clojars.org having some issues?
06:14lokienit's down for me too
06:14hellofunkthe 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
06:14beakyme too
06:15beakymaybe they ar ehosted on linode :D
06:15ridcully_they _are_ hosted on linode
06:15hellofunkyes they are, just checked
06:15hellofunki wonder why all the hate against linode by the attackers?
06:16ridcully_blackmail most likely
06:16lokien"99.9% uptime guaranteed" :^)
06:17PetazzHi 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.
06:17hellofunkjust shows that even something as simple as ddos can swamp good companies without easy resolution
06:17PetazzHow can I grant access to PG for my clojure connection?
06:17hellofunkPetazz: are you running locally or on heroku?
06:17hellofunkif on heroku, you need to use the postgres password they assign to you
06:18hellofunkPetazz: 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
06:19Petazzhellofunk: locally
06:19PetazzTrying to just get started with a real application :)
06:19hellofunkPetazz: 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
06:20PetazzI tried fiddling with the pg_hba.conf file..
06:20hellofunkPetazz: should not be necessary
06:23taspatis there some way to be able to run "lein repl" without connecting to clojars (some offline setup)?
06:24Petazzhellofunk: Hmm I'm quite lost with postgres. How do I add a user?
06:24PetazzThe heroku instructions seem weird, they just init a db and it should work?
06:25hellofunkPetazz: 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
06:26hellofunkPetazz: 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
06:26ridcully_either use `createuser` on commandline or `create user` in psql
09:32taspatthat is weird, being a newbie and wanting to play with clojure is imposible while clojars webserver is dead
09:33lokientaspat: implement space invaders then
09:33lokienwith core only
09:34taspat:D
09:34lokien:^)
09:39lokiendoes someone use typed clojure here?
09:43lokienor schema?
10:26codefingerPetazz: 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:40favetelinguisclojars is down?
10:45jonhfavetelinguis: i think (i could be wrong) but where they are hosted linode is currently being dos'd so it's effecting clojars
10:45suspicious_eseems so, https://twitter.com/clojars/status/683010552608722944
10:51favetelinguiswow that tweet is 20h old?
10:52favetelinguismust be some serious dos..
10:58jonhfavetelinguis: looks like it
11:12l1xhuh
11:13l1xlinode needs bigger pipes :)
11:13l1xthey should try AWS, so i heard
11:20favetelinguishow can i make a (Thread/sleep ..) in cljs?
11:21justin_smithfavetelinguis: perhaps js/setTimeout
11:21justin_smiththere are no threads, so sleeping everything is not usually the right thing
11:23favetelinguisjustin_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:24justin_smiththe annoying thing about setTimeout is that it needs a function as an arg and that function is what gets called after the timeout
11:24justin_smithbut it can totally be used in eg. a wait-loop
11:40tcrawleyanyone want to help me test a clojars mirror?
11:40tcrawleyI have one set up, based on an rsync from last night
11:40tcrawleythis is an "official" mirror, since I'm the maintainer of clojars
11:40justin_smithtcrawley: sure, I'll try it out
11:41tcrawleyjustin_smith: https://clojars-mirror.tcrawley.org/repo/
11:41justin_smithtcrawley: 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:41tcrawleyyeah, that would do it
11:42tcrawleyyou'll need: :mirrors {#"clojars" {:name "clojars mirror"
11:42tcrawley :url "https://clojars-mirror.tcrawley.org/repo"}}
11:42engblomCould 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:43tcrawleyyou can add that to ~/.lein/profiles.clj under the :user profile
11:43engblomAlso general suggestions on how to improve it are welcome
11:45justin_smithtcrawley: 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:46tcrawleyhmm, what version of java are you using?
11:46justin_smithJava(TM) SE Runtime Environment (build 1.8.0_05-b13)
11:46tcrawleyI'm using a letsencrypt cert, which may not work with some javas?
11:46justin_smithyeah, my java definitely does not like it
11:47tcrawleyit works for me with OpenJDK Runtime Environment (build 1.8.0_65-b17), but I can't require everyone to update java
11:53tcrawleyanyone have recommendations of where to buy ssl certs that will work with java 6+?
11:55p_lhmm, letsencrypt should work with Java, it's not like they are using ECDHE
11:55justin_smithp_l: any insight on that error?
11:59p_ldoes "openssl s_client -verify_host -connect clojars-mirror.tcrawley.org:433 " report any problems?
12:01justin_smithp_l: getting errors about the command line syntax
12:02p_lchange -verify_host to -showcerts
12:02p_lthat said, I get connection refused
12:02tcrawleyp_l: try port 443
12:03p_l... right
12:03p_lnot enough sleep
12:03justin_smithat the end I get Verify return code: 20 (unable to get local issuer certificate)
12:04justin_smith(after fiddling the command line a bunch)
12:04tcrawleyI get Verify return code: 0
12:04p_ljustin_smith: sounds like you have outdated ca-certificates?
12:04tcrawleyhttps://gist.github.com/bda9ce355887cbb1b88a
12:05justin_smithhttps://gist.github.com/noisesmith/bbe5f0d2c33ab187cafa
12:06p_lyou have outdated ca certs
12:06justin_smithp_l: cool, updating now (it's been way too long since I ran aptitude it seems)
12:09tcrawleycool, let me know if it works for you after
12:32justin_smithtcrawley: 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:33justin_smithit might just be me though, someone else should try using the mirror for sure
12:33tcrawleyhmm, I've had a few other folks try it with success
12:33tcrawleydoes openssl still complain?
12:33justin_smithyeah, same result
12:33tcrawleywhat version of debian/ubuntu are you on?
12:35justin_smithOK, just explicitly ran "update-ca-certificates" - same error
12:35justin_smithtrusty
12:35justin_smithwhich is probably pathetically old now
12:36tcrawleyyah, it may not get cert updates anymore
12:37justin_smithin 2014 they said trusty would be supported for 5 years
12:38tcrawleyhmm
12:39justin_smithoh, now I get an OK
12:39justin_smith(for the openssl check)
12:41favetelinguiswhat is the idomatic way of handling state in long running go-loop blocks? my guess is to use a var here?
12:42justin_smithfavetelinguis: the idiomatic thing is to make it a loop binding
12:43justin_smithno, definitely not idiomatic at all to modify a var inside a go loop
12:46favetelinguisjustin_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:47justin_smithright, make the map one of the loop args
12:47favetelinguisnice thanks (as always :))
12:57jonathanjam i being stupid here? https://pb.codehash.net/39e9bd94fd424c96853e7b9041e43b86
12:57jonathanjhttps://github.com/haraldk/TwelveMonkeys/blob/twelvemonkeys-3.2.1/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/jpeg/JPEGQuality.java#L85
12:57jonathanjthat's the source for the version i'm using from maven
12:59jonathanjtrying to invoke it seems to fail too:
12:59jonathanj=> (JPEGQuality/getJPEGQuality (-> "/Users/jonathan/Downloads/6703c8e9-89aa-481c-a07a-1ec0365fc91b.jpeg" clojure.java.io/file clojure.java.io/input-stream))
12:59jonathanjIllegalArgumentException No matching method found: getJPEGQuality clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)
13:00justin_smithjonathanj: it wants a List of JPEGSegment
13:00justin_smithoh never mind
13:00justin_smithwrong version
13:08jonathanjis there any way i can inspect the class/function from a repl?
13:09justin_smithjonathanj: clojure.reflect
13:10jonathanjokay, so this method is present
13:10jonathanjand it's public
13:10jonathanjoh hang on
13:10jonathanjand ImageInputStream isn't an InputStream
13:12jonathanjdoh
13:13jonathanjthat was a waste of 30 minutes staring at code
14:20danlentzSo, is clojars.org down?
14:21justin_smithdanlentz: looks down again, yeah, it's been down as much as up the past few days
14:22danlentzDammit I knew I should have contributed to that Kickstarter ;)
14:22justin_smithdanlentz: tcrawley shared a mirror he set up - it's not working for me (likely for config reasons) but is working for others
14:23justin_smith:url "https://clojars-mirror.tcrawley.org/repo"
14:25tcrawleyjustin_smith: I just replaced the ssl cert - can you try again?
14:25justin_smithsure thing
14:26tcrawleydanlentz: see https://github.com/clojars/clojars-web/wiki/Mirrors
14:26justin_smithtcrawley: this one works
14:26tcrawleyyay!
14:26justin_smiththanks man
14:26justin_smithtcrawley: also, you might have gotten false positives from others, because the :repositories key merges by default, but I use the ^:replace metadata
14:27justin_smithor would the key "clojars" have made it replace the other?
14:27danlentzMuch appreciated will give it a try
14:27tcrawleydid you set it up as a mirror, or just replace the :repositories key?
14:27tcrawley(see the wiki link above)
14:28momerathsorry if everyone is asking: is clojars down?
14:28justin_smithtcrawley: 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:28tcrawleygotcha
14:28justin_smithmomerath: tcrawley has a mirror you can use
14:28tcrawleymomerath: https://github.com/clojars/clojars-web/wiki/Mirrors
14:28momerathcool- thanks!
14:30justin_smithwow the dep list for this project is really, really, sadly huge
14:38lokienHey guys, what would you recommend to implement for exercise? 4Clojure problems are too short, I'm seeking something bigger.
14:39justin_smithlokien: project euler?
14:39justin_smithadvent of code?
14:40lokienjustin_smith: something standalone? not "someone has built a rpg, you have to write a combat system for it"
14:40justin_smithlokien: how are project euler problems not standalone?
14:41lokienjustin_smith: oh, I talked about advent of code. project euler gets me focused on maths, not on the language :(
14:45lokienI'll do advent of code then, thanks justin_smith
15:08amalloylokien: did you try the harder 4clojure problems? i wouldn't call those short
15:10amalloyeg http://www.4clojure.com/problem/140 or http://www.4clojure.com/problem/127
15:15lokienamalloy: no, I'll check it now
15:17lokienamalloy: damn, they're hard
15:17amalloywell i linked you to two of the hardest, since you wanted hard ones
15:17amalloythere's plenty in the middle too
15:18lokienyou overestimate me
15:18amalloylike http://www.4clojure.com/problem/96 is much easier
15:18amalloybut not so easy as the intro problems
15:18lokienanyway, how to change some sequence in a string to another sequence? like :s/foo/bar/g in vim
15:19justin_smith,(clojure.string/replace "hello, world!" "world" "shoes")
15:19clojurebot"hello, shoes!"
15:19amalloybut advent of code is also great, and i don't want to discourage you from doing those. i used them to practice haskell
15:20lokieneh, I was looking at clojure.core/replace. thanks, justin_smith
15:21lokienamalloy: haskell is too spooky for me now (just as ocaml)
15:21lokienthese problems make me anxious too, but I have to start doing *something*
15:41lokienadvent of code would be so easy with imperative approach, ugh.
15:46engblomI 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:46justin_smithengblom: for local usage you can run "lein install" and that will make it available in other projects
15:47justin_smithengblom: to share on the network, you could upload it to clojars or some other maven server
15:47engblomclojars.org seem to be down...
15:47justin_smithif you want to share publicly on clojars, "lein deploy clojars" should do that
15:47justin_smiththere is that
15:48lokiencan I have haskell's x:xs destructuring here (on a string)? or do I have to do (first string) etc?
15:48justin_smith,(let [[x & xs] "hello"] [x xs])
15:48clojurebot[\h (\e \l \l \o)]
15:48lokienoh.
15:49justin_smithunlike in haskell, a list of char is not a string
15:50lokien(apply str (flatten list-of-chars))?
15:50justin_smithyou don't need flatten
15:50lokienoh, right
16:06engblomDo I have a bad value in my DNS servers or is clojars.org really down?
16:06justin_smith~you don't need flatten
16:06clojurebotexcusez-moi
16:06justin_smithengblom: linode has been under attack, clojars has been down
16:06lokienit is, servers are being ddosed
16:06justin_smithengblom: one of the attacks has been against DNS, but that's not all
16:07engblomOk, thanks
16:15lokienjustin_smith: clojure says "Parameter declaration "loop" should be a vector" when I use your destructuring
16:16lokienand I'm pretty sure it's a vector (but I'm sure in a minute you'll prove it actually isn't)
16:17justin_smithlokien: can you show me the code?
16:17justin_smith,(fn loop)
16:17clojurebot#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:17justin_smith,(let loop)
16:17clojurebot#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:17justin_smithhmm
16:17lokienminute
16:18justin_smith,(fn (loop)) ; lokien this is how you get that error
16:18clojurebot#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:18lokieneh, I forgot an argument list to my function, I only made it for loop
16:26lokienjustin_smith: it still doesn't work (returns nil every time). do you mind if I send you my code? ~12 lines
16:26justin_smithsure, or you could paste it somewhere
16:27justin_smithnot on this channel though
16:27lokienI pasted it on lpaste, can I send a link here?
16:27justin_smithsure
16:27lokienhttp://lpaste.net/3871394851014574080
16:30sampwinganyone 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:31justin_smithlokien: one potential issue - you won't ever reach -1
16:31rhg135That's not too bad
16:32justin_smith,(- 1 10)
16:32clojurebot-9
16:32lokienwhy won't I?
16:32justin_smithlokien: look at the code above
16:32justin_smiththat's what you do if x is equal to )
16:33lokienoh
16:33lokienprefix notation rocks /s
16:33justin_smithI mean you might hit -1 by accident, but for most inputs you won't ever
16:33justin_smithlokien: for this we have inc / dec
16:33justin_smithbut also prefix is great, it just takes a minute to learn
16:34justin_smith,(< 0 1 2 3 10) ; just try doing this with infix as nicely
16:34clojurebottrue
16:34lokienyeah, you're right
16:34lokienbut it still returns nil immediately
16:36lokienit should return the last expression.. how would counter be nil?
16:36justin_smith,(cond nil :wat false :WAT)
16:36clojurebotnil
16:36justin_smithit is returning the last expression
16:37justin_smithyou hit the end of the string, x is nil, none of your clauses match
16:37justin_smithlokien: the code works if you replace the + 1 with inc and the - 1 with dec
16:37lokienso, he didn't reach the basement?
16:37justin_smithlokien: your code is broken
16:37lokienhttp://lpaste.net/3871394851014574080
16:38justin_smithnil would mean never hitting -1, yes
16:38lokienjustin_smith: I've noticed
16:38justin_smithbut that should work if it did hit the basement
16:38bibacHi, 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:39lokienjustin_smith: it works with a short string, I'll check what's wrong with this long dude
16:39justin_smithlokien: perhaps it has characters in it that are not ( or )
16:39justin_smithbecause that code will just return nil if it hits one
16:40justin_smithlokien: perhaps you want to add a "char other than ( or )" clause to the cond?
16:40lokienjustin_smith: yeah, 'cause I have no :else
16:40lokienno, it's this file
16:40lokienhttp://adventofcode.com/day/1/input
16:40justin_smithlokien: right, it defaults to nil if an input is not matched - implicit :else nil
16:40justin_smith"Puzzle inputs differ by user. Please log in to get your puzzle input."
16:41lokienoh, sorry
16:41lokienit's all like "()(((()()()()()" and only that
16:41lokienno other characters
16:41justin_smiththan sure, that should return nil, because it would never hit -1
16:41MJB47the first one
16:42MJB47is pretty easy to solve
16:42MJB47with 0 code
16:42MJB47unless you are doing it to learn clojure better
16:42lokienMJB47: you mean?
16:42MJB47you can ctrl-f and see the count of 1 char
16:42MJB47and then get the other
16:42MJB47and then minus them
16:43lokienI've replaced ( to "open" and ) to "closed", parens had broken my regexp
16:43lokienanyway, that's the problem, my file is like "openclosedopenopen"
16:47leftylinksilly question - newline at the end of that file?
16:47leftylinkthat would be a non ( ) char
16:47leftylinkoh but eh you'd probably hit the basement before oyu get to the end, so maybe it doesn't matter
16:47justin_smithleftylink: lokien: wouldn't change the result - the floor never goes to -1, so it will return nil
16:47justin_smithright
16:48lokienumm, let's see
16:48lokienyeah, nil leftylink
16:48amalloyiirc the input files don't have newlines
16:49amalloybut your text editor might add one, if you save it locally
16:49lokien")(((((()))(()(\n"
16:49lokienmaybe, I saved it with vim
16:49amalloyright. i saved mine with emacs, and it added a newline, but that was fine with me, i love newlines
16:50lokienunless it breaks your app on windows
16:51lokien( \n vs \r vs \r\n, thank you hickey for (newline))
16:58itissidclojars is down?
16:58justin_smithmostly, yeah
16:58justin_smithitissid: there's a mirror
16:59justin_smithitissid: https://github.com/clojars/clojars-web/wiki/Mirrors
17:00itissidThansk justin_smith, setting it up now..
17:08felixndo I have to add the mirror to my project file as well?
17:09felixnhttps://gist.github.com/munro/7c8915bff75b1d9271a3 <-- I followed the instructions, but it didn't set up correctly
17:14pilnewaitasecond... i can have macros, monads, actors, and futures in clojure?!??!!!??!?!!
17:15felixnpilne: and logic programming!
17:16pilneit really is a secret weapon in a coding arsenel
17:17felixnoh, and it's the only language that stands on it's own, and compiles to javascript extremely well. (ignore haxe XD)
17:18pilneplayed with haxe... felt very... hacked together and a bit of dependency hell-ish
17:19pilnewell, 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:20pilneand pixie seems to be getting some development again after a bit of a hiatus
17:20felixnjvm is super slow to start up, but the key is just never restart the vm, you can reload modules to rerun tests
17:21pilneyeah, 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:21justin_smithitissid: oh, is this the initial bootstrap of the lein install?
17:21justin_smithitissid: if so, it might be using clojars hard coded :(
17:24felixnjustin_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:24tcrawleyfelixn: it looks like lein *may* not honor mirrors when resolving plugins. I'm trying to debug that now
17:24felixntcrawley: ah thanks a lot
17:24justin_smithfelixn: I was able to use that mirror as a regular repo
17:25justin_smithfelixn: and it downloaded plugins with no trouble
17:26itissidjustin_smith: It was when I ran it. Setting up `~/.lein/profiles.clj` with the mirror fixed the run command.
17:26felixnjustin_smith: hmm, what's the exact code you used in your project file? :repositories {"...." "https://clojars-mirror.tcrawley.org/repo/&quot;}
17:27justin_smithfelixn: https://gist.github.com/noisesmith/bb2804c8c3624ca9aaa4
17:27justin_smithfelixn: it needs all of the entries, because the ^:replace key overwrites the normal locations, rather than merging
17:30felixnjustin_smith: ah nice that works. should that be put in the channel topic?
17:30justin_smithfelixn: well, it isn't supposed to be the official way to do this...
18:09m4ckWhy is the use function apparently frowned upon for use in production code?
18:10justin_smithit makes refactoring harder than it needs to be
18:11m4ckjustin_smith: oh, how so?
18:12justin_smithif 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:12justin_smithis it safe to remove those namespaces from the use of the other ns?
18:13justin_smithit's easy to answer these questions if you don't use use, it's not if you do
18:13clojurebotNo entiendo
18:15m4ckI'm struggling to see how using require & refer alleviates issues surrounding that
18:15justin_smithm4ck: easy - don't use refer
18:15justin_smithrequire with refer is just like use with only
18:15amalloyrequire :refer solves this just fine too
18:15amalloywhat you shouldn't do is (require ...) (refer ...), but (require ... :refer ...) works
18:16amalloybecause it explicitly lists all the things you're using
18:16clojurebotIt's greek to me.
18:16amalloywhenever 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:17m4ckamalloy & justin_smith: right, is the reason it's easier simply because you're explicitly listing the symbols being used?
18:17amalloyyes
18:18amalloyor use require :as, and then prefix each with the ns it came from
18:18m4ckGotcha, that makes complete sense then. Seems to be the same advice as "don't do import x.y.z.*; in Java"
18:18justin_smithexactly
18:18justin_smithm4ck: notice that kind of import is impossible in clojure too
18:19m4ckjustin_smith: isn't that exactly what use is doing though?
18:20m4ckTaking a wildcard underneath a known namespace, and making them all accessible indiscriminately in the current one
18:22justin_smithm4ck: right. When I said import, I meant import. Like the thing that does what java import does, but doesn't accept wildcards.
18:22justin_smith,(doc import)
18:22clojurebot"([& 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:22justin_smithm4ck: namespaces are not packages and vars are not classes, we have both kinds of thing
18:23m4ckAh, I think I'm with you now
18:23m4ckThanks
18:34rhg135a thing I've started to do is to only use symbols that are in the code file
18:34justin_smithrhg135: plus clojure.core I hope?
18:35rhg135of course
18:37rhg135usually those are obvious. like I see map/filter/reduce in my dreams they're so common
18:38taspathi, I'm getting this error when doing cider-jack-in from emacs: https://gist.github.com/anonymous/aae2f1f3049fdd538353
18:39taspatIm really confused about this nrepl cider thing
18:41justin_smithtaspat: it wants 0.11.0-SNAPSHOT and you have 0.10.0
18:42rhg135justin_smith: but it's saying he's running 0.8.x
18:42justin_smithyes, that is weird
18:42taspatif I edit my .lein/profiles.clj to 0.11.0, lein repl doesnt even complete (gets error from clojars)
18:42tolstoytaspat: Try putting those outside the :repl map.
18:42rhg135probably being overwritten but by what
18:43justin_smithtaspat: there is no such thing as 0.11.0 yet afaik
18:43justin_smithtaspat: 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:29pilnedo you have a ~/.lein/profiles.clj with the appropriate info in it?
21:29pilnewhat version cider are you using?
21:30pilneit is saying you don't have 0.11.0-SNAPSHOT installed
21:30pilnetry it with 0.8.2
21:31justin_smithpilne: the problem is that the version you have in clj has to match the version in elc
21:31justin_smithand it's not easy to switch out elc versions
21:40pilneahhhh, so emacs has some peculiarities
21:41justin_smithpilne: yeah, it doesn't have versioned deps like our clojure ecosystem
21:42pilnegranted, versions probably didn't change as regularly back when emacs was created
21:43justin_smithemacs predated many of our modern concepts of versioning
21:43justin_smithhell, emacs predates source control
21:43pilneyeah, i wonder when there will be a "neomacs" like someone made "neovim"
21:43justin_smithpilne: there have been many, none caught on
21:43pilnehrm... clojure might be the language to do it in too....
21:44pilnejust for historical prescidence
21:45justin_smithemacs has been redone in haskell, ocaml, common lisp, scheme (they are still talking about doing scheme again), likely others I am forgetting
21:45pilneand yet the only one that survives is the grand old elisp version >.<
21:46justin_smithand there were various redos of the elisp (or even attempts to do everything without elisp), that have also all faded away by now
21:46justin_smithin fact gosmacs was one of the reasons for the first GPL
21:47justin_smithstallman 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:49tolstoyDo you think the lispiness of elisp is what makes Emacs so much more, I don't know, fun, than say, Atom or Sublime?
21:53tolstoyI'm not sure what the difference is. Emacs is mostly written in its extension langage, but not Atom?
21:53tolstoyPlugins vs interpreter?
21:53justin_smithhmm... you can use the browser without atom, you can't use the C core of emacs without elisp
21:53justin_smithit would literally be useless
21:54justin_smithbut 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:55tolstoyMaybe firefox especially, with the Xul stuff?
21:55justin_smithtolstoy: 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:55sdegutisjustin_smith: I finally have reason to learn what tries are!
21:56kenrestivodoes anyone use xul anymore?
21:56justin_smithsdegutis: interesting, what's the use case?
21:56sdegutisjustin_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&quot; whatever the hell that means
21:56tolstoykenrestivo: No idea. I've not paid attention to Firefox in a long times, but wasn't it used to implement most of Firefox?
21:57sdegutiskenrestivo: that weird emacs-like browser does afiak
21:58tolstoyI used to use TextMate which had a plugin architecture, but it was too high a barrier of entry for me.
21:58justin_smithsdegutis: immutable things in c - I hope you plan on using a garbage collector because otherwise that sounds very painful
21:58tolstoyEmacs, 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:00sdegutisjustin_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:00tolstoyAnyway, I'm kind curious if Emacs' lack of a "plugin" system (outside of convention) is actually a really good thing.
22:01sdegutisjustin_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:11pilnei'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:17pilneand light table is quite interesting, a bit... quirky and rough, but interesting nonetheless
22:46retrogradeorbithey people. I was doing some work and clojars went offline
22:46retrogradeorbitlein now just hangs
22:46retrogradeorbitI tried LEIN_OFFLINE=y
22:46justin_smithretrogradeorbit: there's info to use a mirror on the clojars repo
22:47justin_smithretrogradeorbit: lein new checks for updated templates...
22:47retrogradeorbitjustin_smith: cant get to clojars repo to read the mirror
22:47justin_smithretrogradeorbit: no, the github repo for clojars, one moment
22:48retrogradeorbithttps://github.com/clojars/clojars-web/blob/master/MIRRORS ?
22:48justin_smithretrogradeorbit: https://github.com/clojars/clojars-web/wiki/Mirrors
22:49justin_smithand 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:50retrogradeorbitis there anyway to make leiningen not go online?
22:50retrogradeorbittheres no need to do so in the situation Im in
22:50retrogradeorbitits all in the maven cache
22:50retrogradeorbityet it just hangs wanting to connect?
22:50retrogradeorbitI dont have a profile at all. So I have to google how to set one up
22:50justin_smithretrogradeorbit: lein thinks making a new repo means looking for the newest version of the template
22:50retrogradeorbitso I can add the mirror
22:51retrogradeorbitIm not making a new repo
22:51justin_smith*new project, sorry
22:51retrogradeorbitjust tring to build
22:51retrogradeorbitlein figwheel actually
22:51retrogradeorbit$ lein figwheel
22:51retrogradeorbitJan 03, 2016 11:45:01 AM org.apache.http.impl.execchain.RetryExec execute
22:51retrogradeorbitINFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://clojars.org:443: Network is unreachable
22:51retrogradeorbitrepeatedly says that over and over every 30 seconds
22:52justin_smithprobably checking for a snapshot somewhere in your dep tree
22:52justin_smithI think there's a flag to ask lein not to check for snapshots...
22:53justin_smithretrogradeorbit: you can add :snapshots false to a repo definition
22:54justin_smithretrogradeorbit: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L82
22:54justin_smithretrogradeorbit: 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:54justin_smiththe one I called a hack
22:57retrogradeorbitIt must be figwheel.
22:57retrogra1eorbitwait no cljsbuild isnt working wither
22:57retrogra1eorbitI added the mirror to profile. Still not working
22:58justin_smithretrogradeorbit: 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:58justin_smithyou can get the cljs jar from maven central, org.clojure
22:58retrogra1eorbitlein should work offline. Also the mirror should work.
22:59justin_smiththose things are both true
22:59retrogra1eorbitright now I cant build at all
22:59retrogra1eorbitcan anyone build atm?
22:59justin_smithretrogradeorbit: did you try my config example where you use ^:replace to make "clojars" point at the mirror?
22:59retrogra1eorbityeah I tried the mirror
22:59retrogra1eorbitin the user profile
22:59retrogra1eorbitset to the one public mirror
23:00justin_smithretrogradeorbit: yes, in my project using that mirror I am building an uberjar right now
23:00justin_smithwhich includes a clojurescript build
23:00retrogra1eorbithow do I know the profile is working?
23:00retrogra1eorbitor even loading?
23:01retrogra1eorbitleiningen is often frustratingly silent with errors
23:01justin_smithit's true
23:01justin_smithit has a verbose flag, right?
23:01retrogra1eorbitdoes it?
23:02retrogra1eorbitnope doesnt look like it
23:02justin_smithif you set the DEBUG env var it will be more verbose
23:02rhg135Lein-pprint can help
23:02justin_smithretrogra1eorbit: there is also LEIN_OFFLINE because :offline? does not work for plugins
23:03justin_smithmaybe that would help too
23:05retrogra1eorbithttps://www.refheap.com/113310
23:06retrogra1eorbitanything wrong with my profile?
23:06retrogra1eorbitam I invoking it right?
23:06rhg135That's looking like figwheel itself is calling clojars
23:07justin_smiththat looks right - in my project, with the :repositories ^:replace trick, figwheel starts up
23:07justin_smithlet me change that setting and see if it fails like it does for you
23:08justin_smithretrogra1eorbit: funny, even when I change to look for the old clojars address instead, figwheel still starts up like normal for me
23:09justin_smithretrogra1eorbit: what if you provide the LEIN_OFFLINE env var too?
23:16retrogradeorbithttps://www.refheap.com/113311
23:17retrogradeorbitjustin_smith: whats your figwheel version?
23:17justin_smithweird, I guess that's a bug on figwheel if it doesn't respect the LEIN_OFFLINE flag
23:18justin_smith0.3.7 - probably not up to date
23:18retrogradeorbitright yeah. old
23:18retrogradeorbitI'll investigate the figwheel code
23:24retrogradeorbitsomeone else is having my problem
23:24retrogradeorbithttp://stackoverflow.com/questions/34573135/using-a-mirror-of-clojars-from-leiningen
23:24retrogradeorbitthats not me
23:24retrogradeorbitasked 34 minutes ago
23:24justin_smithyeah, with this unprecedented clojars downtime, a few features of various lein related projects are being tested for the first time
23:25retrogradeorbitits a good smoketest
23:27pilnethis figwheel looks interesting
23:28justin_smithit's pretty cool, when it works
23:28retrogradeorbityeah its amazing... when it runs
23:28retrogradeorbit:P
23:29pilnelol
23:30retrogradeorbitopenned ticket for posterity
23:30retrogradeorbithttps://github.com/bhauman/lein-figwheel/issues/316
23:54retrogradeorbitclojars back online.
23:58rhg135Yay