2015-12-17
| 00:29 | owlbird | The jdbc API of clojure will return a list including the count of affected record, it's possible to get a number directly while querying count/sum with :result-set-fn first, but what's best way to get the number of affected records while updating? |
| 00:30 | owlbird | I write (first (jdbc/xxx)), which seems ugly, and the result-set-fn was not supported by jdbc/update serials API |
| 02:38 | kenrestivo | does something like this already exist? https://www.refheap.com/112791 |
| 02:39 | danneu | owlbird: `with rows_affected as (UPDATE ... RETURNING 1) select count(*) from rows_affected` |
| 02:39 | danneu | idk |
| 03:10 | keep_learning | Hello all |
| 03:11 | keep_learning | I am trying to parse web page but the data part is mostly rendered by javascript |
| 03:11 | keep_learning | so when ever I am downloading the page it contains javascript but not the data |
| 03:11 | keep_learning | Could some one please tell me how to simulate browser behaviour |
| 03:11 | keep_learning | to render the data |
| 05:45 | TEttinger | Sorella! I remember you from livescript! I can't remember if you've used clojure before |
| 05:46 | Sorella | TEttinger: I've been using Clojure for a couple of years, did a few projects at work with it (including a VM for a live programming platform running a Self dialect, which was fun) |
| 05:46 | TEttinger | cool! |
| 05:46 | TEttinger | I've been uh... mostly writing java |
| 05:47 | TEttinger | trying to avoid helsinki affliction |
| 05:47 | TEttinger | stockholm syndrome I've got plenty |
| 06:53 | lkollar | keep_learning: you can use phantomjs to evaluate javascript |
| 06:53 | lkollar | http://blog.zolotko.me/2012/12/clojure-selenium-webdriver-and-phantomjs.html |
| 07:53 | Gonzih | Hi guys, we are organizing 1 day clojure conference in Amsterdam! more info here: http://clojuredays.org |
| 07:58 | beaky | hello |
| 07:58 | beaky | wow |
| 08:09 | Gonzih | so yeah, it's free event btw :) |
| 08:14 | lokien_ | Hello! What exercises do you guys recommend? I'm bored reading books all the time |
| 08:15 | shoky | lokien_ https://www.4clojure.com/ |
| 08:16 | lokien_ | Thank you shoky |
| 09:00 | oracle | what's the meaning of the last parameter (where ...)? |
| 09:00 | oracle | (alter-var-root (var *driver*) |
| 09:00 | oracle | (constantly new-driver) |
| 09:00 | oracle | (when (thread-bound? (var *driver*)) |
| 09:00 | oracle | (set! *driver* new-driver))) |
| 09:01 | oracle | that (when ...) is a paramter, but it doesn't return anything. |
| 09:13 | gfredericks | hiredman: oh that was more succinct than I expected; thanks |
| 09:32 | oracle | I defined a var like (def firefox_brower some_specificiation_for_firefox) |
| 09:32 | oracle | and used core.aysnc, and then I found the code of (def firef...) run twice, |
| 09:33 | oracle | since I saw two firefox stared up |
| 09:33 | oracle | since core.async could kick off multiple threads, so will (def ...) run for each thread? |
| 09:34 | oracle | If I run lein repl, then I only saw one firefox. |
| 09:35 | oracle | but if run lein run, it will startup 2 firefox. But the main function doesn't call any code to startup firefox, only some code for core.async |
| 10:21 | benjyz1 | hello |
| 10:21 | benjyz1 | are there are any pure clojure TCP libraries? |
| 10:21 | benjyz1 | or anybody aware of work in this area? |
| 10:23 | beaky | hello |
| 10:24 | prateekbhatt | Hi I am trying to setup ac-cider with cider |
| 10:24 | prateekbhatt | I keep getting the error (error "Not a nREPL dict object: rem") |
| 10:24 | prateekbhatt | on trying to autocomplete on any keyword |
| 10:27 | dxlr8r | say I have go-loop with async/timeout in it. the loop runs for ever. is there any way to stop if from repl? or do I need to implement some logic inside the loop in order to stop it? |
| 11:20 | socksy | in the example projects for sente, the defmethods for a multimethod are defined inside of a (do) form. Is this a thing? What does it do differently from defining at the top level? |
| 11:54 | dxlr8r | try and see :) I am looking at sente to atm |
| 11:58 | socksy | I mean, I am trying it, and not seeing a difference |
| 12:03 | dxlr8r | yeah, I looked at that block to. maybe he had more stuff in the block before and removed it |
| 12:03 | dxlr8r | back then I might had made sense, but not now |
| 12:05 | socksy | but even if he had more stuff in there, it doesn't make any sense to put it in a do |
| 12:05 | socksy | since it was only definitions |
| 12:07 | dxlr8r | true |
| 12:07 | dxlr8r | now that I look at it, it actually makes sense |
| 12:08 | dxlr8r | I looked upon my modified version, where I had split the cljx file |
| 12:09 | dxlr8r | since it's cljx he uses do in order to not type #+cljs in front of all the domethods |
| 12:09 | dxlr8r | reads better to I think, you know right away that all this is for cljs only, not clj |
| 12:11 | socksy | aha, i'm reading the boot-sente example, so in that case it was probably kept from that |
| 12:11 | socksy | (where clj and cljs are split) |
| 12:12 | dxlr8r | :) |
| 12:48 | justin_smith | oracle: generally you shouldn't ever have side effects at the top level - for example that def would start up firefox while building an uberjar or running your tests (probably not things you want) |
| 12:52 | justin_smith | oracle: a common way to deal with this are to use an atom or delay or promise that will hold the firefox-browser value, then an init function (called in your -main) that actually starts up firefox and connects your handle to the container |
| 14:10 | devth_ | for a long time i've used ns-resolve to dynamically look up expected functions in two namespaces (e.g. irc and slack - they are chat adapters). should i use protocols and deftype instead? then I can create instances of the type in each instance and dispatch based on that. right? i've avoided protocols for years :/ |
| 14:11 | devth | *in each namespace, and register them in some known place (i.e. swap an atom) |
| 14:11 | justin_smith | yes, protocols are the cleaner way to do this |
| 14:12 | devth | thought so, just wanted to make sure i wasn't misunderstanding. thanks justin_smith |
| 14:12 | justin_smith | and yeah, you could use deftype, or defrecord, but for something which will only ever have one instance it can be easier to just use reify |
| 14:13 | devth | wouldn't irc and slack each have their own instance? |
| 14:14 | justin_smith | devth: the idea with protocols is you can use them where you want the runtime app to be able to provide you with some thing, but you know you can do specific defined operations on that thing even if its definition isn't accessible to your code. You already do this with IFn probably - eg. map doesn't need to have access to your functions definition, the fact that it is IFn and because of that you can call it is all the map really needs :) |
| 14:14 | devth | something like (deftype Adapter [name] ...) (def slack (Adapter. "slack") (def irc (Adapater. "irc") |
| 14:14 | justin_smith | devth: right irc, and slack, would each be a seperate reification |
| 14:14 | justin_smith | devth: my point was that you wouldn't have two ircs, or two slacks |
| 14:15 | devth | oh, right |
| 14:15 | justin_smith | (but if you would have that, yeah, use deftype or defrecord instead of reify) |
| 14:15 | devth | got it. thx! |
| 14:16 | justin_smith | devth: but yeah, it's really not more complicated than how map can use anything that's an IFn |
| 14:16 | devth | right. i was always afraid it was too java-y or something :) |
| 14:16 | justin_smith | devth: what separates this from java is that concrete inheretence is not possible |
| 14:17 | justin_smith | it's really closer to how haskell does it (and java just did a half ass version of what haskell was already doing anyway) |
| 14:17 | devth | are you referring to the ad-hoc nature of it? |
| 14:18 | devth | and i'm guessing you're referring to haskell's type classes |
| 14:18 | justin_smith | devth: the fact that haskell had parametric polymorphism via typeclasses, and java copied that but mixed it with some grotesque OO garbage |
| 14:18 | justin_smith | what clojure does is closer to the haskell version (on top of java's vm, of course) |
| 14:18 | devth | right |
| 14:19 | justin_smith | right |
| 14:19 | devth | and then there's scala |
| 14:19 | justin_smith | maybe other folks have something nice to say about scala, I'll hold back on that topic |
| 14:20 | devth | i use it but i don't mind bashing :) |
| 14:45 | ghost_ | Hey, what are multimethods and what are they for? I tried to read about them on clojure.org but I don't understand anything |
| 14:52 | postpunkjustin | ghost_: they let you do function dispatch on whatever you want. Similar to how some other languages let you overload functions based on the type of the argument, but more flexible. |
| 14:53 | ghost_ | postpunkjustin: so, different actions on different arguments? on steroids? |
| 14:54 | xemdetia | ghost_, it's like having in an OO language an .add(String) and an .add(Int) for the same object but with steroids |
| 14:54 | ddellacosta | ghost_: I think the top answer here is pretty good: http://stackoverflow.com/questions/8070368/clojure-multimethods-vs-protocols |
| 14:54 | ghost_ | xemedetia: shh, I don't know OOP |
| 14:54 | ddellacosta | if you are just dispatching on type, a lot of the time using protocols is the way to go |
| 14:54 | ghost_ | xemdetia* |
| 14:55 | xemdetia | ghost_, its like having a struct with an enum defining type and a union of multiple datatypes, and through a main dispatch function of add(struct) you call add_int(struct) and add_string(struct) to do what you need to do. |
| 14:55 | ddellacosta | mikera's answer is worth reading too on that page |
| 14:55 | xemdetia | :) |
| 14:55 | ghost_ | xemdetia: shh, I don't know C |
| 14:55 | xemdetia | ghost_, use lots of gotos |
| 14:56 | ghost_ | xemdetia: oh, it's clear now |
| 14:56 | ghost_ | ddellacosta: reading |
| 14:56 | ddellacosta | :-p |
| 14:56 | ghost_ | nah, I'm just smiling |
| 14:57 | ghost_ | "but if you need to dispatch based on the phase of the moon as seen from mars then multimethods are your best choice." |
| 14:57 | ghost_ | yeah, very helpful, ddellacosta |
| 14:57 | ddellacosta | ghost_: great |
| 14:58 | ghost_ | nvm, I'll just read it. thanks for help |
| 15:03 | ghost_ | ddellacosta: last question - so, I create a function, then write that multimethod which depends on output of that first function. yeah? |
| 15:05 | ddellacosta | ghost_: sorry, are you asking about the dispatch function? |
| 15:05 | dxlr8r | say I have go-loop with async/timeout in it. the loop runs for ever. is there any way to stop if from repl? or do I need to implement some logic inside the loop in order to stop it? |
| 15:05 | ghost_ | ddellacosta: it's in the mikera's answer you linked me |
| 15:05 | dxlr8r | i tried close! |
| 15:06 | ddellacosta | ghost_: i.e. what is "balance-available?" doing? |
| 15:06 | musteresel | Hi. I need to write some simulation software. This simulation is going to be controllable by my students. As they only know Java, I thought about providing some interfaces for them to implement. On the other hand, I want to implement the simulation in clojure for obvious reasons. Is there a "standard" way of doing so? I know Java/Clojure interop is excellent, what I'm looking for is an "approach" such that the students will only s |
| 15:06 | musteresel | their interfaces (for example an interface IX) and a "Simulation" class such that in their code they'll have something like Simulation s = new Simulation(new IX() { /* Implement stuff */ }); s.run(); but won't have to deal with any clojure stuff. |
| 15:06 | ddellacosta | but yeah, that's your dispatch function |
| 15:08 | justin_smith | musteresel: easiest is probably to make your interface in java, tell them to implement based on that, and then write clojure code that uses objects of that interface |
| 15:08 | ghost_ | ddellacosta: generally, I know what they're doing. but I don't know if I got the concept correctly |
| 15:09 | ghost_ | it's just as calling different functions depending on other function's output? but cleaner? |
| 15:10 | ghost_ | like (if (true? withdraw) (call-first-function params) (call-second-function params))? |
| 15:10 | justin_smith | ghost_: the dispatch function decides which of your implementation functions gets called, and you don't need to make a big case statement or whatever, yeah |
| 15:10 | justin_smith | or if |
| 15:11 | ghost_ | justin_smith: that's what I meant. thanks a lot |
| 15:12 | musteresel | justin_smith: I'm a bit concerned about immutability / mutability. Writing the simulation in idiomatic clojure I'm probably going for a purely functional approach. But then, using for example a plain java array (that needs to be rebuild in each simulation step) is going to be a costly thing. Can I somehow take advantage of clojure's persistent data structures without exposing them? Do they, for example, implement Java Interfaces l |
| 15:12 | musteresel | say Collection? (I guess not) |
| 15:13 | xemdetia | musteresel, only if you give them an interface to that resource |
| 15:14 | xemdetia | if anything it sounds like what justin_smith described - students have to implement an interface, and if they need resources from the system you should provide another interface that you implement that tells them what they can ask for, and you can write up a simple java class to implement that interface and provide dummy data |
| 15:15 | jjttjj | uuhhh what's the word(s) to describe the (bad) use of defining top level vars in a library, for example (def)ing a connection var right in a database library (instead of leaving that for the user to do) |
| 15:15 | jjttjj | too much top-level state? |
| 15:15 | xemdetia | jjttjj, http://dl.acm.org/citation.cfm?id=953355 |
| 15:15 | xemdetia | probably this |
| 15:15 | ystael | musteresel: The basic Clojure data structures do implement the Java interfaces you want them to, for instance, APersistentVector implements Iterable, List, Comparable, Serializable among others |
| 15:16 | jjttjj | xemdetia: thanks! |
| 15:19 | musteresel | ystael: They do? That's awesome, I guess I can then just give them an interface (like xemedita suggested) wiht a method like Iterable<Data> getDataObjects(). I'll try that, it should do the trick :) |
| 15:19 | musteresel | Thank you all :) |
| 15:43 | cap10morgan | Anyone else seeing “Args out of range: -1, -1” errors in Emacs when you have a CIDER REPL running and you hit Enter to create a new line in a Clojure buffer (and then your code doesn’t auto-indent; the point stays at column 0)? Latest versions of all the things. |
| 15:50 | justin_smith | cap10morgan: in emacs "Args out of range: -1, -1" is a sign that some command wants to access a range of the buffer contents, but the range is not findable (you may already know this) |
| 15:50 | cap10morgan | justin_smith: I did not know that, thanks. |
| 16:05 | justin_smith | cap10morgan: also, did you just update recently? |
| 16:06 | cap10morgan | justin_smith: yes, I'm running CIDER 0.10 (and the latest versions of pretty much everything else) |
| 16:06 | justin_smith | cap10morgan: because cider often has the problem of things breaking if you try to update in place, so the best options are to completely uninstall then install the newer version, or to delete all your elc files |
| 16:06 | cap10morgan | justin_smith: ah, sure. good idea, I'll give that a try. |
| 17:12 | sdegutis | Is it possible to use ClojureScript with advanced-optimization enabled inside a Clojure process without actually touching the real filesystem for any of the compilation, and end up with a single string representing the entire JavaScript program after advanced compilation? |
| 17:24 | benjyz1 | hi. what's the best way to update a map? |
| 17:25 | justin_smith | benjyz1: what kind of update are you trying to do? usually you want assoc. But, to be pedantic, you can't change a map, you can only make a new map derived from it. |
| 17:26 | benjyz1 | {:a b} => {:a c} |
| 17:26 | benjyz1 | {:a :b} => {:a :c} |
| 17:26 | benjyz1 | ,(def m {:a :b}) |
| 17:26 | justin_smith | ,(assoc {:a :b} :a :c) |
| 17:26 | clojurebot | eval service is offline |
| 17:26 | clojurebot | eval service is offline |
| 17:26 | blischalk | Is it possible in prismatic schema to define a schemaless map? E.g In compojure-api I want to say that I want to accept a map but that the structure of the map can be anything. |
| 17:31 | justin_smith | blischalk: perhaps something like {s/Any s/Any} |
| 17:31 | one | how can i use a variable as an idex for a map? |
| 17:31 | justin_smith | one: by using a variable as an index for a map |
| 17:32 | justin_smith | ,(def idx :a) |
| 17:32 | clojurebot | #'sandbox/idx |
| 17:32 | one | i mean how do i pass it |
| 17:32 | justin_smith | ,(assoc {} idx 0) |
| 17:32 | clojurebot | {:a 0} |
| 17:32 | justin_smith | ,(get (assoc {} idx 0) idx) |
| 17:32 | clojurebot | 0 |
| 17:32 | justin_smith | ,{idx 0} |
| 17:32 | clojurebot | {:a 0} |
| 17:33 | one | if x is my map, {:abc 123}, and y = "abc" |
| 17:34 | felixn | hey is there a reason I would use (keyword 'foo) instead of :foo? is it there so I can escape a string if it's not written? |
| 17:34 | justin_smith | ,(get {:abc 123} (keyword "abc")) |
| 17:34 | clojurebot | 123 |
| 17:34 | one | than you |
| 17:34 | amalloy | one: are you sure you want the map to have keyword keys, if you're looking up strings in it? can you just make the map have strings? |
| 17:34 | one | thank |
| 17:35 | justin_smith | felixn: (keyword 'foo) is weird |
| 17:35 | justin_smith | amalloy: excellent point |
| 17:35 | one | its something im getting from an elastic search response |
| 17:35 | amalloy | people so often seem to think only keywords are valid map keys |
| 17:35 | one | it has to be grouped by a certain field that isnt determined |
| 17:36 | justin_smith | amalloy: see also, doing a tree walk and converting every string key to a keyword key, when you only access one value in the map |
| 17:36 | amalloy | i haven't seen that one much |
| 17:37 | justin_smith | amalloy: cargo culting while using json apis |
| 17:37 | TEttinger | ,(defn random-string [] (apply str (repeatedly (+ 2 (rand-int 6)) #(char (+ (int \a) (rand-int 26)))))) |
| 17:37 | clojurebot | #'sandbox/random-string |
| 17:37 | TEttinger | ,(random-string) |
| 17:38 | clojurebot | "yorqj" |
| 17:38 | TEttinger | ,(keyword (random-string)) |
| 17:38 | clojurebot | :ygsg |
| 17:38 | TEttinger | ,(keyword (random-string)) |
| 17:38 | clojurebot | :id |
| 17:38 | blischalk | justin_smith: It seems to give “Bad explicit key: schema.core.AnythingSchema” |
| 17:38 | TEttinger | ha nice |
| 17:38 | justin_smith | blischalk: oh, I'm not sure what the answer is there |
| 17:38 | justin_smith | blischalk: is there a s/Map? |
| 17:39 | blischalk | justin_smith: doesn’t seem to be |
| 17:40 | blischalk | justin_smith: “No such var: s/Map” |
| 17:41 | justin_smith | blischalk: I figured it out in my repl |
| 17:41 | blischalk | justin_smith: Awesome! What’d ya find? |
| 17:42 | justin_smith | blischalk: spoke too soon! |
| 17:42 | justin_smith | but (s/check {} {}) works, haha |
| 17:44 | justin_smith | blischalk: wait - the first thing I suggested totally works (s/check {s/Any s/Any} {:a 0 :b 1}) -> nil |
| 17:46 | justin_smith | blischalk: that checks, and as expected the one way to make that check fail is to provide an arg that is not a map |
| 17:47 | blischalk | justin_smith: using (s/defschema MySchema |
| 17:47 | blischalk | {:query {s/Any s/Any} |
| 17:47 | blischalk | :some_id java.lang.Long |
| 17:47 | blischalk | :foos {s/Any s/Any} |
| 17:47 | blischalk | :id String}) |
| 17:47 | blischalk | schema.core in compojure-api is saying “Bad explicit key: schema.core.AnythingSchema” |
| 17:48 | justin_smith | blischalk that schema definition compiles here |
| 17:49 | blischalk | justin_smith: It compiles but when I visit the swagger ui it throws a runtime exception |
| 17:49 | justin_smith | blischalk: I am using schema 0.4.3, what's your version? sounds like a swagger bug |
| 17:49 | Deraen | blischalk: Use {s/Keyword s/Any} |
| 17:50 | felixn | is there an idiomatic way to create enums? I googled and someone said use keywords, but now I want to parameterize the data type (:foo [1 2 3]) is no good XD I guess I could use a list/map, but is that idiomatic? |
| 17:51 | justin_smith | felixn: clearly you don't mean jvm enums |
| 17:51 | justin_smith | felixn: why not [:foo [1 2 3]] ? |
| 17:51 | felixn | really just algebraic data types like haskell |
| 17:52 | felixn | ok yea, list works then! |
| 17:52 | justin_smith | felixn: vector |
| 17:52 | amalloy | felixn: there's not really good support for ADTs |
| 17:52 | justin_smith | tis true |
| 17:53 | blischalk | justin_smith: [prismatic/schema "1.0.4"] is what compojure-api is using currently |
| 17:53 | justin_smith | blischalk: yeah, I had no idea I was using such an old version... |
| 17:53 | justin_smith | one moment, going to see how things look when I bump my version |
| 17:55 | justin_smith | blischalk: {s/Any s/Any} is still a valid schema that passes for any hash map (including empty) as of 1.0.4, I just upgraded |
| 17:56 | blischalk | Deraen: That seems to work! |
| 17:56 | blischalk | Thanks justin_smith and Deraen. |
| 17:56 | ridcully | (inc justin_smith) |
| 17:57 | justin_smith | blischalk: https://www.refheap.com/112831 |
| 17:57 | ridcully | that reboot every second seems not that much to be on the workind side of things? |
| 17:57 | justin_smith | ridcully: I'm not sure where things ended up with lazybot |
| 17:58 | ridcully | i have a genral idea i don't like to share |
| 17:58 | justin_smith | blischalk: seems like compojure-api is doing something unusual there |
| 17:58 | Deraen | Ring-swagger doesn't currently support s/Any as key, I don't remember if there's specific reason for it but the problem is schema.core/explicit-schema-key call here: https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/json_schema.clj#L240 |
| 17:59 | justin_smith | Deraen: thanks! good to have that info |
| 18:00 | justin_smith | Deraen: I guess they assume the keys would really need to all be keywords, which in that domain could make sense |
| 18:02 | Deraen | Yeah, at leason on JSON the keys are always keywords (or strings) so s/Any doesn't make that much sense. Anyway, if someone has usecase for s/Any as schema key, an issue is welcome. |
| 18:04 | justin_smith | yeah, {{:foo 0} :a} isn't going to work in json, so it makes sense there |
| 18:05 | Deraen | Unfortunately s/Str doesn't work as key either and it probably should |
| 18:07 | Deraen | Ah, s/Keyword works because it's defined as (pred keyword?) and ring-swagger filters predicates out. It should probably do the same for classes. |
| 18:20 | rbxbx_ | Has anyone here used mcohen01's amazonica lib for dynamodb? Specifically performing a scan query with key-conditions. |
| 18:20 | rbxbx_ | Having a difficult time sussing out the exact sort of heterogenous map it's expecting ;) |
| 18:20 | oracle | automate.core=> (get-thread-bindings) |
| 18:20 | oracle | |
| 18:20 | oracle | StackOverflowError clojure.lang.PersistentHashMap$BitmapIndexedNode.index (PersistentHashMap.java:677) |
| 18:20 | oracle | |
| 18:20 | oracle | why called get-thread-biddings failed? |
| 18:24 | rbxbx_ | oracle: (take 1 (get-thread-bindings)) ;; => ([#'clojure.core/*err* #object[java.io.PrintWriter 0x47c1094 "java.io.PrintWriter@47c1094"]]) |
| 18:24 | rbxbx_ | It looks like it's returning an infinite sequence so you'll have to grab the part you want. |
| 18:26 | oracle | get-thread-biddings is the build-in function in clojure, why it return infinite sequence? it get the bidding vars, the vars should be finite, right? |
| 18:29 | amalloy | *1 is a thread-binding referring to the last thing returned by the repl |
| 18:29 | amalloy | if *1 is the result of get-thread-bindings, it's an infinitely self-recursive data structure |
| 18:30 | amalloy | which is fine, but when you try to print it you'll run out of stack |
| 18:40 | oracle | how to use add-watch for a var? |
| 18:40 | oracle | since a var is a per thead data, how could know which thread change? |
| 19:06 | aaelony__ | Is anyone familiar with converting a msgpack file to a tab delimited file? I'm looking at [clojure-msgpack "1.1.2"] and trying (-> testfile io/input-stream java.io.DataInputStream. msg/unpack-stream), but instead of seeing data for my file, it returns 31... |
| 19:07 | aaelony__ | https://github.com/edma2/clojure-msgpack/blob/master/src/msgpack/core.clj |
| 19:11 | justin_smith | oracle: I wonder if your add-watch can check which thread it is in when it gets called? not sure, I've never tried that combination of features |
| 20:02 | xeqi | I've been profiling some code and its basically 93% hashCode / 7% PersistantHashMap.cloneAndSet related to a deftype being used as keys in a hashmap. After implementing IHashEq and caching .hashcode in a volatile it gets to 66 % hashCode / 33% PersistantHashMap.cloneAndSet |
| 20:02 | xeqi | Are there any guides to implementing a good/fast hashcode for use in PHMs? or any other techniques around optimizing this area? |
| 20:03 | xeqi | * for use as objects as keys in PHMs |
| 20:03 | TEttinger | wowza |
| 20:03 | xeqi | thats what IRC is for right? harder, esoteric questions :p |
| 20:04 | TEttinger | I'd guess looking up bob jenkins' hashing page would help, maybe not for JVM stuff |
| 20:04 | TEttinger | what kind of stuff are you hashing? |
| 20:05 | xeqi | just a deftype. See LVar in https://github.com/xeqi/aurelius/blob/master/src/aurelius/unify.clj |
| 20:07 | TEttinger | my first instinct is that having any fn named . is a bad idea |
| 20:07 | TEttinger | no idea if it interoperates with .hashCode |
| 20:07 | TEttinger | ,(macroexpand '(.hashCode "hey")) |
| 20:08 | clojurebot | (. "hey" hashCode) |
| 20:10 | xeqi | haha, that hasn't been a problem yet. but fair point about the expanded interop form |
| 20:10 | xeqi | I might end up doing something more along the lines of core.logic's LCons later, but was trying that out for now |
| 20:11 | TEttinger | so here's how flatland's ordered maps do their hashing https://github.com/amalloy/ordered/blob/5c07c3a72d476f19818eeffe4a07afdb63b0bbed/src/flatland/ordered/map.clj#L85-L92 |
| 20:12 | TEttinger | not the type hints, use of unchecked and bitwise operations, and not relying on the default (slow) .hashCode method of objects |
| 20:12 | TEttinger | *note the |
| 20:28 | slester | hey there |
| 20:29 | slester | are there any places that one could help develop / contribute to clojure? |
| 20:38 | amalloy | TEttinger, xeqi: the stuff in flatland/ordered is just direct theft from clojure.core/hash-nordered-coll |
| 20:38 | amalloy | since i wanted it to work in versions of clojure prior to that function's addition |
| 20:39 | amalloy | and i think hashing the map itself is not actually interesting to xeqi anyway, who wanted to know how to create key objects whose hashes are good |
| 21:03 | xeqi | its semi-relevant, but since I'm not making container objects its less so. |
| 21:05 | xeqi | If I just make a global counter and inc it for each one, providing them each with unique (but linear) hashes, it ends up being 10% faster or so, and then 99% of time is in PHM/cloneAndSet |
| 21:05 | xeqi | so either I can't get much better without changing datastructures, or the visualvm sampler is not effective |
| 21:06 | xeqi | or pruning the call tree somehow |
| 21:29 | socksy | i have a cyclic dependency, anyone feeling up to suggesting some refactors? |
| 21:30 | socksy | using danielsz's system library, i have a defsystem in a systems NS |
| 21:30 | socksy | it has a DB, Sente, HTTP Kit |
| 21:31 | socksy | the second two things are depended upon a NS "server", which has an event handler that's needed to set up Sente |
| 21:31 | socksy | one of the sente events is to parse something, this is in a namespace "parser" |
| 21:32 | socksy | the parser needs access to the DB, which is in "systems" |
| 21:32 | socksy | so i have parser -> systems -> server -> parser |
| 21:32 | socksy | (server's event handler is calling the parser) |
| 21:33 | socksy | short of scrapping system altogether, or putting everything in one NS, I can't see a way around it currently |
| 21:33 | futuro | socksy: what about pulling the db code out into it's own namespace? |
| 21:33 | socksy | but then it doesn't get reloaded with the system, right? |
| 21:34 | socksy | but yeah, that's the best idea i've got so far |
| 21:34 | socksy | i suppose i can make a separate persistent state system, and treat the sente/http-kit as a system for web interaction |
| 21:35 | futuro | so the dep graph would just have the things that depend on the db declaring as such |
| 21:35 | futuro | and the db has it's own lifecycle, no? |
| 21:36 | futuro | so that triggering a restart on a higher level system causes a restart on the things it depends on |
| 21:37 | socksy | mm |
| 21:37 | clojurebot | excusez-moi |
| 21:37 | socksy | i guess i don't really get systems well enough yet :) |
| 21:38 | futuro | that'd be my recommendation. Split out the code so that each ns does one thing, then use the system library to declare your dependencies so everything gets loaded in the right order |
| 21:38 | fierycatnet | Can someone help me out with simple Reagent example. I have this code from their page http://pastebin.com/u6JK1ZvE but I can't figure out how to render the main BMI component in home-page |
| 21:39 | socksy | thanks futuro :) |
| 21:40 | futuro | np, best of luck |
| 21:41 | futuro | I am really jazzed about om.next so far |
| 21:42 | futuro | I highly recommend anyone on the fence about checking it out to give it a look |
| 21:42 | fierycatnet | any open source projects use it yet? I'd like to check out the whole SPA to study. |
| 21:43 | futuro | fierycatnet: There are some examples using om.next, but I'm not sure about anything OSS and large using it |
| 21:44 | futuro | https://github.com/swannodette/om-next-demo |
| 21:44 | futuro | that comes to mind |
| 21:46 | fierycatnet | Cool, I'll look into it later if I get my reagent page to work. |
| 21:47 | futuro | I know mfikes has tied it into ambly/React Native, so he got the autocomplete demo to run on his iphon |
| 21:47 | futuro | iphone* |
| 22:00 | socksy | nooo i can only have one system at a time |
| 22:04 | felixn | (logic/run* [q] (logic/== q (lvar "foo" false))) <-- hey, anyone know if it's possible to keep track of original names of variables after solving? |
| 22:09 | felixn | https://gist.github.com/anonymous/f4551c7afa01f4f892dd <-- this is the only approach i've came up with, then I iterate through the result reapplying the old names (only the first if a variable is shared), and if there's a new variable I generate a new name. it takes a lot of work! |
| 23:09 | slester | are there things that need to be done for clojure that a newb could do? |