2016-05-23
| 00:03 | tolstoy | If you use plumatic/schema s/defrecord to apply schemas to the data in the record, why doesn't it break when you supply bad values? |
| 00:04 | tolstoy | Oh, there it is in the doc string. |
| 00:17 | tolstoy | The record itself is the schema. |
| 00:30 | jasonmason | feminist put in her place. https://www.youtube.com/watch?v=R3HvI5dJuzo |
| 00:35 | dysfun | ... |
| 00:43 | tolstoy | Hm. roomkey/annotate doesn't support map->Record constructor type checking. |
| 00:45 | will_sm | Is EDN used outside of clojure/clojurescript? |
| 00:46 | dysfun | not really, but there are libraries for other langs |
| 01:16 | tolstoy | If you had a table (entity, attribute, value, time) and never deleted stuff, how would you query for all the attributes for a given entity, limiting to the latest time? |
| 01:17 | tolstoy | I mean, you know, for a dirt poor man's hacky misunderstood semblance of a kind of datomic like thing? |
| 01:17 | dysfun | what is it in? |
| 01:17 | tolstoy | postgres |
| 01:18 | dysfun | haha. building datomic-like on postgres atm |
| 01:18 | tolstoy | Or, well, h2, actually. But I'm just kinda wondering. |
| 01:18 | dysfun | gimme a minute to write a postgres query |
| 01:18 | tolstoy | First thought is just punt, load all the stuff into memory, then filter out. ;) |
| 01:18 | dysfun | lol |
| 01:19 | tolstoy | Normally, I just start writing a query and let the failure drive google searcher until I know how to ask the right question. |
| 01:21 | dysfun | select eavt.a from eavt where eavt.e = ? group by eavt.a order by max(eavt.t) |
| 01:21 | dysfun | have not tested! |
| 01:21 | dysfun | order by eavt.t desc, probably |
| 01:21 | dysfun | i haven't been up long, sorry, but i hope it helps |
| 01:22 | tolstoy | That looks surprisingly simple. Pays to work with a DB more than for a few weeks every couple of years. |
| 01:23 | dysfun | hah |
| 01:23 | dysfun | yeah, i think postgres actually probably is quite alright for a datomic-like |
| 01:24 | tolstoy | I've never used group by without a count(*) or similar. Interesting. |
| 01:24 | dysfun | well the next trick that comes to mind is DISTINCT ON |
| 01:24 | dysfun | so many ways to drive a db |
| 01:24 | tolstoy | Yeah. |
| 01:26 | tolstoy | "Find all the latest attribute versions of an entity." But also need some way to register retractions, I guess. Huh. |
| 01:26 | dysfun | you may wish to just postfilter |
| 01:26 | dysfun | but actually that query may not return it all |
| 01:26 | dysfun | yeah, fun fun |
| 01:32 | tolstoy | Captain Hindsight: A project I helped maintain for a bit could have used an EAV (at least) db. |
| 01:32 | tolstoy | Lots of "variant" data types: a thing, a subclass of a thing with extra attrs, etc, etc. |
| 01:32 | dysfun | there is an EAV database for pg, just not an EAVT one |
| 01:33 | tolstoy | They modeled it using different tables to add on extra bits, tied together with a reference table and custom OIDs, etc. |
| 01:33 | tolstoy | Super had to piece together as a DB in and of itself. |
| 01:33 | dysfun | oh yes, seen lots of those |
| 01:33 | tolstoy | s/had/hard/ |
| 01:36 | dysfun | wow, it's been ages since i checked out an svn repo |
| 01:36 | dysfun | i am of course using git-svn... |
| 01:36 | tolstoy | My little toy project replaces entities, so I can't really test this history stuff. |
| 01:36 | dysfun | maybe you should just wait for me to finish my project then? ;) |
| 01:37 | tolstoy | Yep. |
| 01:37 | dysfun | wow. this sourceforge project has way more revisions than i thought it would |
| 01:37 | dysfun | it's a test library written in C that something i want uses |
| 07:16 | pythys | Hi everyone. I'm having some difficulty understanding the REPL integration with projects. If I do something like "lein repl" inside a project, what is the difference from doing it outside the project? |
| 07:18 | pythys | Does anything get loaded by default? |
| 07:25 | dysfun | if you've set a nems |
| 07:25 | dysfun | namespace in your project.clj that will be loaded |
| 07:26 | dysfun | in :repl-options |
| 07:26 | dysfun | otherwise it's just all your dependencies will be on the classpath |
| 07:47 | pythys | hi dysfun, so when I open a certain file in a project, how can I experiment with it in the repl? |
| 07:47 | pythys | do I have to (use thefile)? |
| 07:49 | dysfun | i prefer require, but basically yes |
| 07:49 | dysfun | and you'll need to quote thefile: 'thefile |
| 07:59 | pythys | dysfun: ok great |
| 07:59 | pythys | Another question, what is the fastest way to understand where a function came from |
| 08:00 | dysfun | if you use :as in require, it should be pretty clear |
| 08:00 | dysfun | otherwise see if it's in clojure.core (doc clojure.core/name), otherwise look through the (:use) in the ns form |
| 08:01 | dysfun | you can use the same trick with doc for each namespace |
| 08:01 | pythys | I see |
| 08:01 | dysfun | and if your repl supports autocomplete (like the lein one), you can hit tab to get completion and eliminate names quickly |
| 08:01 | pythys | and exploring packages? I see for example that (all-ns) does not help much |
| 08:01 | dysfun | define 'package' |
| 08:01 | pythys | (dir package) lists them which is nice |
| 08:02 | pythys | oh I mean just namespaces I guess |
| 08:02 | dysfun | ok |
| 08:02 | dysfun | well tbh i mostly read the README.md or the docs |
| 08:02 | pythys | so (dir clojure.core) |
| 08:02 | pythys | dysfun: so you're always in some website checking the API docs? right? |
| 08:02 | dysfun | yes, the clojure cheatsheet |
| 08:02 | dysfun | http://clojure.org/api/cheatsheet |
| 08:03 | dysfun | i also keep a repl open so i can answer questions even when i'm not writing clojure :) |
| 08:04 | pythys | dysfun: ok, so the REPL is always relative to your current directory |
| 08:04 | pythys | and the way you explor files is with (use,,,) or (require,,,) |
| 08:04 | dysfun | with lein, yes |
| 08:04 | pythys | and I assume you should always be in the lein project's root directory |
| 08:04 | dysfun | and i tend to require with :as and use the tab key in the repl to check them |
| 08:05 | pythys | ok, good tip |
| 08:05 | pythys | tab completion really helps |
| 08:05 | dysfun | yup |
| 08:05 | pythys | if you have 10 files calling each other or requiring each other somehow |
| 08:05 | pythys | and I just (require oneofthem) |
| 08:06 | dysfun | all of them will be required as you'd expect |
| 08:06 | pythys | does it automatically pull the rest in? |
| 08:06 | pythys | ok I see |
| 08:06 | dysfun | however, caveat! |
| 08:06 | pythys | yeah, shoot? |
| 08:06 | dysfun | if you need to *reload* a namespace, you do e.g. (require '[foo.bar as fb] :reload) |
| 08:06 | dysfun | otherwise, it will silently do nothing |
| 08:06 | pythys | when should you reload? |
| 08:06 | dysfun | :reload will *not* reload all the dependent modules |
| 08:06 | dysfun | :reload-all will |
| 08:07 | dysfun | when you know that you have changed some code and want to play in the repl to see if it's fixed |
| 08:07 | pythys | I thought clojure is dynamic, why would I reload upon changing code? |
| 08:07 | pythys | does the repl cache in stuff? |
| 08:08 | dysfun | okay, this is for the situation where you are editing one of your lein project's clj files |
| 08:08 | dysfun | just editing them in a text editor does not make them changed in the repl |
| 08:08 | pythys | so either reload or restart the repl |
| 08:08 | dysfun | :reload-all is more useful |
| 08:08 | pythys | errrr, reload-all |
| 08:09 | pythys | okay, got it |
| 08:09 | dysfun | and realistically you may just want to use it by default, because then you can just find the last time you did it in the history |
| 08:09 | dysfun | but some modules don't play entirely nicely, so caveat emptor :) |
| 08:10 | dysfun | (and you will know when you have hit one) |
| 08:11 | pythys | Yeah, not too worried about that. I haven't been in a mind-bending journey in any new language the way I've been here. I'm staying in "exploration" mode for at least 3-4 months |
| 08:12 | dysfun | hah. i'm currently in the process of rewriting everything i wrote in my first 2 years |
| 08:12 | dysfun | (of clojure) |
| 08:15 | pythys | I see! clojure is definitely not short-term then |
| 08:15 | dysfun | i wouldn't say it's all bad code, but i like to improve old things periodically because i'm always learning |
| 08:16 | dysfun | and part of it has been necessitated by supporting clojurescript |
| 08:18 | pythys | dysfun: is it true that TDD is rendered unnecessary because of the nature of clojure programs and immutable state? that most tests are integration that grab more stuff from your system? |
| 08:18 | dysfun | no |
| 08:19 | dysfun | writing tests is a good way of reminding yourself that human beings weren't mean to write code |
| 08:19 | dysfun | because you will find bugs in things that you're absolutely certain are correct |
| 08:19 | pythys | dysfun: I was talking specifically about TDD, red-green refactor? |
| 08:19 | dysfun | i don't buy into all that |
| 08:20 | dysfun | it's just a strategy you give to mediocre developers to enable them to do a passable job |
| 08:22 | pythys | ok, so you test, but you don't have test code for every single line of production |
| 08:22 | pythys | the 100% coverage rule or whatnot |
| 08:23 | dysfun | i didn't say i was against testing |
| 08:23 | dysfun | just red-green-refactor and "write tests upfront" |
| 08:23 | pythys | I see |
| 08:23 | dysfun | it's alright for simple things, but i do a lot of research work and things evolve in a way that make it tedious |
| 08:28 | Keksike | how can I check if something is a set or not? |
| 08:28 | ridcully_ | ,(doc set?) |
| 08:28 | clojurebot | "([x]); Returns true if x implements IPersistentSet" |
| 08:29 | Keksike | no sorry, I meant map |
| 08:29 | Keksike | ,(doc map?) |
| 08:29 | clojurebot | "([x]); Return true if x implements IPersistentMap" |
| 08:29 | faxmodem | ^^ |
| 08:29 | Keksike | thanks :) |
| 08:29 | Keksike | ,(doc hash-map?) |
| 08:29 | clojurebot | Excuse me? |
| 08:30 | faxmodem | ,(doc dwim) |
| 08:30 | clojurebot | excusez-moi |
| 10:30 | sdegutis | What? |
| 10:30 | clojurebot | What is sampling a random integers betwen 2, 12 s..t. P(X = i) = (7-|i-7|)/36 |
| 10:30 | sdegutis | Clojure.spec!? |
| 10:30 | sdegutis | clojurebot: you're the most useless bot ever, stfu |
| 10:30 | clojurebot | I don't understand. |
| 10:30 | sdegutis | I vote we petition hiredman to turn off all clojurebot features except the REPL. |
| 10:31 | ridcully_ | ~sdegutis |
| 10:31 | clojurebot | No entiendo |
| 10:32 | hodapp | clojure.spec, man |
| 10:35 | dysfun | what are people using to develop webgl games in cljs? |
| 10:36 | sdegutis | http://clojure.org/about/spec |
| 10:36 | sdegutis | This looks handy! |
| 10:42 | sdegutis | dysfun: that wasn't in response to you btw |
| 10:42 | sdegutis | sorry for temporal ambiguity |
| 10:42 | dysfun | i'll live |
| 11:27 | sdegutis | Hello. What do you think of Clojure.spec ? |
| 12:31 | tolstoy | Reminds me a of schema attributes in datomic. |
| 12:31 | tolstoy | I should really pay attention to time stamps. |
| 13:06 | jsselman | dysfun: I plan on using pixijs, but to be fair i haven't tried it yet |
| 13:14 | dysfun | heh, i used to drink beer with the guy behind pixijs |
| 13:17 | jsselman | dysfun: you could check this out https://github.com/alexkehayias/chocolatier |
| 13:18 | jsselman | it has a giant WIP on the front page though |
| 13:24 | dysfun | interesting |
| 13:34 | jsselman | dysfun: the author had a talk at clojure conj 2016 about it: https://www.youtube.com/watch?v=TW1ie0pIO_E |
| 13:34 | dysfun | cool, thanks |
| 14:03 | irctc | hello there |
| 15:36 | sdegutis | Is there some way to mix comp with map without defining anonymous function? Like ((comp (map :order/id) :user/orders) users) |
| 15:37 | dysfun | er, what should that do? |
| 15:38 | sdegutis | The same as #(map :order/id %) |
| 15:38 | dysfun | (partial map :order/id) |
| 15:38 | sdegutis | Blargh. |