2014-05-02
| 00:40 | fowlslegs | Anyone know a good way to convert 64 bit binary strings into Ints? |
| 00:45 | Jaood | ,(assoc nil 1 2) |
| 00:45 | clojurebot | {1 2} |
| 02:11 | storme | ,(+ 1 2) |
| 02:11 | clojurebot | 3 |
| 02:11 | storme | ,'(+ 1 2) |
| 02:11 | clojurebot | (+ 1 2) |
| 02:11 | storme | ,(- 4 (+ 1 2)) |
| 02:11 | clojurebot | 1 |
| 02:11 | storme | ,'(- 4 (+ 1 2)) |
| 02:11 | clojurebot | (- 4 (+ 1 2)) |
| 02:11 | storme | ,(- 4 '(+ 1 2)) |
| 02:11 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number> |
| 03:12 | TravisD | is there any attempt to get clojure operating with the ipython notebook? I just installed the new version and it is gorgeous |
| 05:28 | m1dnight | guys, is the order of evaluation of a let sequential, or undefined? |
| 05:28 | pyrtsa | Sequential. |
| 05:28 | ssideris | m1dnight: sequential |
| 05:28 | m1dnight | great :) thanks guys |
| 05:28 | m1dnight | the docs are not really clear on it |
| 05:29 | ssideris | m1dnight: also, previous bindings are available to later bindings |
| 05:29 | ssideris | ,(let [a 5, b (* 2 a)] b) |
| 05:29 | clojurebot | 10 |
| 05:30 | ebaxt | ,(let [a 5, b (* 2 a), a 2] a) |
| 05:30 | clojurebot | 2 |
| 05:30 | ssideris | and sometimes people do this but I have mixed feelings about it: |
| 05:31 | ssideris | ,(let [a 5, a (* 2 a), a (* 2 a)] a) |
| 05:31 | clojurebot | 20 |
| 05:32 | m1dnight | ssideris: yeah, that's what I figured as well |
| 05:32 | m1dnight | but with the laziness there could be some voodoo going on or so :p |
| 05:32 | m1dnight | so I just wanted to make sure |
| 05:32 | m1dnight | I have something like (let [before (System/nanoTime) <do some heavy work> after (System/nanoTime)] <code>) |
| 05:33 | m1dnight | I checked out the criterium library yesterday. Too bad that when a function takes too long to run it only runs it once. |
| 05:33 | m1dnight | great library otherwise |
| 05:33 | m1dnight | perhaps I can fiddle a bit with the source code |
| 05:41 | Glenjamin | hi guys, i'm getting what looks to be a reflection warning from leiningen: call to static method invokeStaticMethod on clojure.lang.Reflector can't be resolved |
| 05:41 | Glenjamin | which appears to be from: (clojure.lang.Reflector/invokeStaticMethod class__9795__auto__ "main" |
| 05:41 | ssideris | do you get that from: lein run |
| 05:42 | Glenjamin | yes |
| 05:42 | Glenjamin | is that a problem i should raise an issue for, or is it expected? |
| 05:43 | ssideris | do you have a class that is configured in project.clj, is compiled ahead of time, and has a main method/ |
| 05:43 | ssideris | ? |
| 05:44 | Glenjamin | class as in gen-class ? |
| 05:44 | Glenjamin | i've just got the -main that was generated from lein new project |
| 05:44 | ssideris | see gen-class here: http://clojure.org/compilation |
| 05:44 | ssideris | oh |
| 05:45 | ssideris | hm, yeah that should have worked |
| 05:46 | Glenjamin | could it be related to ":main ^:skip-aot myproject.main" |
| 05:46 | Glenjamin | in the project.clj |
| 05:46 | ssideris | very likely |
| 05:46 | ssideris | the namespace containing the -main class should be AOT'ed |
| 05:47 | ssideris | (AOT = ahead of time) |
| 05:47 | Glenjamin | yeah, i hadn't changed anything from the generated template, so i was just confused as to whether or not its a real error or even a problem |
| 05:48 | ssideris | so removing ^:skip-aot fixed it? |
| 05:49 | Glenjamin | hrm, nope |
| 05:50 | Glenjamin | ah, i think this maybe be a minor lein bug |
| 05:50 | Glenjamin | https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java#L198 |
| 05:51 | Glenjamin | looking at the generated bootstrap code, i think something should have ^Class typehint on it |
| 05:52 | Glenjamin | i'll write it up on github and see what people think |
| 05:57 | ssideris | good idea |
| 05:58 | ssideris | so is there a workaround? |
| 06:00 | TEttinger | is it called main or -main in your code, Glenjamin? |
| 06:02 | ssideris | TEttinger: Glenjamin mentioned that he's just using the code generated by lein new |
| 06:02 | TEttinger | oh! |
| 06:08 | ssideris | Glenjamin: I just tried with Leiningen 2.3.4 and it works fine for me |
| 06:08 | ssideris | could you paste your project.clj in a pastebin please? |
| 06:11 | ticking | I was wondering if theres a a special form to limit lexical/reset scope. |
| 06:22 | turbopape | so keyword can contain space ? |
| 06:23 | rukor | hi does anyone know if any tools currently exist for automatically generating API documentation from liberator resources |
| 06:24 | rukor | or from compojure route specifcations |
| 06:24 | ssideris | turbopape: yes ,(keyword "this is valid") |
| 06:25 | ssideris | ,(keyword "this is valid") |
| 06:25 | clojurebot | :this is valid |
| 06:25 | andrewchambers | its valid in code, but the reader cant do it? |
| 06:25 | turbopape | ok, cool ssideris, I just wanted to know if it was not undefined behaviour.... |
| 06:26 | turbopape | andrewchambers, I think you must go with a (keyword ....) call |
| 06:32 | Glenjamin | TEttinger / ssideris - reduced to testcase https://github.com/glenjamin/lein-new-reflection |
| 06:32 | Bronsa | turbopape: ssideris andrewchambers keywords can't contain spaces. |
| 06:33 | Bronsa | the `keyword` function doesn't do any validation on its input, it's garbage-in garbage-out |
| 06:34 | turbopape | ok BRonsa, is it invalid or merely not verfied and random ? |
| 06:34 | andrewchambers | ((keyword ":foo bar") {(keyword ":foo bar") 1337 }) |
| 06:34 | andrewchambers | that works fine |
| 06:35 | andrewchambers | whoops ignore the colon |
| 06:35 | andrewchambers | ,((keyword "foo bar") {(keyword "foo bar") 1337 }) |
| 06:35 | clojurebot | 1337 |
| 06:36 | Glenjamin | ,(type (keyword "a space")) |
| 06:36 | clojurebot | clojure.lang.Keyword |
| 06:36 | andrewchambers | works fine |
| 06:36 | Bronsa | andrewchambers: I didn't say that it doesn't work, but you should consider it undefined behaviour |
| 06:36 | ssideris | lengthy discussion on the topic of spaces in keywords here: https://groups.google.com/forum/#!topic/clojure/WvXYkvLoQhI/discussion |
| 06:36 | Bronsa | the fact that it works is just because the implementation doesn't do any validation on its input for performance reasons |
| 06:37 | turbopape | ok Bronsa, well explained ! |
| 06:37 | ssideris | ,(pr-str (keyword "will this print")) |
| 06:37 | clojurebot | ":will this print" |
| 06:37 | ssideris | this is broken for example ^ |
| 06:38 | ssideris | ,(read-string (pr-str (keyword "will this print"))) |
| 06:38 | clojurebot | :will |
| 06:39 | andrewchambers | I dunno, i think it has legitimate uses |
| 06:39 | andrewchambers | since keywords and strings dont have the same performance characteristics |
| 06:40 | andrewchambers | just because the reader cant handle it doesnt mean its undefined |
| 06:40 | andrewchambers | if there is a standard that says that i would beleive it :P |
| 06:41 | andrewchambers | clojurebot is pretty cool |
| 06:45 | s0x | hey guys, im not sure if the following is a speclj or clojure namespace issue. Maybe im just to dumb to see the reason: I try to setup a projectusing speclj for testing and tools.cli for cl-parsing. If i require the clojure.toosl.cli namespace and try to use the function parse-opts somewhere in the source file speclj stops to work complaining about no such var parse-opts. When i call the source by hand, everything works fine :-/ Im acctually struggling with that for |
| 06:45 | s0x | I'd be very happy if anyone could give me a bit of support or a hand what the issue might be about |
| 06:49 | ssideris | s0x: can you paste the code somewhere? |
| 06:49 | ssideris | or at least the (ns) and the actual call to parse-opts |
| 06:50 | s0x | ssideris: sure ... give me a sec |
| 06:52 | s0x | http://pastebin.com/xLGMiY9e |
| 06:52 | s0x | both, the test and the tested file are in there |
| 06:53 | ssideris | clojure.tools.cli/parse-opts args cli-options is not even in parentheses, it should be: (clojure.tools.cli/parse-opts args cli-options) |
| 06:54 | s0x | oh you're right ... just a c&p mistake ... doesnt change anything though |
| 06:54 | s0x | java.lang.RuntimeException: No such var: clojure.tools.cli/parse-opts, compiling:(chnum/core.clj:26:3) |
| 06:54 | s0x | thats the error message i get |
| 06:55 | ssideris | weird |
| 06:55 | llasram | s0x: Which version of tools.cli do you have in your dependencies? |
| 06:55 | s0x | 0.3.1 |
| 06:56 | s0x | speclj 2.9.1, clojure 1.6.0 |
| 06:56 | llasram | Are you using Leiningen? If so, I'd do `lein deps :tree` to verify |
| 06:56 | ssideris | yeah, an earlier version could be pulled in by another dependency |
| 06:56 | llasram | Well, not usually |
| 06:57 | llasram | But best to verify :-) |
| 06:57 | s0x | llasram: yes using lein, there are just the version present, i've mentioned |
| 06:57 | ssideris | try changing the require to: (:require [clojure.tools.cli :refer [parse-opts]]) |
| 06:57 | llasram | Ok. I'm now going to guess that you have a stale AOT of a pre-0.3.0 version somewhere, either in your project or in a badly-packaged dependency |
| 06:57 | clojurebot | Cool story bro. |
| 06:58 | ssideris | yeah that too, try a lein clean |
| 06:59 | s0x | um ... since im strugling with this issue for months i've tried even creating new projects and on different machines with the same effect |
| 06:59 | llasram | Ok. I just re-ran your original question |
| 06:59 | llasram | Er |
| 06:59 | llasram | "went back and read" ha |
| 06:59 | llasram | How are you running your speclj tests? |
| 06:59 | s0x | lein clean does not change anything either |
| 06:59 | llasram | (which causes the error) |
| 06:59 | s0x | lein spec |
| 07:00 | llasram | version of the speclj plugin? |
| 07:00 | s0x | 2.9.1 |
| 07:00 | guns | sox: Others have reported that earlier versions of of tools.cli get pulled in by reply |
| 07:01 | s0x | well, lein deps :tree gives no evidence of older versions installed |
| 07:01 | guns | I haven't seen this myself, but the snapshot version of reply has at least upgraded to 0.3.1 |
| 07:01 | llasram | I think this was a problem specific with the speclj plugin |
| 07:01 | llasram | Just a sec... almost have it tracked down |
| 07:01 | clojurebot | It's greek to me. |
| 07:02 | llasram | Man, clojurebot is on a roll this morning |
| 07:03 | llasram | There we go! Ok, for not-very-good reasons, the `lein spec` task used to run specs *in the Leiningen process* |
| 07:03 | llasram | Looks like got fixed for the speclj plugin version 3.0.2 |
| 07:03 | llasram | s0x: If you're on 2.9.1, try adding `:speclj-eval-in :subprocess` to the top-level of your project map |
| 07:03 | llasram | (or upgrade your speclj plugin) |
| 07:06 | s0x | llasram: wow ... both ways the tests run successfully :D ... thank you so much |
| 07:06 | llasram | np! |
| 07:07 | s0x | well the last time i was working on that 3.0.2 was not available yet :) |
| 07:17 | andrewchambers | ,'() |
| 07:17 | clojurebot | () |
| 07:18 | sm0ke | so in a compojure route how do i get both requestmap and uri param |
| 07:18 | sm0ke | so for something like. (GET "/foo/:id" [id] (foo id]) |
| 07:18 | sm0ke | how do i pass req to foo with id |
| 07:27 | pyrtsa | sm0ke: (GET "/foo/:id" [id :as req] (foo req id)) is probably the best option, though there are other ways too. |
| 07:29 | sm0ke | hurm |
| 07:29 | sm0ke | pyrtsa: id :as req looks really misleading |
| 07:30 | sm0ke | does that even work? |
| 07:30 | sm0ke | ! |
| 07:30 | noidi | I think so too, that's why I always put :as first |
| 07:30 | sm0ke | what kind of destrucuring is that? |
| 07:30 | pyrtsa | sm0ke: It does. It's similar to (defn foo [a b c :as args] ...) |
| 07:30 | noidi | https://github.com/weavejester/compojure/wiki/Destructuring-Syntax |
| 07:30 | noidi | Compojure has its own desctructuring syntax for requests |
| 07:31 | pyrtsa | You could do something like this too: (GET "/foo/:id" {:as req {:keys [id]} :params} ...) |
| 07:31 | noidi | I think [:as req, id] might work as well |
| 07:32 | pyrtsa | Really? That'd read nicer. |
| 07:32 | noidi | at least that works with Clojure's require :) |
| 07:34 | pyrtsa | I think a bigger downside in Compojure is that you can't enumerate the routes at runtime (i.e. the routes aren't bidirectional). And when the list of routes starts to grow, there's nothing to check that you didn't already handle that route somewhere higher up already. |
| 07:34 | noidi | yeah, we've hit that bump as well |
| 07:35 | pyrtsa | I know there are other attempts to fixing that outside Compojure. |
| 07:35 | pyrtsa | https://github.com/juxt/bidi for example. |
| 07:35 | noidi | I can see why Prismatic chose to describe schemas as data instead of composition of validation functions |
| 07:39 | sm0ke | so i dont really understand this |
| 07:39 | sm0ke | if i say (GET "/foo" foo) foo gets called with request? |
| 07:40 | sm0ke | if i say (GET "/foo:id" [id] foo) ? |
| 07:40 | pyrtsa | noidi, sm0ke: Just tested that [:as req arg1 arg2 arg3] works too. |
| 07:40 | sm0ke | what happend then? |
| 07:41 | sm0ke | where arg1 arg2 arg3 are url patterns? |
| 07:42 | m1dnight | hey guys, I'm having a weird thing with agents. I've many threads (about 100) write to a file couple of 100 times each. (these params should be bigger normally). I wrapped the filepath in an agent and just send-off a function to the agent to update a file. |
| 07:42 | pyrtsa | sm0ke: I think Compojure went a bit over board with all the ways the handlers can be written. Mistakes you make often end up being valid code, possibly failing silently. IMO, it's best to always follow the structure (METHOD "<pattern>" [captures...] (a-function-call ...)) |
| 07:42 | m1dnight | when I use this, my program takes more than minutes to excute, while disabling sending to the agent it executes in a fraction of as econd. |
| 07:42 | m1dnight | any tips..? |
| 07:42 | pyrtsa | E.g. (GET "/foo/:foo-id/bar/:bar-id" [:as req foo-id bar-id] (foo/handle-foo-bar req foo-id bar-id)) |
| 07:42 | m1dnight | even when the sendoff doesn't do any writing, it still takes a huge amount of time. |
| 07:43 | sm0ke | pyrtsa: thanks |
| 07:43 | sm0ke | (inc pyrtsa) |
| 07:43 | lazybot | ⇒ 4 |
| 07:43 | noidi | sm0ke, the thing after the path is the name for the request parameter. In (GET "/foo" foo ...) the request parameter is made available under the name "foo" |
| 07:44 | pyrtsa | sm0ke: PROTIP, to test Compojure routes on the REPL, pass in a map with at least the :uri and :request-method fields, e.g. ((compojure.core/GET "/foo/:id" [:as req id] {:body (str "foo-" id)}) {:uri "/foo/123" :request-method :get}) |
| 07:44 | sm0ke | noidi: sorry but i think that was a typo |
| 07:44 | sm0ke | that is not valid iirc |
| 07:45 | sm0ke | (GET "foo" [] foo) is ok though |
| 07:45 | pyrtsa | noidi: (GET "/foo" foo ...) would bind the whole request object itself to the name `foo`. |
| 07:46 | noidi | sorry, that's what I was trying to say |
| 07:46 | sm0ke | ugh ugly stuff |
| 07:46 | noidi | the request is passed as a parameter to the handler :D |
| 07:46 | sm0ke | (GET "foo" [] foo) makes no sense to me |
| 07:49 | noidi | sm0ke, https://www.refheap.com/84861 |
| 07:49 | noidi | does that make any more sense? |
| 07:55 | sm0ke | ugh thanks noidi |
| 07:55 | sm0ke | still need to grok it i guess |
| 07:55 | sm0ke | bookmarked |
| 08:06 | noidi | sm0ke, if you're unfamiliar with destructuring, this might help http://blog.jayfields.com/2010/07/clojure-destructuring.html |
| 08:09 | phillord | I'm just reading Wiliiam Byrd's thesis on mini-kanran. In one place he defines "alwayso" and "nevero". When he uses "alwayso" he writes it like (run1(x) (== #t x) alwayso (==#f x)) while when he uses never, he writes (nevero) -- i.e. one looks like a function call, and one looks like a value. Am I confused over scheme syntax or is this right? |
| 08:18 | m1dnight | if anybody has a moment, could they help me out with my clojure question? : http://stackoverflow.com/questions/23427457/clojure-using-agents-slows-down-execution-too-much |
| 08:18 | m1dnight | I'm stumped as to what's going on.. |
| 08:20 | m1dnight | it just seems to be the case that code doesn't immediatly return |
| 08:20 | m1dnight | the method exits fine (well, it prints the last statement I've just added) |
| 08:21 | Anderkent | m1dnight: send-off spawns a new thread executor every time you call it |
| 08:21 | Anderkent | wait no i'm reading it wrong |
| 08:21 | ucb | agents use the global threadpool IIRC |
| 08:21 | Anderkent | pretty sure agents have their own threadpool |
| 08:21 | m1dnight | yeah, the file is written to. and each thread does it work properly and on time. when I'm done running the (barrier/run-with-barrier) I print "done", which gets printed instantly |
| 08:22 | ucb | how are you spawning new thread m1dnight? if using (future...) then your agent thread is probably competing with the producer threads |
| 08:22 | m1dnight | but then it keeps waiting a long time to finish.. |
| 08:22 | Anderkent | m1dnight: oh |
| 08:22 | m1dnight | threads (repeatedly number (fn [] (Thread. work)))] |
| 08:22 | m1dnight | like this |
| 08:22 | Anderkent | you need to call (shudtown-agents) |
| 08:22 | m1dnight | oh |
| 08:22 | Anderkent | when you're done sending stuff |
| 08:22 | m1dnight | I might try that |
| 08:22 | m1dnight | let me try, thanks man :) |
| 08:22 | ucb | that too |
| 08:22 | m1dnight | that did the trick!!! :) |
| 08:22 | m1dnight | thanks guys! |
| 08:23 | m1dnight | strange the programing clojure book didn't mention it |
| 08:23 | m1dnight | if anybody has a SO account i'll be glad to accept it as the anser |
| 08:25 | foodoo | 3 |
| 08:40 | Anderkent | ucb: go ahead |
| 08:41 | ucb | I don't think I have an SO account anyway :) |
| 09:19 | mi6x3m | clojure |
| 09:19 | mi6x3m | is set! the same as binding but without the explicit scope? |
| 09:20 | CookedGr1phon | does anybody know how I might go about configuring cljx for :cljs and :clj (:android or :jvm) using features? |
| 09:20 | CookedGr1phon | I can't seem to find any documentation, it's just mentioned in a couple of places |
| 09:20 | llasram | mi6x3m: `set!` is a special form which can do multiple things. Applied to a dynamic var w/ an existing thread-local binding, it will change the var's value in that current binding frame |
| 09:21 | mi6x3m | llasram: so it saves me another binding frame? |
| 09:21 | llasram | No |
| 09:21 | llasram | It mutates the value in the current binding frame |
| 09:22 | llasram | Well, or "yes" -- I'm not sure which sense of "save" you mean there |
| 09:22 | mi6x3m | ok, I see, so if I use it inside a loop recur for instance it will take effect for the things before set! also |
| 09:22 | mi6x3m | where another binding frame will not |
| 09:23 | llasram | What are you trying to do? |
| 09:26 | mi6x3m | llasram: nothing, just asking questions to get a clear picture :) |
| 09:27 | llasram | ok |
| 09:41 | _trev | Exception in thread "main" java.lang.ExceptionInInitializerError |
| 09:41 | _trev | at clojure.main.<clinit>(main.java:20) |
| 09:41 | _trev | Caused by: java.lang.NoClassDefFoundError: clojure/core/cache/CacheProtocol, compiling:(user.clj:1:1) |
| 09:41 | _trev | Morning everyone. I'm trying to uberjar my app on a ubuntu box, but I keep getting this error " |
| 09:41 | _trev | Any thoughts? |
| 09:41 | _trev | I'm using the cmd "lein ring uberjar" |
| 09:44 | clgv | _trev: sound like an AOT problem, possibly old class files lying around. try "lein clean" |
| 09:45 | _trev | Same deal clgv :( |
| 09:46 | clgv | does "lein repl" work? |
| 09:46 | _trev | no |
| 09:46 | _trev | I get that same error |
| 09:47 | clgv | what is the content of user.clj? |
| 09:47 | clgv | refheap.com please |
| 09:49 | _trev | https://www.refheap.com/84869 clgv |
| 09:49 | clgv | _trev: check "lein deps :tree" whether you accidently pull in 2 different versions of core.cache |
| 09:50 | _trev | only 1 core.cache |
| 09:50 | _trev | [org.clojure/core.cache "0.6.3"] |
| 09:52 | clgv | can you post the full stacktrace on reheap.com? |
| 09:52 | clgv | *refheap |
| 09:52 | _trev | yeah 1 sec |
| 09:54 | _trev | https://www.refheap.com/84871 clgv |
| 09:56 | clgv | _trev: hmm your problem seems to be somewhere in that namespace www.models.ghub |
| 09:56 | _trev | hmm. It works on my osx box though |
| 09:57 | _trev | my ubuntu server is unable to create the uberjar :( |
| 09:57 | _trev | clgv: |
| 09:59 | _trev | [clojure.core.cache :refer [->TTLCache ttl-cache-factory]] pretty standard |
| 10:11 | clgv | _trev: that project is not hosted on github or somewhere similar? |
| 10:12 | _trev | clojure.core.cache? |
| 10:20 | _trev | Thanks for the help clgv I'll have to work on fixing the problem later |
| 10:21 | clgv | no I meant yours ;) |
| 10:33 | AssCancer | hiya |
| 10:33 | SparkySparkyBoom | im trying to use this library |
| 10:33 | SparkySparkyBoom | https://github.com/cgrand/regex |
| 10:34 | SparkySparkyBoom | when i tried this command in the repl, it gave me a FileNotFoundException |
| 10:34 | SparkySparkyBoom | (require '[net.cgrand/regex :as regex]) |
| 10:35 | SparkySparkyBoom | i dont understand what's wrong |
| 10:35 | SparkySparkyBoom | this is the relevant file |
| 10:35 | SparkySparkyBoom | https://github.com/cgrand/regex/blob/master/src/net/cgrand/regex.clj |
| 10:35 | `szx | SparkySparkyBoom: do you have the library as a dependency in your project.clj? |
| 10:35 | SparkySparkyBoom | yes |
| 10:35 | SparkySparkyBoom | [net.cgrand/regex "1.1.0"] |
| 10:36 | whodidth1s | net.grand.regex :as regex |
| 10:37 | SparkySparkyBoom | AH |
| 10:37 | SparkySparkyBoom | i forgot the ' |
| 10:37 | SparkySparkyBoom | symbol literals |
| 10:37 | SparkySparkyBoom | XD |
| 10:37 | SparkySparkyBoom | sorry about that |
| 10:46 | SparkySparkyBoom | does anyone know of any more examples of that library |
| 10:46 | SparkySparkyBoom | other than the readme |
| 10:47 | eraserhd | What is the thinking about not having single-component namespaces? |
| 10:49 | cbp | You cant use them in java |
| 10:49 | llasram | eraserhd: Because of the way Clojure generates classes, it results in package-less classes, which can cause some issues from the Java side |
| 10:50 | llasram | In practice access from Clojure is completely fine |
| 10:51 | cbp | you get classes in the default package which cant be referenced from other packages in java |
| 11:18 | jcromartie | What are y'allses thoughts on RequireJS vs some sort of middleware to bundle up script includes into a minified package? |
| 11:19 | jcromartie | I could probably use the Closure compiler to do it from Clojure |
| 11:19 | bbloom | jcromartie: in the context of clojurescript? or generally? |
| 11:19 | jcromartie | just to make things confusing for everybody |
| 11:19 | jcromartie | in the context of a Clojure web app that serves up regular old JS for regular old webpages |
| 11:19 | jcromartie | sorry, nothing fancy |
| 11:19 | jcromartie | (why aren't we using cljs?) |
| 11:20 | bbloom | if you've got regular ol' web pages, don't get fancy with module loaders |
| 11:20 | bbloom | requirejs, browserify, etc are exceptionally complex |
| 11:20 | jcromartie | you think? |
| 11:20 | jcromartie | requirejs doesn't seem too complex to me |
| 11:21 | bbloom | browserify makes sense for larger codebases and for playing nice with node.js components |
| 11:21 | bbloom | requirejs makes sense for really rich apps that need asynchronous code loading and such |
| 11:21 | jcromartie | we just have a few bits of client side code |
| 11:21 | bbloom | but otherwise, simple concatenation gets the job done for your everyday static page w/ a little js on it |
| 11:21 | jcromartie | really not much at all |
| 11:22 | jcromartie | it could be in a single file really |
| 11:22 | bbloom | yeah, don't worry about "large" packages |
| 11:22 | jcromartie | but I like to be organized |
| 11:22 | bbloom | make files are your friend here |
| 11:22 | bbloom | all you want is a single rule like this: |
| 11:22 | bbloom | mysite.js: js/foo.js js/bar.js js/baz.js |
| 11:23 | bbloom | cat $* > $@ |
| 11:23 | bbloom | and you're done |
| 11:23 | bbloom | add a mysite.min.js: mysite.js rule as well to run your favorite compressor |
| 11:23 | bbloom | maybe add a mysite.min.js.gz rule too if you want to send pre-compressed files to your CDN |
| 11:24 | bbloom | don't get fancier than this unless you need to |
| 11:24 | jcromartie | and integrating that into lein? |
| 11:24 | bbloom | don't |
| 11:24 | jcromartie | that seems like a rather ugly way to go for development time, though |
| 11:24 | jcromartie | I would have to run make every time I update af ile |
| 11:25 | bbloom | nah, just create a ./dev.sh file and run that while you work |
| 11:25 | bbloom | you can put your sass/compass/less/whatever watch in there too |
| 11:25 | jcromartie | yeah |
| 11:25 | bbloom | you can have dev.sh run your lein server if you want |
| 11:26 | sm0ke | how do you send a pretty print json to browser? |
| 11:26 | sm0ke | i am using cheshire and {:pretty true} doesnt really work |
| 11:26 | sm0ke | neither does (with-out-str (pprint json)) |
| 11:27 | jcromartie | bbloom: that also adds another step to the final build process |
| 11:27 | bbloom | jcromartie: what's your final build process? |
| 11:27 | jcromartie | well it's already a rake script :) |
| 11:27 | jcromartie | that calls lein among other things |
| 11:27 | bbloom | jcromartie: ugh rake. |
| 11:27 | jcromartie | yeah |
| 11:27 | jcromartie | for our purposes it's a little overkill |
| 11:27 | bbloom | jcromartie: anyway, make can call rake and vice versa |
| 11:27 | bbloom | rake isn't overkill, it's bad. |
| 11:28 | llasram | bbloom: Why so? |
| 11:28 | bbloom | it's got some make-like features that most ppl don't know exists, then it does some stupid "task" level stuff |
| 11:28 | jcromartie | what make-like features that most people don't know exists? |
| 11:28 | bbloom | it's slow, impossible to debug, and encourages you to do stupid things |
| 11:28 | bbloom | jcromartie: http://rake.rubyforge.org/doc/rakefile_rdoc.html#label-Rules |
| 11:29 | jcromartie | damn |
| 11:29 | bbloom | for some weird reason, people want ONE COMMAND LINE TOOL TO RULE THEM ALL and insist on everything being `rake foo` or `lein bar` |
| 11:29 | jcromartie | yeah I have used file tasks before, but not rules |
| 11:29 | bbloom | meanwhile, a ./script directory is 100X more dev friendly |
| 11:29 | jcromartie | it certainly can be |
| 11:30 | jcromartie | ./script/deploy |
| 11:30 | jcromartie | ./script/dev |
| 11:30 | jcromartie | sure |
| 11:30 | bbloom | best feature: |
| 11:30 | bbloom | ls ./script |
| 11:30 | lazybot | etc home lib mnt proc sbin src srv |
| 11:30 | jcromartie | who doesn't love a shell script :) |
| 11:30 | bbloom | i'll take bash over rake any day of the week |
| 11:31 | bbloom | :-P |
| 11:31 | bbloom | and i know rake better than most people ever will :-P |
| 11:31 | llasram | The only reason I'd argue is because pretty much every damn time I think "this is tiny, so I'll just do it in bash" it grows beyond "tiny" and I experience regret |
| 11:31 | bbloom | llasram: so don't do it in bash, do it in python or ruby or whatever you like |
| 11:31 | jcromartie | well it doesn't have to be bash for every script |
| 11:31 | bbloom | #!/bin/whatever |
| 11:32 | jcromartie | yeah |
| 11:32 | jcromartie | #!/bin/lein |
| 11:32 | jcromartie | :P |
| 11:32 | jcromartie | don't |
| 11:32 | llasram | hah |
| 11:32 | jcromartie | not that that would even work |
| 11:32 | llasram | bbloom: Sure. I was just disagreeing with taking bash over rake :-p |
| 11:33 | jcromartie | I'm a little sick of typing "bundle exec" to do anything in my clojure app |
| 11:33 | jcromartie | someone else designed the deployment script |
| 11:33 | jcromartie | :| |
| 11:33 | bbloom | jcromartie: solution: |
| 11:33 | jcromartie | I'm taking it over though |
| 11:34 | jcromartie | I'm the primary one running this project now |
| 11:34 | bbloom | echo "#!/bin/bash\nbundle exec\nrake" > ./script/build |
| 11:34 | lazybot | "#!/bin/bash\nbundle exec\nrake" > ./script/build |
| 11:34 | bbloom | lazybot: your sh parser sucks :-P |
| 11:34 | jcromartie | :) |
| 11:58 | SparkySparkyBoom | i tried looking through the source of this library |
| 11:58 | SparkySparkyBoom | https://github.com/cgrand/regex |
| 11:58 | SparkySparkyBoom | but i couldnt figure out a way to match a word |
| 12:00 | SparkySparkyBoom | does anyone know how to use the lib? |
| 12:01 | gtrak | SparkySparkyBoom: did you try the built in stuff first? |
| 12:01 | SparkySparkyBoom | yes |
| 12:02 | SparkySparkyBoom | ive composed regexes with it |
| 12:02 | gtrak | ah, ok. just making sure :-) |
| 12:02 | cbp | What was the name of that routing library that used data instead of macros? |
| 12:02 | cbp | there's probably more than one |
| 12:02 | gtrak | pedestal, bidi.. |
| 12:03 | SparkySparkyBoom | it's weird because the exec function's args are all characters |
| 12:03 | gtrak | I think prismatic has one |
| 12:03 | SparkySparkyBoom | er character equivalents |
| 12:03 | gtrak | fnhouse |
| 12:03 | SparkySparkyBoom | *regexes and character literals |
| 12:04 | nullptr` | cbp: https://github.com/caribou/polaris explicitly defines itself as you describe |
| 12:04 | cbp | Ah yes that one |
| 12:04 | cbp | thanks! |
| 12:07 | eflynn | is it possible to integrate PHP with clojure |
| 12:08 | cbp | I mean you can marshal data between them. Maybe you can even do something nutty with that java bridge thing |
| 12:09 | eflynn | cbp: yeah but i’m clueless when it comes to java web tech |
| 12:09 | SparkySparkyBoom | figured it out |
| 12:09 | SparkySparkyBoom | :D |
| 12:10 | SparkySparkyBoom | i was right about the character thing |
| 12:10 | eflynn | chp: how would you marshal data between |
| 12:10 | cbp | with json or something of the sort |
| 12:25 | manutter | or possibly this: https://github.com/igorw/edn/blob/master/src/parser.php |
| 12:25 | manutter | (just had to google that, don't know if it's any good or not) |
| 12:30 | coventry | https://github.com/rodnaph/clj-php (not saying it's a good idea. :-) |
| 12:41 | justin_smith | wow |
| 12:43 | manutter | just ran across that one myself |
| 12:44 | manutter | I'd be more interested in writing a php interpreter in clojure |
| 12:44 | manutter | or a hack interpreter |
| 12:46 | expez | gfredericks: nice! |
| 12:49 | m1dnight | hmm, clojure just ignored my post and pre? :p |
| 12:49 | m1dnight | is there a setting I have to force? (im using lein) |
| 12:50 | justin_smith | m1dnight: what do they look like? |
| 12:50 | pyrtsa | m1dnight: Where did you use those? They aren't supported in all places. |
| 12:50 | m1dnight | call: (load-store-only 30 5 20 500) and constraint: |
| 12:50 | m1dnight | (defn load-store-only [thread-count cache-size store-size store-latency] |
| 12:50 | m1dnight | "Test requesting from the store" |
| 12:50 | m1dnight | { |
| 12:50 | m1dnight | :pre [(> store-size thread-count)] |
| 12:50 | m1dnight | :post [] |
| 12:50 | justin_smith | it is easy to use :pre and :post wrong, there is no error message, they just don't fire |
| 12:50 | m1dnight | } |
| 12:50 | pyrtsa | m1dnight: Your docstring is in wrong place. |
| 12:51 | m1dnight | snap |
| 12:51 | pyrtsa | FYI, :pre and :post also won't work if *assert* is set to false, but who does that. :) |
| 12:51 | m1dnight | oh, it seems to be so, yes |
| 12:51 | gfredericks | I just went on a rant in the internal chatroom about arglists going on the first line |
| 12:51 | m1dnight | had not noticed it before! |
| 12:51 | gfredericks | due to exactly this possibility |
| 12:51 | m1dnight | so it's <name> <docstring> <params> |
| 12:51 | pyrtsa | Yes. |
| 12:52 | gfredericks | ,(doc defn) |
| 12:52 | clojurebot | "([name doc-string? attr-map? [params*] prepost-map? ...] [name doc-string? attr-map? ([params*] prepost-map? body) + ...]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata. prepost-map defines a map with optional keys :pre and :post that contain collections of pre or post conditions." |
| 12:52 | m1dnight | damn, sorry I missed that guys |
| 12:52 | m1dnight | figured I'd get a compiler error |
| 12:52 | m1dnight | thanks again :p |
| 12:52 | cbp | Happens to everyone |
| 12:52 | gfredericks | maybe eastwood would catch that as an unused literal |
| 12:52 | justin_smith | m1dnight: yeah, because pre / post are just a regular data structure, they don't throw an error when malformed / in the wrong place |
| 12:53 | justin_smith | they just don't do what you expect, is all |
| 12:53 | pyrtsa | I just wish :pre and :post would allow a custom error message like assert does. The errors from :pre and :post are often so unhelpful when they happen. |
| 12:53 | gfredericks | well the post should throw |
| 12:53 | cbp | I have actually very old code with docstrings in the wrong place haha |
| 12:53 | gfredericks | ,(fn [a] "Putting my post in the wrong place" {:post [(even? %)]} a) |
| 12:53 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 12:53 | pyrtsa | Heh, so postconditions are safer actually. :) |
| 12:54 | gfredericks | pyrtsa: I sent an email to clojure-dev about the error message thing with a couple proposals for how to support it |
| 12:54 | gfredericks | nobody responded |
| 12:54 | pyrtsa | gfredericks: Link? |
| 12:54 | gfredericks | I'll check |
| 12:54 | justin_smith | ,(fn [a] "Putting my post in the wrong place" {:post [(even? a)]} a) |
| 12:54 | justin_smith | ,((fn [a] "Putting my post in the wrong place" {:post [(even? a)]} a) 1) |
| 12:54 | clojurebot | #<sandbox$eval71$fn__72 sandbox$eval71$fn__72@1ed8be3> |
| 12:54 | clojurebot | 1 |
| 12:54 | gfredericks | justin_smith: what's the point of a post without using %? |
| 12:55 | m1dnight | hah :) nice |
| 12:55 | justin_smith | gfredericks: ahh, got it |
| 12:55 | m1dnight | he meant pre, I think |
| 12:55 | justin_smith | m1dnight: no, I just didn't understand what he was demonstrating |
| 12:55 | gfredericks | pyrtsa: just kidding I did get one response: https://groups.google.com/forum/#!searchin/clojure-dev/preconditions/clojure-dev/eNK9UZ5HklI/BDa6CDHenWkJ |
| 12:58 | pyrtsa | gfredericks: Ha, that's actually a very nice way to achieve it. |
| 12:59 | SparkySparkyBoom | is there a function to add one map to another where only the same keys are modified |
| 12:59 | pyrtsa | Thanks! |
| 12:59 | SparkySparkyBoom | like a set union |
| 12:59 | m1dnight | hey, they work now \o/ |
| 12:59 | m1dnight | thanks a bunch guys |
| 12:59 | justin_smith | SparkySparkyBoom: merge / merge-with |
| 12:59 | m1dnight | free internets for everyone! |
| 12:59 | technomancy | (map inc @#clojure) |
| 13:00 | hyPiRion | technomancy: that one is just too lazy |
| 13:00 | SparkySparkyBoom | (add {:a "a" :b "c"} {:a "aa" :b "bb" :c "cc"}) |
| 13:00 | technomancy | hyPiRion: mapv then? |
| 13:00 | SparkySparkyBoom | where the result is {:a "aa" :b "bb"} |
| 13:00 | hyPiRion | technomancy: yeah, or dorun |
| 13:00 | SparkySparkyBoom | justin_smith: will it do that? |
| 13:00 | justin_smith | SparkySparkyBoom: so you don't want union, you want intersection :P |
| 13:00 | technomancy | I get a guilty pleasure from using mapv for side-effects |
| 13:01 | SparkySparkyBoom | ah |
| 13:01 | SparkySparkyBoom | sorry |
| 13:01 | SparkySparkyBoom | yes |
| 13:01 | justin_smith | something like (merge (select-keys a (keys b)) (select-keys b (keys a))) |
| 13:01 | gfredericks | merge-intersectingly! |
| 13:01 | pyrtsa | Maybe just (select-keys b (keys a)) |
| 13:02 | gfredericks | then b has to have the keys |
| 13:02 | pyrtsa | Right. |
| 13:02 | pyrtsa | (merge a (select-keys b (keys a)) |
| 13:02 | gfredericks | I guess that's what intersection does |
| 13:03 | justin_smith | ,(let [a {:a 0 :b 1 :c 2} b {:b 3 :c :4 :d 5 :e 6}] (merge (select-keys a (keys b)) (select-keys b (keys a)))) SparkySparkyBoom |
| 13:03 | clojurebot | {:b 3, :c :4} |
| 13:04 | johnjelinek | hihi all, how's it goin'? |
| 13:04 | justin_smith | pyrtsa: well that's not an intersection, it has all keys of a |
| 13:04 | pyrtsa | justin_smith: The original example didn't require it to be an intersection actually. |
| 13:04 | justin_smith | pyrtsa: I could have misunderstood the intention |
| 13:04 | johnjelinek | got a question: I have a higher-order function defined in a let so I can use it, but it is executing in the let and also when my functions use it |
| 13:05 | johnjelinek | how can I declare it without using it in the let? |
| 13:05 | gfredericks | johnjelinek: that shouldn't be happening; can you share your code? |
| 13:05 | manutter | Do you h ave the fn name after the (fn part? |
| 13:05 | johnjelinek | lemme clean it up and I'll refheap it :) |
| 13:05 | justin_smith | johnjelinek: things don't execute unless you call them |
| 13:06 | SparkySparkyBoom | justin_smith: thank you |
| 13:06 | manutter | it should look like (let [my-fn (fn [arg] (body))]) |
| 13:07 | justin_smith | SparkySparkyBoom: actually, taking a second look at that, since we are doing a merge we only get the values from b |
| 13:08 | justin_smith | ,(let [a {:a 0 :b 1 :c 2} b {:b 3 :c :4 :d 5 :e 6}] (select-keys b (keys a))) this is equivalent |
| 13:08 | clojurebot | {:b 3, :c :4} |
| 13:09 | justin_smith | the other one had a redundant selection of elements of a that would all get replaced (though as I mentioned above merge-with could do something useful) |
| 13:10 | rasmusto | (reductions (fn [v f] (mapcat f v)) [{:seed blah}] (cycle [fn1 fn2 fn3]))) |
| 13:10 | rasmusto | is this ^ a thing? |
| 13:10 | johnjelinek | https://www.refheap.com/85025 |
| 13:11 | johnjelinek | I believe the part in the let is being executed because I get "401" printed out, which is a (.statusCode resp) |
| 13:12 | johnjelinek | and it happens on start (and also when the channel gets that event message) |
| 13:12 | justin_smith | johnjelinek: I see no let in that code... |
| 13:12 | johnjelinek | https://www.refheap.com/85025#L-11 |
| 13:12 | johnjelinek | line 11 |
| 13:12 | justin_smith | oh never mind |
| 13:12 | justin_smith | yeah, I missed it, see it now |
| 13:13 | justin_smith | so you are thinking the token-handler is being called prematurely? |
| 13:14 | m1dnight | well, I just figured out you can't use function names that reside in the core namesapce |
| 13:14 | m1dnight | derp :p |
| 13:14 | johnjelinek | I think so, the println is being called when the process starts |
| 13:14 | justin_smith | m1dnight: you can, it's just not a good idea usually - but you can still call clojure.core/shadowed explicitly |
| 13:15 | justin_smith | johnjelinek: if the let is on the top level, I would expect to see the go-loop be executed immediately |
| 13:15 | justin_smith | which could lead to token-handler being called, I would assume |
| 13:16 | johnjelinek | but the channel doesn't have anything in the buffer on start |
| 13:16 | johnjelinek | so, the go-loop shouldn't grab anything |
| 13:16 | johnjelinek | brb, lunch |
| 13:16 | justin_smith | johnjelinek: in general anything with side effects should be in a function (maybe an 'init') so that it can be explicitly run / re-run instead of running at namespace load time |
| 13:21 | cbp | m1dnight: use (:refer-clojure :exclude [..]) It's fine as long as they are not special forms |
| 13:34 | m1dnight | cbp: yeah, I went with that one instead of renaming all my functions |
| 13:34 | m1dnight | funny quirck though :) |
| 13:34 | m1dnight | well, kinda logical, actually |
| 13:53 | dudnik | hey |
| 13:54 | teslanick | Nek is now known as Guest82402... Guest82402 is now known as nikdudnik... nikdudnik is now known as dudnik |
| 13:54 | teslanick | WHO ARE YOU REALLY!? |
| 14:00 | m1dnight | SANTA |
| 14:37 | dbasch | is there an emacs mode for edn files? |
| 14:37 | amalloy | gfredericks: #(fn (inc %) {:post [(even? %)]}) |
| 14:37 | jonasen | dbasch: clojure-mode? |
| 14:38 | amalloy | now, that code is illegal because i got the args to fn wrong :P |
| 14:38 | amalloy | but, okay, imagine the syntax is right - will % throw in that context? |
| 14:38 | dbasch | jonasen: I guess that works, thanks |
| 14:38 | amalloy | i think probably not, but it will refer to the wrong %: the function's argument, not its return value |
| 14:39 | gfredericks | amalloy: easy to find out |
| 14:40 | gfredericks | ,#(fn (inc %) {:post [(even? %)]}) |
| 14:40 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Parameter declaration inc should be a vector, compiling:(NO_SOURCE_PATH:0:0)> |
| 14:40 | gfredericks | ,#(fn [a] "docstring" {:post [(even? %)]} a) |
| 14:40 | clojurebot | #<sandbox$eval51$fn__52 sandbox$eval51$fn__52@39f4d3> |
| 14:40 | gfredericks | I don't think I've ever used #(fn ...) before |
| 14:41 | gfredericks | (inc amalloy) |
| 14:41 | lazybot | ⇒ 104 |
| 14:41 | gfredericks | amalloy: wtg with the weird edge case, as always |
| 14:41 | gtrak | technomancy: I tried to get syme going on a m3.medium, you mentioned it would give me the option if I picked a custom AMI, firstly the AMI didn't load, secondly, I didn't get the option. Here's why I think it's hard-coded: https://github.com/technomancy/syme/blob/master/src/syme/instance.clj#L97 . Guess I'm SOL until I decide to fork and deploy it myself? :-) |
| 14:42 | amalloy | gfredericks: i'm sure i've used #(fn ...) somewhere. probably #(fn [x] (fn [y] ...)) even, in jiraph i think |
| 14:44 | gfredericks | amalloy: did it make you miss haskell? |
| 14:45 | bbloom | mmm currying thunks |
| 14:45 | amalloy | gfredericks: ah, https://github.com/ninjudd/jiraph/blob/develop/src/flatland/jiraph/wrapped_layer.clj#L9 is what i was thinking of |
| 14:46 | gfredericks | amalloy: did you use an IO monad? |
| 14:47 | amalloy | gfredericks: i tried |
| 14:48 | amalloy | it went kinda okay |
| 14:48 | technomancy | gtrak: well aw crap |
| 14:49 | technomancy | gtrak: if you have a heroku account I can add you as a collaborator |
| 14:49 | technomancy | so you don't have to get your own copy going |
| 14:49 | amalloy | the main problem was that i only had a good implementation of >>, not >>=. but it was still kinda useful, because it meant we had a first-class model of IO actions to perform, which helped if like...the machine had crashed mid-transaction, allowing us to pretend-to-perform the actions that had already been done |
| 14:49 | gtrak | technomancy: ah, yea I do, just not sure I can get to it today. Maybe I can take a look in a couple hours, though? |
| 14:50 | technomancy | sure, just let me know your account |
| 14:50 | gtrak | gary dot trakhman at gmail dot com |
| 14:51 | gfredericks | clojurebot: gary is a cool guy |
| 14:51 | clojurebot | You don't have to tell me twice. |
| 14:51 | technomancy | gtrak: you got it |
| 14:51 | gtrak | cool! |
| 14:52 | gfredericks | amalloy: "had already been done" meaning "hadn't already been done"? |
| 14:52 | jcromartie | justin_smith: yeah? looking for full-time? |
| 14:53 | justin_smith | yeah |
| 14:53 | justin_smith | caribou got defunded |
| 14:53 | justin_smith | it's been a good run, parting ways in good spirits |
| 14:54 | amalloy | gfredericks: no, i had it right. suppose you had some IO action that adds 1 to a person's age, then reads their age |
| 14:54 | llasram | justin_smith: Will it be dismantled and sold as scrap abstractions? |
| 14:54 | amalloy | we need to *not* actually write any change to disk if that part of the transaction was already done; but your read needs to return the old result before you "attempt" to write, and then the new result after your wriet |
| 14:55 | justin_smith | llasram: buried in a secret spot in the desert |
| 14:55 | llasram | ha! |
| 14:55 | amalloy | we were able to do that because we had a revisioned database, where the past is immutable. so we'd detect you'd already done that write, and look in the past for the first read, drop your write, then look in the present for a second read |
| 14:55 | llasram | justin_smith: Not enough clients willing to go the Clojure route? |
| 14:56 | dbasch | justin_smith: any interest in cryptocurrencies? |
| 14:56 | justin_smith | llasram: the company is getting bigger, more companies that have their own stack already / are in the position to dictate a specific tech stack |
| 14:56 | justin_smith | *more clients |
| 14:56 | technomancy | justin_smith: were you doing OSS work full time up to now? |
| 14:56 | justin_smith | dbasch: I'll get back to you on that :) |
| 14:57 | justin_smith | technomancy: divided between OSS work on the framework and client work using that framework |
| 14:57 | technomancy | cool |
| 14:57 | justin_smith | technomancy: company decided they were spending too much money on work that was not bringing in revenue (almost all the work has been OSS recently) |
| 14:58 | technomancy | yeah, it happens |
| 14:58 | jcromartie | PS we are hiring for work w/ some Clojure here. http://www.element84.com/jobs |
| 14:58 | technomancy | I got hired to do primarily leiningen originally. |
| 14:58 | jcromartie | you need to be able to be in the DC area once in a while |
| 14:58 | jcromartie | but we are more and more remote |
| 14:58 | justin_smith | jcromartie: thanks man - people can also hit me up via pm or in #clojure-social since this is a little OT for #clojure |
| 14:59 | jcromartie | you are right |
| 14:59 | jcromartie | yes, anybody who wants to use Clojure at work should come to #clojure-social :) |
| 15:06 | lemonodor | element #84 is a pretty nasty one! |
| 15:06 | jcromartie | yeah, it's a pun on the owner's name |
| 15:07 | jcromartie | I need an Enlive selector that selects only the topmost div, |
| 15:07 | jcromartie | not any child ones |
| 15:08 | jcromartie | [:div] selects the child divs as well as the topmost one |
| 15:08 | jcromartie | [[:div first-of-type]] does too |
| 15:12 | m1dnight | (sorry i'm asking another question guys) I have an atom to stop threads from looping. I tried setting that atom to see if my threads would stop and they do. When i return it from my function to reset it to false in an other scope it doesn't work anymore. |
| 15:12 | m1dnight | any clue as to why? |
| 15:13 | m1dnight | http://pastebin.com/LHQx4P55 this is the code.. |
| 15:13 | m1dnight | I've shown the part where it stops working |
| 15:13 | m1dnight | again something I don't get :p |
| 15:14 | m1dnight | hmm maybe I should declare the stop atom in my original scope |
| 15:15 | m1dnight | ill try that first |
| 15:15 | jcromartie | yeah, those atoms are all out of scope of the fn returned by thread-factory-looping |
| 15:15 | jcromartie | you could use thread-local bindings with dynamic vars for all of them |
| 15:15 | gtrak | technomancy: quick glance at the diff? http://sprunge.us/dEXX |
| 15:16 | jcromartie | this would actually be one of those places where it makes sense :) |
| 15:16 | jcromartie | wait, no they are passed as args |
| 15:16 | jcromartie | never mind |
| 15:17 | technomancy | gtrak: lgtm |
| 15:17 | m1dnight | oh |
| 15:17 | gtrak | sweet, I'll deploy it and try it out. |
| 15:17 | technomancy | gtrak: are there restrictions about what AMIs can be used with what instance sizes? |
| 15:17 | gtrak | I have no idea. |
| 15:17 | technomancy | maybe I'm getting confused with having them tied to specific regions only |
| 15:17 | technomancy | that seems more sensible |
| 15:17 | m1dnight | hrm, strange it's the same behaviour when I pass my stopping atom TO the thread-factory-looping |
| 15:18 | gtrak | technomancy: a couple-hours hackathon could really polish this up. I'll pitch it to my meetup. |
| 15:19 | technomancy | gtrak: if you could open issues for things you run into it would be great too |
| 15:19 | technomancy | I've hardly touched it since my original coding frenzy |
| 15:19 | gtrak | validation, error-checking, logging would be my first concern. |
| 15:20 | technomancy | the errors you get launching an instance are pretty annoying |
| 15:20 | gtrak | from ec2 api, or from syme? |
| 15:20 | technomancy | from ec2 |
| 15:20 | technomancy | well |
| 15:20 | technomancy | I mean, we pass the annoyance on to the user |
| 15:21 | gtrak | ah, gotcha. |
| 15:22 | gtrak | here goes nothin' |
| 15:23 | gtrak | technomancy: 3.5GB of memory, success.. almost something that can run lein, now :P |
| 15:27 | m1dnight | hmm can't seem to fix it with those atoms |
| 15:27 | m1dnight | is it expected behavior? |
| 15:27 | gtrak | what's weird is how uncomfortable 15 cents makes me feel disproportionate to the utility. |
| 15:27 | gtrak | compared to $5 for a coffee |
| 15:33 | technomancy | gtrak: I thought about using digital ocean instead since it's so much cheaper |
| 15:33 | technomancy | but the fact that everyone already has an AWS account counts for a lot |
| 15:33 | gtrak | not me! |
| 15:33 | gtrak | had to get one. |
| 15:34 | technomancy | whaaaaaat |
| 15:34 | gtrak | we don't all work at heroku, man |
| 15:34 | amalloy | technomancy lives in some weird AWS-centric world |
| 15:34 | amalloy | i certainly don't have an AWS account |
| 15:34 | technomancy | but you have an amazon account |
| 15:34 | gtrak | well, yea |
| 15:34 | gtrak | but oddly the credit cards don't sync up |
| 15:35 | gtrak | oh wow, DO is way better. |
| 15:36 | gtrak | what happened to pair.io anyway, did they fall off the map? |
| 15:36 | gtrak | I tried to use their form (I don't have an invite) and got a nasty stacktrace :-) |
| 15:38 | m1dnight | allright, got the error :) don't join threads before you stop them.. |
| 15:38 | yeoj___ | if i have a program printing to stdout, is that any slower than writting to a file? I'm trying to build a command line program i can use with named pipes and other unix programs. |
| 15:39 | ToxicFrog | yeoj___: it depends? |
| 15:39 | ToxicFrog | I mean, first of all, stdout might be connected to a file itself, or a named pipe, or another program's stdin, rather than a tty |
| 15:40 | ToxicFrog | If it is connected to a tty, well, which is more expensive, writing to disk (what disk? What filesystem? What caching policy?) or redrawing the tty emulator's window? |
| 15:41 | llasram | I noticed at some point that writing to Java's stdout was *insaaaenly* slow |
| 15:41 | llasram | I didn't drill too far into it, but id definitely didn't seem to matter if I was using Clojure's `*out*` or hitting `System/out` |
| 15:42 | llasram | Maybe `PrintWriter`? |
| 15:42 | PigDude | how does a function pass `h', bound {:as h} to another function? |
| 15:42 | ToxicFrog | And yeah, if we're involving java it also depends on what kind of horrifying clusterfuck of writers/buffers/etc is wrapped around stdout |
| 15:42 | PigDude | is there a way to do this without apply? |
| 15:42 | PigDude | so one function expects (f :a 1 :b 2), now i want to pass those params directly to g which expects the same |
| 15:43 | PigDude | also, generally how to provide a hash to a function like this? **kwargs in python |
| 15:43 | gtrak | ~google clojure apply-kw |
| 15:43 | clojurebot | First, out of 578 results is: |
| 15:43 | clojurebot | ClojureDocs - clojure.core/apply |
| 15:43 | clojurebot | http://clojuredocs.org/clojure_core/1.2.0/clojure.core/apply |
| 15:43 | gtrak | well, here it is anyway: https://groups.google.com/forum/#!topic/clojure-dev/9ctJC-LXNps/discussion |
| 15:44 | PigDude | this is a roundabout way of syaing it's not in the language? |
| 15:44 | PigDude | (yet) |
| 15:44 | cbp | ~mapply |
| 15:44 | clojurebot | You could (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))) |
| 15:44 | gtrak | there's a JIRA ticket, but it's been there for years |
| 15:45 | gtrak | about 1.5 yearas |
| 15:45 | PigDude | i have some functions that accept a common config hash, this is also used as a dispatch in a multimethod |
| 15:45 | cbp | use an explicit map. Trying it to do the python way is a PITA |
| 15:45 | llasram | (inc cbp) |
| 15:45 | lazybot | ⇒ 5 |
| 15:45 | PigDude | so for the multimethod it has to be the first arg, but i think usually an arg like this is the last arg |
| 15:46 | llasram | PigDude: Nope -- optional argument map first arg now |
| 15:46 | llasram | There's still some documentation suggesting to do it the "keyword argument" style way, but check out edn/read |
| 15:46 | PigDude | llasram: sorry? |
| 15:46 | PigDude | ah, i see |
| 15:46 | PigDude | ok, so i can do it 'right way' and be consistent w/ multimethod |
| 15:47 | llasram | I'm not quite sure what you're talking about wrt multimethods.... You can make the dispatch for a multimethod be based on anything about the arguments |
| 15:48 | PigDude | my multimethods have different arities, i guess i could have it just pull the last item off, but like yous aid this is not the way to make such an API now |
| 15:50 | PigDude | thanks everyone :) |
| 15:56 | Raynes | Now refheap's paste inflation bug should be fixed. |
| 15:57 | Raynes | Let's all pretend refheap has 85k legitimate pastes and move on with our lives. |
| 15:57 | bbloom | Raynes: i can't move on. this is an important issue. you've been lying to us about pastes & therefore you're a bad man who must be flogged publicly |
| 15:58 | bbloom | ....time passes... |
| 15:58 | bbloom | ok, i'm over it |
| 15:58 | bbloom | carry on |
| 15:59 | cbp | boy clojure sure is popular |
| 15:59 | jimjams | Quick dumb question: How can you get the basis keys from a variable containing a record type? |
| 16:00 | jimjams | I can get the keys if I have the actual type in my hand using the static Type/getBasis method |
| 16:00 | jimjams | but if I pass in the type to a macro, I'm totall lost. |
| 16:00 | jimjams | *totally |
| 16:00 | amalloy | jimjams: i think if you don't already know what those keys are, you probably don't want to be using a record? |
| 16:00 | bbloom | ,(deftype Point [x y]) |
| 16:00 | clojurebot | sandbox.Point |
| 16:00 | bbloom | ,(.getBasis (-> (Point. 5 10) class)) |
| 16:00 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: getBasis for class java.lang.Class> |
| 16:01 | bbloom | hmm that makes sense |
| 16:01 | bbloom | ,(.getBasis (Point. 5 10)) |
| 16:01 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: getBasis for class sandbox.Point> |
| 16:01 | amalloy | bbloom: you have to use the reflector |
| 16:01 | jimjams | amalloy: I want to write a macro that pulls the basis keys out automatically |
| 16:01 | bbloom | amalloy: yeah, i figured |
| 16:01 | amalloy | jimjams: why? |
| 16:02 | jimjams | amalloy: I've got some conversion methods on our internal datatypes that operate on all of their fields in a uniform way. |
| 16:03 | jimjams | amalloy: so far I've copied the vector of fields by hand, but having a general (and less prone to inconsistancies) way to access all of the fields names will make everything easier to work with |
| 16:04 | bbloom | please forgive the following spam: |
| 16:04 | bbloom | ,(import '[clojure.lang Reflector]) |
| 16:04 | clojurebot | clojure.lang.Reflector |
| 16:04 | bbloom | ,(defn static-invoke [class member & args] (if (zero? (count args)) (try (Reflector/getStaticField class member) (catch Exception e (Reflector/invokeStaticMethod class member clojure.lang.RT/EMPTY_ARRAY))) (Reflector/invokeStaticMethod class member (object-array args)))) |
| 16:04 | clojurebot | bbloom: Excuse me? |
| 16:04 | bbloom | ,(defn staticfn [class member] (fn [& args] (apply static-invoke class member args))) |
| 16:04 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: static-invoke in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 16:04 | bbloom | ,(deftype Point [x y]) |
| 16:04 | clojurebot | sandbox.Point |
| 16:04 | bbloom | ,(let [p (Point. 5 10)] ((staticfn (class p) "getBasis"))) |
| 16:04 | clojurebot | #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'sandbox/staticfn> |
| 16:04 | bbloom | aw, executed in the wrong order |
| 16:05 | llasram | ,(try "exceptions?" (catch Exception _ "nope.")) |
| 16:05 | clojurebot | llasram: It's greek to me. |
| 16:06 | llasram | You're the best, clojurebot |
| 16:06 | jimjams | bbloom: I see where you're going with that though! Thanks |
| 16:07 | bbloom | Raynes: there does not appear to be a button any more to save my paste... |
| 16:07 | jimjams | It's crazy that you've gotta jump through so many hoops to talk to static functions, but I guess that's the price you pay for such clean interop elsewhere. |
| 16:07 | bbloom | jimjams: https://gist.github.com/brandonbloom/1636c60c176f992cb60c |
| 16:07 | amalloy | bbloom: that's how he's going to cut down on paste inflation |
| 16:08 | amalloy | jimjams: well, static functions are easy |
| 16:08 | amalloy | static functions when you don't even know what class you want to call them on? that's not as easy |
| 16:08 | amalloy | you have to do the same thing in java |
| 16:08 | bbloom | jimjams: it's not a price of clean interop, it's a price of interop that yields efficient & predictable bytecode |
| 16:08 | jimjams | Good points. |
| 16:08 | bbloom | jimjams: java doesn't have a non-reflection based mechanism for dynamically dispatching static methods |
| 16:10 | jimjams | I feel like it'd help a bunch to sit and digest how interop really happens between java and clojure at some point. |
| 16:11 | jimjams | Thanks for the pointers and gist though! <3 <3 <3 |
| 16:12 | bbloom | jimjams: i recommend the src to tools.analyzer and tools.emitter.jvm for precisely how clojure translates to jvm intrinsics |
| 16:14 | jimjams | These look wicked. Bookmarked! |
| 16:16 | bizniz98 | Using archiva with clojure project...so have ~/.lein/profiles.clj for archiva creds. How would this translate to Jenkins? |
| 16:17 | technomancy | gtrak: pair.io used the v2 github API |
| 16:17 | technomancy | but it was also way more complicated |
| 16:18 | technomancy | since it had to do the oauth dance to get access to your repos |
| 16:18 | gtrak | ah |
| 16:18 | gtrak | I already figured out the oauth bit in a test-project, it wasn't that bad. |
| 16:18 | technomancy | gtrak: about 10x more code |
| 16:19 | gtrak | but syme doesn't really need it. Not sure I'd want it to be more git-project-centric than it already is? |
| 16:19 | technomancy | gtrak: right now it's OSS-only |
| 16:19 | technomancy | which is sort of by design, sort of because I'm lazy |
| 16:19 | gtrak | ah, it won't work on private repos? that kinda sucks. |
| 16:19 | technomancy | haven't decided which yet =) |
| 16:19 | technomancy | gtrak: you can use it for private repos; you just have to clone by hand |
| 16:20 | gtrak | ah, right. |
| 16:20 | technomancy | because I don't want to get in the business of storing anything sensitive |
| 16:20 | gtrak | yea, that's fine. |
| 16:20 | technomancy | which given how much attention I've paid to the project has absolutely turned out to be the right choice =) |
| 16:20 | gtrak | just bringing up the ec2 instance and some helpful hints on tmux was enough for me to feel it's useful :-) |
| 16:21 | technomancy | yeah, and setting up the pubkeys by magic |
| 16:21 | gtrak | and the .symerc bit, that's nice. |
| 16:21 | gtrak | yea |
| 16:21 | technomancy | it's useful for seajure |
| 16:41 | PigDude | is there an idiom for applying a function to the first argument, as in a common multimethod dispatch function? |
| 16:42 | PigDude | now i have a higher-order fyunction 'apply-first-arg' that returns a function doing this |
| 16:43 | gtrak | partial? |
| 16:43 | PigDude | i don't see how partials are used for this |
| 16:43 | gtrak | ,((partial + (inc 1)) 2) |
| 16:43 | clojurebot | 4 |
| 16:43 | PigDude | right |
| 16:43 | bbloom | PigDude: do you want double type-based dispatch? |
| 16:44 | PigDude | bbloom: well i hvae a bunch of methods that dispatch based on the first arg |
| 16:44 | bbloom | PigDude: use defmulti unless you know for sure you want defprotocol |
| 16:44 | PigDude | bbloom: but they have different arities in different method implementations even, so a flexible dispatch function would accept any number of arguments and dispatch from the first one |
| 16:44 | PigDude | bbloom: yea,i'm using multimethods now |
| 16:45 | bbloom | PigDude: multimethods can trivially be made variadic |
| 16:45 | PigDude | here's my code: |
| 16:45 | bbloom | (defmulti foo (fn [x & args] (:some-key x))) |
| 16:47 | PigDude | bbloom: http://www.bpaste.net/show/fJdS6ymXQMJurEyfgmUD/ |
| 16:47 | PigDude | bbloom: does this look reasonable? i felt like maybe my higher-order function is reinventing some wheel, or there is a different idiom for common dispatch function to variadic MMs |
| 16:48 | PigDude | bbloom: maybe the idiom is #(f %1) ... |
| 16:48 | PigDude | rather %) |
| 16:48 | bbloom | PigDude: yeah, the idiom is to just create an inline anon fn |
| 16:48 | PigDude | ok thanks |
| 16:49 | PigDude | i forgot about # :) |
| 16:49 | bbloom | also, this may be a case where you actually do want a protocol |
| 16:50 | PigDude | bbloom: it probably is one, but i was advised to start w/ a MM for now |
| 16:50 | PigDude | bbloom: (this is my first clojure project at a new position) |
| 16:50 | PigDude | bbloom: so i think it will probably become a protocol |
| 16:50 | bbloom | PigDude: the reason for that advice is b/c multimethods are more flexible and easier to work with |
| 16:51 | bbloom | PigDude: but that doesn't mean OOP ideas are 100% bad, so if you're doing something mutable like representing an interface to an external service, then it makes sense to do somewhat traditional OOP things |
| 16:51 | bbloom | like defining an interface aka (sorta) a protocol |
| 16:51 | PigDude | makes sense |
| 17:05 | michaelr525 | hello |
| 17:06 | gopat | Hello michaelr525 |
| 17:07 | gopat | Hehe. |
| 17:07 | gopat | Don't try this at home |
| 17:07 | michaelr525 | what's so funny tonight? |
| 17:07 | gopat | just evaulated (range) in a repl |
| 17:07 | michaelr525 | on which laptop? |
| 17:08 | gopat | rMBP13" |
| 17:08 | gopat | java kernel panic |
| 17:08 | michaelr525 | oh |
| 17:08 | gopat | never turbo boosted to 450% before :D |
| 17:09 | michaelr525 | i'm looking to buy a good laptop for work.. |
| 17:10 | michaelr525 | everything i see on the market today is disappointing |
| 17:10 | gopat | new macbook airs just out |
| 17:10 | amalloy | gopat: (pmap inc (range)) or bust |
| 17:10 | michaelr525 | i'm not familiar with macbooks |
| 17:10 | michaelr525 | why would anyone buy a macbook? |
| 17:11 | amalloy | michaelr525: as a linux user, i bought a thinkpad somewhat recently. i'd recommend you instead get a macbook and install linux on it; the hardware is so much better |
| 17:11 | michaelr525 | amalloy: are you serious? |
| 17:11 | michaelr525 | amalloy: the new thinkpads are really disappointing, that's w2hat I'm talking about |
| 17:12 | turbofail | linux on a macbook often has driver issues though |
| 17:12 | cbp | Maybe one of those new dell precision laptops? |
| 17:12 | cbp | they look pretty good |
| 17:12 | cbp | no idea if you can run linux on them though |
| 17:12 | dbasch | turbofail: linux on a macbook? *barf* |
| 17:12 | michaelr525 | cbp: i don't like that they don't have page up/down home/end buttons |
| 17:12 | technomancy | glossy screens =( |
| 17:13 | technomancy | such a tragedy |
| 17:13 | michaelr525 | yeah, that's a problem I live in a sunny country :) |
| 17:13 | turbofail | also the battery life will typically be dramatically worse |
| 17:13 | cbp | pft who uses the laptop's keyboard anyway :-P |
| 17:14 | michaelr525 | technomancy: what laptop are you working one? |
| 17:14 | michaelr525 | one |
| 17:14 | michaelr525 | on |
| 17:14 | michaelr525 | dammit |
| 17:15 | stompyj | bitemyerrors twitter profile pic is a clojure stacktrace? haha, he truly is on a mission |
| 17:15 | yeoj___ | is there anyway for my leiningen/clojure program to tell if i'm running via script or not? I have error conditions that call System/exit and it's annoynig to have to restart my repl constantly. |
| 17:15 | technomancy | michaelr525: I'm currently on a thinkpad x200s; hoping to upgrade to a novena soon |
| 17:16 | michaelr525 | novena.. let me gooogle that |
| 17:17 | justin_smith | if you have a macbook budget, consider a system76 computer with ubuntu preinstalled, I like mine |
| 17:17 | technomancy | http://www.crowdsupply.com/kosagi/novena-open-laptop |
| 17:18 | justin_smith | yeoj___: you could have a function that decides whether to exit or to print a stack trace, and delegate to that |
| 17:18 | justin_smith | yeoj___: it could just be a question of checking if the :development profile is active |
| 17:18 | yeoj___ | justin_smith: ahh, ok thats what i was missing. thanks. |
| 17:21 | justin_smith | yeoj___: consider using System/setProperty and System/getProperty to check for which behavior should be used |
| 17:21 | yeoj___ | justin_smith: ok thank you i'll look into it. |
| 17:21 | michaelr525 | technomancy: weird stuff |
| 17:21 | justin_smith | or something more elaborate like environ |
| 17:22 | technomancy | weird is good |
| 17:22 | technomancy | most of the time |
| 17:23 | nullptr` | (note that technomancy also built his own keyboard) |
| 17:23 | nullptr` | <-- lazier than that |
| 17:23 | justin_smith | technomancy: so you don't use anything that relies on x86 support? I actually kind of like the idea of an ARM desktop |
| 17:23 | technomancy | justin_smith: I play minecraft with my kids |
| 17:23 | technomancy | but I'm not getting rid of my thinkpad |
| 17:24 | justin_smith | ahh, that makes sense |
| 17:24 | justin_smith | I'll assume there is a good JVM / JDK for ARM |
| 17:25 | technomancy | it's kinda crap actually |
| 17:25 | justin_smith | I was reading recently that there is a tradeoff where more power is required for CISC while RISC can't use cache as efficiently |
| 17:25 | technomancy | but the novena is still nearly a year away from shipping |
| 17:25 | technomancy | and the code to improve the JIT has been written, it just hasn't landed in openjdk yet |
| 17:26 | justin_smith | oh, that's too bad |
| 17:26 | justin_smith | maybe by then openjdk for ARM will get better, heh |
| 17:26 | technomancy | currently on arm racket smokes openjdk |
| 17:28 | justin_smith | well that's cool, let's just switch to racket then |
| 17:29 | michaelr525 | hmm |
| 17:29 | Frozenlock | How about a clojure implementation on racket? |
| 17:30 | technomancy | https://github.com/greghendershott/rackjure <- pretty cool apart from the name |
| 17:30 | Frozenlock | implement clojure on all the things! |
| 17:30 | Frozenlock | Interesting |
| 17:30 | technomancy | it's not clojure exactly so much as "all the things that someone who likes clojure is likely to miss when using racket" |
| 17:31 | technomancy | which isn't as much as you'd expect |
| 17:31 | Frozenlock | I'd really like a Clojure where you don't have to know the underlying platform |
| 17:31 | Frozenlock | technomancy: you like Racket? |
| 17:31 | technomancy | Frozenlock: tons |
| 17:31 | technomancy | well |
| 17:32 | technomancy | I haven't used it tons, but I mostly like it, except for a few problems that rackjure fixes. |
| 17:32 | Frozenlock | I tried it a few years ago. Can't even remember what I thought of it :-/ |
| 17:32 | technomancy | the literature and usability are both excellent, possibly unrivaled |
| 17:33 | Frozenlock | Are you able to do 'real' things? |
| 17:33 | technomancy | sure |
| 17:33 | Frozenlock | I remember drRacket being kind of neat |
| 17:33 | amalloy | as a being of pure energy, technomancy can *only* do real things through a programming language |
| 17:34 | justin_smith | LOL |
| 17:44 | justin_smith | that "pure energy" thing certainly explians his copious projects and oss contributions |
| 17:44 | Frozenlock | Yeah, it rivals with my theory of "there's two of them.." |
| 17:45 | zerokarmaleft | how do you get a non-namespaced symbol for a var? |
| 17:46 | zerokarmaleft | or do I just need to resort to string-munging? |
| 17:46 | amalloy | &(doc name)? |
| 17:46 | lazybot | ⇒ "([x]); Returns the name String of a string, symbol or keyword." |
| 17:47 | justin_smith | ,(name #'clojure.core/+) zerokarmaleft: |
| 17:47 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to clojure.lang.Named> |
| 17:47 | justin_smith | race condition! |
| 17:47 | justin_smith | err |
| 17:47 | justin_smith | ,(name 'clojure.core/+) zerokarmaleft: |
| 17:47 | clojurebot | "+" |
| 17:47 | amalloy | well, i wasn't gonna do it wrong, justin_smith :) |
| 17:47 | amalloy | so it's not quite a race |
| 17:47 | cbp | o snap |
| 17:47 | justin_smith | lol |
| 17:47 | justin_smith | I have an excuse, post employment drinking |
| 17:47 | Frozenlock | ,(symbol (name 'clojure.core/+)) |
| 17:47 | clojurebot | + |
| 17:47 | cbp | =( |
| 17:48 | amalloy | ,(symbol (name (:name (meta #'+)))) |
| 17:48 | clojurebot | + |
| 17:48 | zerokarmaleft | ah, thanks |
| 17:48 | nullptr` | post employment as in "unemployed", or post employment as in "after work"? those involve different levels of drinking... |
| 17:48 | justin_smith | nullptr`: laid off |
| 17:49 | nullptr` | i guess that can be a good thing or a bad thing depending on the circumstances -- hopefully the former in yours! |
| 17:50 | justin_smith | nullptr`: I'll figure it out when I'm sober, probably next month |
| 17:50 | justin_smith | :) |
| 18:02 | greghendershott | technomancy: The name resulted from about 40 milliseconds of careful consideration. I'm open to suggestions. :) |
| 18:03 | amalloy | greghendershott: just call it lein-ironic-rackjure |
| 18:05 | justin_smith | greghendershott: is the lack of [] because racket already has good associative immutable sequence support? |
| 18:07 | technomancy | greghendershott: well on the bright side it does what it says on the tin. |
| 18:07 | technomancy | people in racket-lang probably aren't as tired of *jure pins as we are here |
| 18:07 | greghendershott | justin_smith: The lack of any X is simply due to no one, so far, missing X enough to submit a pull request. |
| 18:07 | amalloy | i would gladly add a *jure pin to my pin collection |
| 18:08 | greghendershott | technomancy: Ah I see. Sorry. Didn't mean for it to be annoying. |
| 18:08 | greghendershott | Maybe I should rename it Clacket. |
| 18:08 | technomancy | greghendershott: heh, no it's more of an inside joke at this point |
| 18:10 | technomancy | what is up with hash-tables not being functions in regular racket though |
| 18:10 | technomancy | it is just baffling |
| 18:10 | technomancy | these literally have more in common with mathematical functions than procedures do. |
| 18:10 | technomancy | domain -> range. boom. |
| 18:17 | justin_smith | (inc clacket) |
| 18:17 | lazybot | ⇒ 1 |
| 18:17 | justin_smith | greghendershott: after looking a little deeper, it seems a hash in racket can be an associative vector? maybe that addresses my concern |
| 18:19 | technomancy | iirc racket vectors only support efficient lookup, not changes |
| 18:20 | scape_ | racket has immutable and mutable vectors i think, possibly different implementations |
| 18:21 | greghendershott | justin_smith: Maybe I'm understanding you backwards, but, there's a `dictionary` generic of which hashes, lists, and vectors are examples: http://docs.racket-lang.org/reference/dicts.html |
| 18:28 | scape_ | how could I get the index of the results from something like: (filter even? (range 20)) |
| 18:28 | justin_smith | greghendershott: yeah, I'd have to get my hands dirty and see how it really compares, but looks cool |
| 18:29 | amalloy | &(doc keep-indexed) |
| 18:29 | lazybot | ⇒ "([f coll]); Returns a lazy sequence of the non-nil results of (f index item). Note, this means false return values will be included. f must be free of side-effects." |
| 18:29 | scape_ | or do I need to then iterate the list and compare? |
| 18:29 | scape_ | ah ok let me read up thanks |
| 18:32 | scape_ | great, thx amalloy |
| 18:56 | akhudek | I’m profiling a clojurescript app and I’m finding that 80% of the time is in garbage collection. Has anyone encountered this or have an idea what can cause it? |
| 18:57 | coventry | The warning that the function passed to keep-indexed must be free of side-effects seems a little strange. Why warn there but not for map or every-pred? |
| 18:58 | amalloy | coventry: that warning appears in all sorts of weird and inconsistent places |
| 18:59 | scape_ | working with a java array, I noticed using arraycopy is significantly faster than running aset over the array. why is this? |
| 19:00 | TravisD | Does anyone know if there is a project to get a clojure language kernel for ipython? |
| 19:01 | dbasch | scape_: with aset, you’re looking up an entry in the array every time |
| 19:02 | amalloy | scape_: System/arraycopy is implemented in native code, inside the jvm |
| 19:02 | dbasch | scape_: arraycopy obviously keeps a pointer to the current position |
| 19:02 | coventry | TravisD: I know of someone who's working on one, but it appears it's not public yet. |
| 19:02 | TravisD | coventry: Sounds cool. Encourage them to make it public :) |
| 19:03 | coventry | TravisD: Are you aware of kovasb's Session? |
| 19:03 | amalloy | but also you might be doing outrageously slow things, like using reflection to discover the type of the array |
| 19:03 | scape_ | well i have an array that I want to reset basically, but not necessarily the entire array nor is it contiguous |
| 19:03 | TravisD | coventry: looks like I've visited the github page |
| 19:04 | scape_ | maybe i'll check for contiguous sections that I can use arraycopy on |
| 19:13 | amalloy | huh. i just found this in my code: (-> {:x 1 :y 2} (assoc :z 3)) |
| 19:28 | akhudek | amalloy: looks like a tutorial |
| 19:32 | hyPiRion | amalloy: must be a bad day or long ago |
| 19:34 | pdk | is clojure able to fold that at compile time |
| 19:34 | dbasch | amalloy: aset has to do a pointer lookup every time, it could never compete with a properly implemented memory copy of an array |
| 19:34 | amalloy | hyPiRion: you forgot the most common reason absurd-looking code gets written: the simplest possible transformation when something changes. like i think i had (-> {:x ... :y ...} (update-in [:x] assoc :z 3)), and then realized i needed z at the top level rather than under x |
| 19:35 | amalloy | dbasch: well, i already said that |
| 19:35 | amalloy | but i also pointed out he could be making it a thousand times slower by doing other things wrong |
| 19:37 | scape_ | amalloy: it's an object array of promises: this is the slower way I was resetting it-- (doseq [n rqi] (aset q n (promise))), which i where I narrowed down the slowdown |
| 19:38 | amalloy | right, and does clojure know it's an object array? or are you making it do reflection every time you call aset? |
| 19:39 | scape_ | I don't know, which I assume means probably it's figuring it out each time |
| 19:39 | scape_ | should I type hint this? |
| 19:39 | scape_ | I do have reflection warn on, let me rerun this from the top |
| 19:40 | scape_ | yes, reflection warnings |
| 19:40 | amalloy | (aset ^objects q n (promise)) |
| 19:41 | eflynn | is it possible to fetch a dependency in the repl? |
| 19:41 | scape_ | thanks, i'll give that a go |
| 19:42 | scape_ | considerably faster, almost as fast as arraycopy now |
| 19:42 | scape_ | thanks amalloy |
| 19:42 | dbasch | scape_: btw, isn’t that just aclone? |
| 19:43 | amalloy | dbasch: errrrr, not at all like aclone? |
| 19:43 | dbasch | amalloy: I don’t understand what it has to do with arraycopy then |
| 19:44 | amalloy | he doesn't really want to do arraycopy. he just wants to change array values and didn't understand how arraycopy could be so much faster than using aset |
| 19:44 | dbasch | amalloy: ah, ok |
| 19:44 | scape_ | well I assumed why, the System part clued me in :) |
| 19:51 | Si_ | anyone here ever play around with caribou? https://github.com/caribou/caribou |
| 19:51 | coventry | justin_smith has used it extensively, probably wrote parts of it. |
| 19:52 | justin_smith | coventry: I'm the #2 contributer |
| 19:52 | justin_smith | Si_: any specific question? |
| 19:52 | dbasch | amalloy, scape_ : no matter what you do, arraycopy would be orders of magnitude faster than using aset |
| 19:54 | ivan | has anyone made AOT'ed Clojure code work on RoboVM? RoboVM appears very unhappy with clojure.lang.DynamicClassLoader.defineClass |
| 19:54 | ivan | any suggestions on stripping out Clojure's custom classloader? |
| 19:55 | eflynn | how do you parse xml with clojure |
| 19:55 | Si_ | justin_smith: not in particular, i'm new to clojure and looking for a web framework that would be comparable to flask. would you suggest caribou or something like luminus? |
| 19:56 | scape_ | try http-kit and enlive or similar |
| 19:57 | ivan | Raynes: the submit button on refheap appears to be missing |
| 19:58 | dbasch | eflynn: http://clojuredocs.org/clojure_core/clojure.xml/parse |
| 20:03 | amalloy | ivan: he's trying to cut down on paste inflation by not allowing anyone to paste anything ever |
| 20:04 | amalloy | seriously though, obviously that's broken, but ctrl-enter works to submit while you wait for Raynes to figure it out |
| 20:05 | ivan | thanks |
| 20:05 | justin_smith | Si_: do you want maps of clojure data following a specific schema persisted in a db? if so caribou integrates this nicely and has a web based admin for the data, if not using http-kit / ring directly is likely easier |
| 20:06 | justin_smith | Si_: also caribou uses the db to define pages, which may or may not be useful to you (other approaches typically use code) |
| 20:07 | justin_smith | Si_: these features are present because we developed caribou for usage in a situation where the frontend developers did not use clojure, and we wanted them to be able to define new pages / data models as they needed |
| 20:07 | ivan | so I think my (ns ... :gen-class [namespace] is the only thing calling defineClass which is the thing I can't call on RoboVM, but I need this :gen-class to generate the class that I'm running |
| 20:08 | ivan | is there some way to get the class but not run genclass stuff at runtime? |
| 20:08 | dbasch | ivan: also, if you’re using emacs you can submit directly with this https://github.com/Raynes/refheap.el |
| 20:18 | Si_ | justin_smith: thanks, it looks pretty cool. good to know its being actively developed. |
| 20:28 | amalloy | so dbasch, i thought it would be interesting to benchmark System/arraycopy vs copying with aget/aset |
| 20:29 | dbasch | amalloy: how did it turn out? |
| 20:29 | amalloy | https://www.refheap.com/85060 suggests it's around twice as fast, certainly not "orders of magnitude" |
| 20:29 | amalloy | the jit is, after all, pretty good |
| 20:39 | dbasch | amalloy: indeed, that is surprisingly good |
| 20:39 | amalloy | dbasch: another point of view is that doing it in the vm is surprisingly bad, of course |
| 20:39 | amalloy | since it can't just do a plain memory copy - there's a lot of extra work to do in java compared to c |
| 20:40 | amalloy | making sure the garbage collector knows about all your moved objects, and so on |
| 21:02 | TravisD | I guess a factor of 2 is an order of magnitude, without any other information :P |
| 21:02 | TravisD | </pedantry> |
| 21:04 | dbasch | amalloy_: try it with bytes instead of objects |
| 21:04 | dbasch | TravisD: my guess would have been 10x at least, so I concede amalloy was right on that |
| 21:05 | TravisD | Hehe, yeah, I was just pointing out the silly fact that it depends on how you're counting your orders |
| 21:14 | dbasch | TravisD: with an array of objects I get the same results as amalloy, but with a random byte array I get a 40x difference |
| 21:14 | TravisD | dbasch: I wasn't really following the conversation :) The problem is to clear an array of some length? |
| 21:16 | dbasch | no, it’s to copy arrays using either System/arracopy or aset in a loop |
| 21:16 | TravisD | ah |
| 21:16 | dbasch | I had guessed that arraycopy would be orders of magnitude faster in general, it turns out that it’s only 2x as fast for objects |
| 21:17 | dbasch | I’m trying the special case of bytes and see a difference of 40x though |
| 21:17 | amalloy | i can believe it for bytes, i suppose. you're hinting as ^bytes, i presume? |
| 21:17 | dbasch | I assume that in that case it’s just a memcpy |
| 21:17 | dbasch | amalloy: of course |
| 21:17 | TravisD | This slowdown comes entirely from running on the JVM? |
| 21:18 | dbasch | TravisD: I assume it’s the different optimizations the JIT can do with what it knows |
| 21:18 | TravisD | ah, yeah |
| 21:22 | amalloy | dbasch: a fair bit of spelunking through the jdk source tells me that for byte[] it is indeed just a memmove |
| 21:25 | amalloy | for int[] it looks like a reimplementation of memmove to preseve java's stronger atomicity guarantees which might be violated if memmove were used instead |
| 21:25 | dbasch | amalloy: and for generic object without any further knowledge you’d have to dereference pointers |
| 21:26 | amalloy | i'm not sure i follow |
| 21:26 | dbasch | amalloy: you don’t know that they are all the same type, so you cannot compute the size for one and assume they are all the same |
| 21:27 | dbasch | although you’re copying pointers, never mind |
| 21:27 | amalloy | right |
| 21:32 | Jaood | amalloy_: do you go down to java much for performance reasons? |
| 21:57 | gfredericks | this tools.nrepl middleware-sorting code is impenetrable |
| 21:57 | gfredericks | https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/middleware.clj#L73-129 |
| 21:58 | gfredericks | at the moment I'm in the middle of conj-sorted trying to figure out what on earth |
| 22:02 | gfredericks | (is this not what the rest of you do on a friday night??) |
| 22:05 | technomancy | gfredericks: nope too busy debugging my keyboard |
| 22:06 | gfredericks | nerd. |
| 22:15 | amalloy | Jaood: never |
| 22:16 | amalloy | i write java if the project is already written in java, or if i need to declare an interface or something so that java users can consume objects i build from clojure more easily |
| 22:39 | gfredericks | I think I literally have ghosts in my machine. |
| 22:39 | gfredericks | I have found a reproducible case where changing the whitespace in my code changes the result. |
| 22:39 | hiredman | norton ghosts? |
| 22:39 | TravisD | mmh, I need to watch Ghost in the Shell. |
| 22:41 | gfredericks | maybe it is haunted by cemerick |
| 22:41 | gfredericks | oh nevermind it stopped reproducing. |
| 22:42 | gfredericks | I suppose it could be a cider bug |
| 22:45 | amalloy | gfredericks: probably a failure that's random, and your pattern-hungry human mind associated it with whitespace changes |
| 22:46 | gfredericks | I went back and forth three or four times |
| 22:47 | gfredericks | I've been seeing spook the whole time I've been debugging this damn code, that was just the height of it |
| 23:13 | gfredericks | turns out the thing is jvm-level nondeterministic |
| 23:13 | gfredericks | http://dev.clojure.org/jira/browse/NREPL-53 |
| 23:16 | amalloy | why is it right for foo to be last? |
| 23:20 | gfredericks | last means being first in line to handle messages |
| 23:20 | gfredericks | well actually |
| 23:20 | gfredericks | foo just has to be after session |
| 23:20 | gfredericks | oh snap good point I should check that it does come before in the false cases |
| 23:21 | gfredericks | I had that behavior at the repl, I just neglected to output that much information |
| 23:21 | gfredericks | (in the code I actually posted) |
| 23:21 | gfredericks | well actually |
| 23:22 | gfredericks | since bar requires session |
| 23:22 | gfredericks | I think [bar session foo] is the only sensible ordering |
| 23:22 | gfredericks | but pr-values might make its way in there too so I should still check |
| 23:23 | amalloy | i don't understand the difference between requires/expects. those words are practically synonyms |
| 23:23 | gfredericks | I know! |
| 23:23 | gfredericks | so confusing |
| 23:24 | gfredericks | requires means "I expect this middleware/operation has already touched the message by the time I get to it" |
| 23:24 | gfredericks | expects means the opposite |
| 23:24 | gfredericks | (I expect this will get handled in the future) |
| 23:24 | gfredericks | e.g., if you want to write a middleware to transform eval messages before they get evaled |
| 23:24 | gfredericks | you would :expects #{"eval"} |
| 23:25 | gfredericks | the more correct code is also nondeterministic |
| 23:25 | gfredericks | I'll update the ticket shortly |
| 23:31 | gfredericks | amalloy: updated ticket |
| 23:31 | gfredericks | would be interested in somebody else corroborating the nondeterminism |
| 23:32 | amalloy | gfredericks: is it possible that nrepl is just choosing an ordering at random because it can't satisfy all requirements? like, "eval" is required but not present |
| 23:33 | gfredericks | I don't think it's explicitly random |
| 23:33 | gfredericks | I didn't see any shuffling in the code |
| 23:33 | gfredericks | it might be implicit due to var hash orderings |
| 23:34 | amalloy | right |
| 23:34 | gfredericks | the absence of eval is an interesting theory though |
| 23:34 | amalloy | s/at random/arbitrarily |
| 23:35 | gfredericks | without eval it's all true |
| 23:37 | gfredericks | BUT |
| 23:37 | gfredericks | if I add back eval _and_ a middleware that handles eval |
| 23:37 | gfredericks | it's all false. |
| 23:37 | amalloy | clojurebot: it's |all| false |
| 23:37 | clojurebot | Ack. Ack. |
| 23:38 | gfredericks | clojurebot: all is not |a| verb |
| 23:38 | clojurebot | Ack. Ack. |
| 23:40 | gfredericks | okay I added that as a comment and now I must to bed |
| 23:56 | TravisD | Would it be possible to add metadata to some set of non-pure functions, and then to propagate that impurity metadata to all functions calling the non-pure ones, and so on? |
| 23:58 | amalloy | TravisD: is map pure? |
| 23:58 | TravisD | ah, right, high order functions |
| 23:58 | TravisD | I guess it depends on its arguments :( |