#clojure logs

2016-03-17

04:18dysfunrhg135: i think the last thing we need is the DoubleSplitExperiment monad
04:18dysfunDoubleSlitExperiment*
04:19rhg135That's be great for OOP
04:20dysfun( https://en.wikipedia.org/wiki/Double-slit_experiment )
04:20mokusowow, how did quantum stuff came into clojure ?:>
04:20dysfuni'm learning particle physics as a hobby
04:20rhg135Modeling it I mean, who needs consistency or making sense?
04:20mokusoah nice
04:21mokusoif I'd deal with quantum physics again I'd focus on quantum information though, rather than particle physics
04:21dysfunrhg135: well it's probabilistic, so it does make a kind of sense
04:22dysfunbut it does make repeatability more challenging
04:22dysfunmokuso: heh, i've finally gotten around to learning enough thermodynamics to just about understand entropy
04:22rhg135So does OOP just not at 3am :P
04:22dysfun(since particle physics kind of requires it)
04:22mokusothough it is probabilistic there are some differences between classical (kolmogorovian) probability and quantum probability
04:23mokusoI think I've read something related somewhere, I can check if you're interested in the differences
04:23dysfunyeah you've lost me now :)
04:23dysfuni mean i understand the probability wave and collapsing it, but surely that just means the distribution of results is different?
04:24mokusodysfun: that's good, the entropy concept is very important and my favorite :>
04:24dysfunwell i came across the holographic principle recently and that was just like... wow
04:24dysfuni hated physics when i was in school because nobody told me just how fucking cool it is
04:25mokusoyeah well nobody told me in school that physics is the coolest application of maths, since high school math teachers always hated physics teachers and conversely
04:25mokusoas for your question I'm not that sure
04:25dysfunwell i hated maths too, so *shrug*
04:26dysfunalthough most of my maths teachers were drier than sawdust
04:26mokusoI liked maths, disliked math teachers and math people :>
04:26mokusoyeah
04:26dysfunnobody taught me how cool maths was either
04:26dysfuni laughed at all the people who told me i needed to be good at maths to be good at programming
04:26dysfunbecause i was not good at maths
04:27rhg135You don't need math much with programming
04:27mokusoexcept if you work in computer graphics and such stuff
04:28dysfunno. mostly you just need to know what the math operators look like
04:28rhg135That's what computers are for ;)
04:28dysfunyeah, graphics are the main exception. audio too
04:28dysfunbut even a lot of that has been sufficiently well abstracted by now. nobody codes a fourier transform by hand
04:28mokusosure
04:28dysfunthis is what i find is the real difference about physics and programming
04:29rhg135What's that though?
04:29mokusobut you'll be needing to understand why a function can be analysed to it's eigenfunctions with fourier analysis to get quantum mechanics
04:29dysfunwhen physics gets 'simpler', they introduce more variables into the equation
04:29dysfunwhen programming gets simpler, it gets out of my way
04:29mokusodysfun: here's something that will blow your mind
04:29rhg135Also, good night people
04:29dysfunmokuso: you may as well have just spoken chinese at me haha
04:29dysfung'night
04:30dysfunthe hardest part about trying to learn particle physics is realising what all the prerequisite knowledge is
04:30dysfunand for all of those, there are wikipedia pages full of arcane symbols that i swear are not intended for human consumption
04:31mokusosorry about that
04:32mokusomy point was that you'll be needing to study a bit fourier analysis and linear algebra
04:32mokusoto feel ok with quantum stuff
04:32dysfunthat's handy, i've been learning machine learning stuff, which is all linear algebra
04:33mokusocool
04:33mokuso:>
04:33dysfuni'm also acutely aware that graphics cards are well suited to a lot of linear algebra maths
04:33dysfunand so with the release of vulkan, i've got my eyes on that space
04:34dysfunin truth i'm also astounded that people would have bothered to do all of this stuff by hand
04:35dysfunif i'd been around before computers were widely available, i think i'd have hated physics
04:35mokusoheh
04:36mokusoin the old days most physicists left the calculations to the mathematicians or to human calculators :P
04:36mokusoat least in the WWII there was such a job, as a human calculator
04:36mokusomostly done by women
04:37mokusoyou might like this link: http://www.bristol.ac.uk/physics/research/quantum/engagement/qcloud/
04:38mokusoI found it sometime ago when I was writing a pop article on quantum computing
04:40dysfuni quite liked feynman's "los alamos from below" lecture
04:41dysfunhe talked about how they were going to get IBM "computers" (adding machines etc.) and how they filled in using humans for each task instead in the meantime and managed to achieve the same performance that the IBMs were going to give them
04:42dysfunand then when they had the computers and they were loading the appropriate cards by hand, they started doing concurrent work!
04:42mokusoheh
04:43dysfunsecurity regulations meant they couldn't tell the computer operators what these numbers were for etc.
04:43dysfunso feynman got them to tell them and suddenly they came up with better ways of squeezing performance out of the machines
04:43dysfunthey started running parallel tasks and performing fast error correction
04:43dysfuna lot of stuff we're struggling with today
04:44mokusoit always helps to know the full problem, along with it's real world details so you can put some extra restrictions that will speed things up
04:45dysfunyeah, writing extremely general libraries is hard
04:46dysfuni noticed it a few years ago. i got a bug report against one of my deprecated modules
04:46dysfunand i found it amazing that this code that i'd written off as a really bad idea was powering some high frequency trading stuff
04:47mokusoheh
04:47dysfunit's sort of like tunnel vision - it's very hard to imagine all the scenarios in which people will find something useful
04:48dysfunit's the reason i like clojure - it just has a few very general abstractions so it's very easy to interoperate
04:48dysfunand things like list functions come in useful in ridiculously more scenarios than you expect when you start
05:02Kah0ona Question: soon i need to strip text out of resumes, and distill relevant tags/keywords from it. Are there clojure libraries that help in that, ie. contain algorithms that use some heuristics to find relevant information in large text files?
05:29prohobonice
05:31dysfunKah0ona: there are a bunch of libraries that can do that listed on http://clojure-toolbox.com/ if memory serves
07:03kungiI am currently starting to dispair about cljs-time. Even the most bacsic examples seem to not work? https://gist.github.com/Kungi/606959e6fd2d00ada1cd does anyone have an idea what is wrong here?
07:15Henkrakskungi: try defining the formatter separate
07:16Henkrakskungi: (date-format/unparse formatter (date/today-at 12 00))
07:16ridcully_also if this is using goog.string.format under the hood, you might have to require it
09:06kungiHenkraks: defining the formatter has no other effect
09:06kungiHenkraks: I tried: (def f (date-format/formatters :basic-date-time)) (date-format/unparse f (date/today-at 12 00)) but I still get the same error
10:34AndreasOSeesaw Image-shape, can't get it right. Given the right path it says "don't know how to make image from... "
10:39sdegutisHi.
10:40AndreasOSeesaw Image-shape, can't get it right. Given the right path it says "don't know how to make image from... "
10:40justin_smithAndreasO: it wants something that to-image can use https://crossclj.info/ns/seesaw/latest/seesaw.graphics.html#_to-image
10:41sdegutisI dunno why, but I just have a hard time trusting DSLs like Seesaw.
10:41justin_smithso you need to give it a java.awt.Image or javax.swing.ImageIcon (though I guess it accepts nil too)
10:41sdegutisMaybe it's cuz I've had so many bad experiences with similar wrapper APIs in the past, and have just gone to the underlying API and had an easier time.
10:42TimMcAndreasO: Please don't re-post questions so rapidly.
10:42AndreasOSorry
10:43AndreasOjustin_smith: and what's that?
10:43justin_smithAndreasO: you would need to look up the constructors for java.awt.Image - it's in the core javadoc as it's part of java
10:45AndreasOOk
10:45justin_smithhttps://docs.oracle.com/javase/7/docs/api/java/awt/Image.html likely you would want the BufferedImage implementation https://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html
10:46digiorgihow can i change a JAVA object state safely from different threads?? in clojure
10:47dysfunyou can't. you need to use a mutex
10:47justin_smithdigiorgi: same way you would in java - IOW very carefully and it tends to be error prone, and you probably want to use a lock
10:47justin_smith(doc locking)
10:48clojurebot"([x & body]); Executes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances."
10:48Glenjaminyou could hide it behind channels, go-style
10:49justin_smithGlenjamin: that's true, but then only one thread will ever be touching it (the one doing the channel read)
10:49dysfunooh that's shiny
10:49digiorgijustin_smith, thanks (:
10:49justin_smithand if you have more than one thread doing a channel read, you're back to needing locking :)
10:49Glenjaminthe channel effectively acts as a lock, yeah
10:50dysfunnoooo, the word is a perfect immutable HAMT!
10:50dysfunworld*
10:50justin_smithhaha
10:50Glenjaminit's just potentially safer than handing out references and relying on callers to lock
10:50Glenjamini think
10:50Glenjaminlow level concurrency isn't my strong suit, as i intentionally tend to avoid doing any
10:52dysfuni'm not sure it's anyone's strong suit tbh
10:52dysfunwe've made lots of progress but i still feel like we're scratching the surface
10:53justin_smithjava concurrency in practice is pretty great, but the big takeaway is "unless you have really pressing performance needs that demand otherwise, use queues"
10:53renlif i wanna learn clojure web development should my first step be looking at clojure ring?
10:54justin_smithhttp://jcip.net/
10:54justin_smithrenl: ring is pretty ubiquitous, there's a new edition of "web development in clojure" coming out right now, fresh and up to date
10:54justin_smithsome friends are doing the book and all the exercises as a group, they say it's good
10:55AndreasOjustin_smith: well, on thing works. Now I need to get the image into the buffer. No sleeping today!
10:55Glenjaminjustin_smith: queues the datastructure, or queues like RabbitMQ?
10:55renlah ok, and the book covers ring? or some other higher level framework?
10:56justin_smithGlenjamin: like java.util.concurrent.ArrayBlockingQueue - pretty much what channels are
10:56justin_smithrenl: it covers ring plus some higher level stuff that uses ring
10:56justin_smithrenl: most web stuff in clojure will be using ring, it's pretty basic and there's few reasons not to use it as part of the stack
10:57justin_smithit's not a framework, it's an abstraction that makes it easy to switch webserver implementations while not changing your code
10:57renlthanks i'll check it out, too bad its not in my local physical book library :D
10:57justin_smithheh, it's a bit too new for that
10:58justin_smithrenl: it's in beta now https://pragprog.com/book/dswdcloj2/web-development-with-clojure-second-edition
10:58renlwould that book cover frontend stuff as well? or that would fall under clojurescript books?
10:58justin_smithrenl: yes, it covers frontend cljs and even css wrappers
11:02TimMcjustin_smith: Weirdly enough, it wasn't until just this month that I seriously used a queue for asynchrony.
11:03TimMc(And an executor!)
11:03justin_smithTimMc: it's remarkably similar to core.async (though not as pretty)
11:03TimMcI guess I just don't do much async that isn't already wrapped up in some other API like rxjava or something.
11:04renljustin_smith: sorry silly question, if the book is in beta, as and when there are content changes would i get to download it as well? or will i need to re-buy an updated copy?
11:04justin_smithrenl: I think the usual idea is that if you buy in beta you will get free updates until the final version is done, but the publisher should have the full info
11:05justin_smithI mean you are doing them a favor by paying for it while it's still not done
11:07winkrenl: for Manning's MEAP they actually regularly email you when you can download a new version, but no clue for others
11:08renlthanks :D
11:08winknow if only it would've been a text diff and not only PDFs... :)
11:08ridcully_renl: with pragprog you will get update notifications via email and can download the book then
11:09ridcully_renl: you (or your reader) might have to deal with the fact, that there are gaps in the book to revisit later. maybe not a problem with a second edition then
11:09TimMcSeriously, what I really want is access to the git repo so I can see the diffs. :-P
11:10renlnod :)
11:38cortexmanany idea what this arises from? (blah and blerg have a type mismatch merging profiles.)
11:38cortexmanwhen running lein
11:39justin_smithfirst thing I'd check is if one is a map value, and the other is a vector of maps
11:39justin_smithprofiles get merged when you run lein - first step might be figuring out which profiles are being used in the task
12:33cortexmanthanks
13:16amoe_how can I insert into a field of type BYTEA using clojure.java.jdbc? seems that neither a string, a byte array, or a vector of bytes work
13:29justin_smithamoe_: if it's any help, in this code the :value field in the table is a bytea, and it looks like he's giving it the value of nippy/freeze, which iirc is a byte-array
13:29justin_smithoh, almost forgot the link https://github.com/yogthos/jdbc-ring-session/blob/master/src/jdbc_ring_session/core.clj#L38
13:42WorldsEndlessI've made web apps using Luminus. Now I just need to make some micro services, not full-out content services. Any suggestions on where to start?
13:43WorldsEndlessLuminus is overkill for something that just needs to respond with JSON.
13:49justin_smithI'd pick a nice routing lib (many people like compojure but there are nice alternatives too), plus ring.
13:49justin_smiththat's all you really need for that.
13:52MJB47bidibidibidi
13:54justin_smithyeah, bidi is great
13:54amoe_justin_smith: thanks -- I just found the same thing, forgot to check
13:55amoe_justin_smith: turns out I need the result of (bytes expr) [rather than (byte-array expr)]
13:57justin_smithaha
14:23nehalI'm losing my mind a little bit with an instaparse grammar thing, is anybody awake to point out where I've gone wrong?
14:31sdegutisI don't know why I opened IRC.
14:32sdegutisI left the room, went into the other room, sat down for a minute and talked with my wife, then came back in here, and IRC was opened. Nobody else was in the room since I left it, and it wasn't opened when I left it. So it must have been me. But I don't recall opening IRC.
14:33nehalquantum IRC
14:33nehalyou were always in IRC, it's only when you came back that reality coalesced into you being here
14:35justin_smithyou have both joined and parted the channel until you sit down at your desk
14:36sdegutisI have a standing desk tho.
14:36sdegutisBuilt it about a year ago I think.
14:36nehalok some people are kind of here? is there something I'm missing with instaparse regarding handling 'empty' lines?
14:37ridcully_nehal: you will only find out, if you put your code on some paste site and share the url with the channel
14:37amalloynehal: ask a real, specific question
14:37sdegutisActually all I did was screw four 4x4s onto a butcher block with U-brackets and call it a day. My dad helped build a middle shelf with his tools, that the Mac Pro sits on.
14:37ridcully_~ask
14:37clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
14:38sdegutisnehal: I tried out instaparse and it was neat, but it didn't quite serve my needs (an INI-like text file format) so I went with writing my own immutable parser in Clojure using mostly just reduce and a bunch of conds.
14:39sdegutisclojurebot: /how dare you/
14:39clojurebotNo entiendo
14:40sdegutisclojurebot: I never!
14:40clojurebotCool story bro.
14:40sdegutisclojurebot: who do you think you are???
14:40clojurebotI don't understand.
14:40sdegutisclojurebot: What gives you the right...
14:40clojurebotExcuse me?
14:42sdegutisI ran out of those kind of phrases, and they're ungoogleable.
14:43justin_smithclojurebot: I demand satisfaction, EMP guns at dawn.
14:43clojurebotexcusez-moi
14:43nehalhttp://pastebin.com/HbsCLt8S
14:43nehalso I'm *pretty darn fresh* around most of this, so I'm sure it's something obvious
14:44nehalbut what I run into is that the blank divider line keeps getting error'd out
14:44justin_smithnehal: that's too many args to def
14:44justin_smithwait, neverm ind
14:44nehallike the parser fails on the first character of that second line
14:44nehaland I'm trying to understand *why*
14:45sdegutisjustin_smith: good one
14:45sdegutisToday my job is to learn how to use semantic HTML5 tags.
14:47nehalI've tried pulling the newline out of the main entry rule, doesn't work, tried doubling up on newlines in the num rule, no dice
14:47nehaleven tried to keep in mind that the file I'm parsing has CRLF's - no dice :)
14:58ridcully_nehal: trying your code in `lein try instaparse` works out fine for me
14:59nehaldidn't even realize lein had a instaparse tester, let me run that really quick and see if I've somehow avoided the actual trouble :v
15:00ridcully_hm no, that just is a plugin to start a repl with some deps loaded
15:00ridcully_(lein-try is the plugin)
15:01nehalgot it
15:01nehalthat'll speed up a bit
15:01ridcully_if you are dealing with dos files, then you need \\r\\n for your `nl`
15:02nehalsee I've tried that and it still blows up, for some reason :)
15:02nehaland yeah, dealing with Windows terminated CRLF newlines
15:02nehalbut oddly it'll get *to* the empty line fine
15:02nehalit's just it never wants to progress past it
15:04ridcully_i have copynpasted your sample entry, saved it starting from the `***...` and set ff=dos on it. then i just (slurp)ed it into the repl and tried from there
15:05ridcully_maybe you can provide the exact failing case?
15:11ridcully_nehal: the error when reading your data should somewho indicate what's the problem (expected X). if you file there has mixed line breaks, maybe you need `nl = '\\r'? '\\n'"` ?
15:12nehal@ridcully - working something out here, slowly, I'm suuuuuuuuuper new to Clojure and it's a bit of a cliff :) i've goofed with trying that, but it seems to blow up some other stuff equally
15:49sdegutisHmm. I had IRC minimized, and didn't realize I was even logged into IRC.
15:49sdegutisYet, here we are.
15:56sdegutisAnd again!
15:56sdegutisMy goodness, this day is full of surprises.
15:57spiedensdegutis: i just went past this tmux pane and had the same experience =)
15:57sdegutisOne minute I forget IRC exists, the next minute I realize I have a minimized live IRC window.
15:57sdegutisspieden: :)
15:58spiedeni was trying the slack channels for a bit but petered out
15:59spiedennot as easy to check in on i find, plus some sense of backlog obligation
16:01sdegutisSlack was an interesting fad.
16:01sdegutisI honestly thought it was going to catch on for a minute there.
16:01sdegutisBut now it's all over the news that Slack sucks and people are going back to using emails once again.
16:02sdegutisI wonder how many times people will try this before they give up and just accept that they'll always either use IRC or email.
16:05justin_smithamalloy: does useful already have this? (defn run-indexed! [f coll] (reduce (fn [i x] (f i x) (inc i)) 0 coll))
16:06justin_smithfairly obvious extension of run! I think
16:17sdegutisjustin_smith: why not something more like this? (defn run-indexed! [f coll] (run! f (map list coll (range))))
16:17sdegutisThat's my go-to when I need indices with my content, which is like never.
16:17justin_smithsdegutis: the point of run! is to not build collections you don't need
16:17sdegutisjustin_smith: meh, it's a lazy sequence
16:18justin_smithsdegutis: by that logic run! wouldn't exist and you would just call (dorun (map ...))
16:18sdegutisjustin_smith: run! already explicitly uses reduce anyway
16:18justin_smithsdegutis: if run! should exist, run-indexed! shouldn't create lazy-seqs
16:18justin_smithsdegutis: and the reason it uses reduce is in order to not create a lazy-seq it doesn't need
16:18sdegutisjustin_smith: oh, I see what you mean now; it's needlessly building a collection that it will probably never return, and if it does, it won't need (since it returns nil)
16:19sdegutisWhy doesn't it just use recir?
16:19justin_smithrecur? because reduce is simpler and has the same performance when you plan on running for each item in a seqable
16:20justin_smithalso thanks to the various implementations of the coll-reduce protocol it can perform better (by not needing seq in those cases even)
16:21sdegutis(defn run! [f coll] (if-let [x (first coll)] (do (f x) (recur f (rest coll)))))
16:21sdegutisInteresting.
16:22justin_smithsdegutis: but that needs rest / first, which means you are getting the seq, with the other implementations of the reduce interface/protocol/whatever-it-is you can do better than that
16:23justin_smithsdegutis: most of this is pointless for most of our code of course, this is silly levels of micro-optimization, but hey, it first the micro-optimized spirit of run! itself and there's entertainment value to trying to get it right
16:23justin_smith*it fits etc.
16:24amalloywell, justin_smith's implementation has the benefit of being correct
16:24sdegutisRight.
16:24amalloysdegutis's version fails for collections that contain nil or false
16:24sdegutisYeah I always get rest/next confused.
16:24justin_smithsdegutis: that's not the issue
16:24sdegutisI never explicitly use them, either. Any time I need that behavior, I just use destructuring.
16:33WorldsEndlessI'm looking for something to get me from "lein new" to a working restful microservice. Any pointers?
16:34justin_smithWorldsEndless: well, I'd start with something like "lein new bidi"
16:35WorldsEndlessI was hoping bidi had a template, but it doesn't seem to
16:35WorldsEndlessI went so far as to search clojars...
16:35WorldsEndlessI could probably use some understanding on how it works with ring (or just how ring works)
16:38WorldsEndlessOkay... reading through Clojure Web Development. It has a chapter on ring...
16:42tabakhasehm, i need help in adapting stuff in a ring context... -- "where" is my request object (i want to parse the requestersIP from it in line 10) http://paste.debian.net/416419/
16:42tabakhaseive edited the usual [] or req ... variants, but have no idea where its gone with {{}} magics :P
16:42sdegutisI very much would like to log off of IRC now.
16:43rhg135sdegutis: we'll only use irc till jim exists
16:43rhg135well even then
16:43rhg135maybe bridge it
16:45amalloytabakhase: the request object is what's being destructured on line 9
16:46amalloyyou can simply add another key to that destructuring, or add :as request if you want to keep the whole request around, or whatever
16:47tabakhaseso just add 'remote-addr :remote-addr' inside the {} block and it will find its way? -- is that the first ot second block then? amalloy
16:48amalloytabakhase: {{foo :foo} :body} extracts the :body of the request, and then further destructures that by taking its :foo out
16:48amalloyyou don't want to look into the body, so it shouldn't be in the inner map, which is for destructuring the body
16:50tabakhaseso that last step is "technically" (:body request) ? so my change would be {{...} :body remote-addr :remote-addr}
16:51WorldsEndlessOkay, so let me get this straight: I need ring to interact with Java services, like Jetty or Immutant, right?
16:52sdegutisI suppose now is as good a time as any to exi
16:52tabakhasecan i also somehow get the full object? (i want to throw it into a func that then also checks the x-forwarded headers and such for example)
16:53amalloytabakhase: try re-reading the first two messages i sent, and see if that answers your question
16:54tabakhase((if also have a wrap-local handler that i generally use where i have the full object -- so maybe that leads me into bad thinkering..
16:55tabakhasei think i dont get the "(GET "/stats" []" VS "(GET "/demos" req" VS (POST "/watch" {{}}}" magics...
17:02justin_smithWorldsEndless: ring adapts over various ways of running a web server, which can include an embedded web server inside your app, or a container that embeds your app
17:02justin_smithWorldsEndless: the nice thing is it makes it so you can use either of those options, with various embedded or embedding implementations, without changing your actual code
17:04justin_smithWorldsEndless: what you as a dev end up caring about is defining a handler, which is a function that ring will call for each request (regardless of how the request gets there). The handler will get a hash-map. All the things you need to be able to serve the request are in that map. You return another map, and ring will turn that map into a response.
17:05justin_smithtypically the handler starts with a router, then functions called based on the route, etc. Clojure routing libs expect to do routing on an incoming ring formatted request.
17:05justin_smithit's actually all very simple once you get used to it
17:06cat-o-the-thrilljustin_smith do you know of a good document that explains all this in detail... or should I just read the source code
17:06cat-o-the-thrillI've read through https://github.com/ring-clojure/ring/wiki
17:07justin_smithcat-o-the-thrill: the ring api docs are decent, and that web development in clojure book we were talking about is good (or so I hear). I figured it out by using the stuff and reading the docs mostly, with a bit of code reading.
17:08cat-o-the-thrilljustin_smith yeah that's what I figured... now if only I could find the time to read the code.
17:09cat-o-the-thrillProbably way better time spent then reading a book
17:09justin_smithheh - the important thing to remember is it's all about the protocols (since ring is about adapting various kinds of data coming from the server implementations, and the various valid replies from your handlers)
17:12sdegutisI'm severely liking the idea of building my web app using Components for all the "features" which have routes, which would conform to some kind of WebFeature protocol which only specified a (routes [this]) method.
17:13sdegutisWhat is your opinion?
17:14justin_smithsdegutis: I really like the idea of having a query api - in other words instead of having an endpoint that returns a specific peice of data gathered in a specific way, you do it as if you are a db, and let the client make db style queries (while of course not just connecting randos on the web to your real db layer)
17:14sdegutisYou have 30 seconds to respond. Best regards.
17:14sdegutisjustin_smith: Hmm. I'm struggling to imagine even the slightest concreteness in your concept.
17:15justin_smithsdegutis: think facebook graph api
17:15sdegutisWhat's that?
17:15justin_smithsdegutis: https://facebook.github.io/react/blog/2015/05/01/graphql-introduction.html
17:15rulliesdegutis: "all girls within 50 miles radius from where i live"
17:16sdegutisHmm. This API seems horrifying. I would prefer to not read any further about it ever.
17:16rullielol
17:17justin_smithsdegutis: the idea is that instead of deciding on one end what data you need, and then on the other end writing code that returns exactly that data, you implement a function that parses a simple data structure describing the data you need.
17:18justin_smithom next gets into this territory too
17:18sdegutisjustin_smith: So, instead of providing a fixed list of 'routes', like "/cart", all requests would .. um.. be a "query"?
17:18rulliejustin_smith: but the "function" you just casually referred to here is an entire field of study in AI.
17:18sdegutisjustin_smith: Om was an interesting experimental prototype of Reagent.
17:18sdegutisAre people still downloading and using Om? That's odd.
17:18justin_smithrullie: well, you get to define the rules for a valid query, and you can start with a known quantity like datascript you don't have to do it from scratch.
17:19rullieso you basically want sql over http
17:19justin_smithrullie: no, datascript
17:19rulliesure, same difference
17:19justin_smithdatastructures, not strings, and no mutability
17:19rulliehttp get is never mutable.
17:20justin_smithsdegutis: if you look at that graphql link, it's meant to go with react - it's a way to simplify providing the data the frontend needs.
17:20justin_smithrullie: tell that to my coworkers who connect a get request to a db update.
17:20sdegutisjustin_smith: Hmm, I've heard of React on HN a few tims.
17:24justin_smithanyway, I haven't tried doing an api this way, but I can see the appeal - why do an ad-hoc query / response combo that tightens the coupling between frontend and backend code when you can use an established query language, with easy to manipulate data structures on the input and output sides.
17:24justin_smiththe hard part is isolation I guess, but it's not like this is solved by regular apis perfectly anyway
17:25sdegutisjustin_smith: because it requires inventing some kind of query language on top of HTTP requests.
17:26sdegutisAnd transforming HTTP requests to this language.
17:26sdegutisWhich I'm not opposed to in principle, but I'm not gonna be the one to invent it.
17:27justin_smithsdegutis: well datascript is already out there, it's not like you need to implement that - more the step of binding that to your own datomic or whatever on the backend
17:30rulliejustin_smith: why use typed language that tightens the couping between your datastore and your actual data when you can just have maps of randoms? :)
17:31justin_smithas a user of an untyped data oriented language in an irc channel devoted to said language, why indeed?
17:32sdegutisjustin_smith: Hmm. Interesting.
17:32sdegutisjustin_smith: I like your (routes [this]) idea a lot.
17:33justin_smithI assure you I'm just sharing relevant ideas that I picked up here an there, I invented none of it.
17:33sdegutisjustin_smith: the routes idea is great.
17:34sdegutisI really want to use Component, but it's just so complex. The readme's length really gives away how much needs to be memorized about how to use it.
17:35sdegutisIn itself, the component/Lifecycle protocol is very simple and understandable. But the Systems section (https://github.com/stuartsierra/component#systems) is where it starts getting very confusing very quickly.
17:39sdegutisHuh! I like this idea more and more.
17:40sdegutisThere'd be no need to store any of the dependency components on the request via middleware. You'd just get them from the Component's initialized fields.
17:45sdegutishttps://gist.github.com/sdegutis/442d9ed9a6cf861ce7f7
17:45justin_smithright, interesting
17:45sdegutisHmm, I forgot to use "db" anywhere.
17:46sdegutisBut the point is that it could.
17:46sdegutisAnd records (all objects) automatically conform to component/Lifecycle, so they could be given to component/system-map.
17:47sdegutisSomething like (conn db) would be called and the result passed to cart/add-product and whatever else.
17:51sdegutisFwiw I like the aspect of Compojure that it uses Clout for.
17:51sdegutisAnd I have no problem creating the router functions manually and giving them to Compojure rather than using its DSL.
17:52sdegutisBut man, Component is confusing.
18:10sdegutisHmm. All my components have no-op start/stop methods, except one, the email service, which queues emails up every 2 seconds and then sends them.
18:10sdegutisI wonder if I can fix that one to not need start/stop. Then I'd be in business!!!
18:10sdegutisActually, wait! I can!!
18:10sdegutisWait, no.
18:11sdegutisThen I literally wouldn't even need Component! I'd just create a map of things, and give some of those things to the other things!!
18:11sdegutisOh wait, the HTTP router.
18:11sdegutisDANGIT.
18:11sdegutisOh wait! I still don't need Component for that. The router can BE the fricken system!
18:11sdegutisamirite? eh? ehh??
18:15sdegutisHi.
18:17ben_vulpeshi sdegutis
18:17sdegutishow r u
18:17ben_vulpeswell
18:17ben_vulpesyourself?
18:30sdegutisGreat thanks.
18:34sdegutisIs this valid Clojure code, and will it resolve the .stop method properly at compile-time? (.stop ^Server (:server component))
18:38MalnormaluloDo you need the type hint? I've never seen one inside an s-expression like that -- usually they're in function signatures
18:39amalloysdegutis: yes
18:39sdegutisGreat, thanks amalloy.
18:40amalloyyou can set *warn-on-reflection* to true to confirm
18:40sdegutisMalnormalulo: I have no idea if it's needed.
18:41sdegutisIs there a good reason not to put :global-vars {*warn-on-reflection* true} inside project.clj?
18:45sdegutisWhat simple self-sufficient Clojure expression is guaranteed to trigger a warning when warn-on-reflection is true?
18:46sdegutisHuh. Weird.
18:47sdegutis,(binding [*warn-on-reflection* true] (eval '(.toString 23)))
18:47clojurebot#error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb...
18:48sdegutisHaha stupid thing.
18:51sdegutisHmm. Okay, I see what happens now.
18:51sdegutisThanks amalloy.
19:45kenrestivois riemann still actively in use?
19:46kenrestivoor are there newer ways to do this kind of thing with, say, onyx, core.async and transformers, etc?
19:48tolstoySeems to have recent commits.
19:51amalloyaphyr probably still actively uses it
20:26TimMc,((resolve (symbol "eval")) '(+ 1 2 3))
20:26clojurebot6
20:27TimMc,(binding [*warn-on-reflection* true] ((resolve 'eval) '(.toString 23)))
20:27clojurebot#error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb...
20:28TimMcI wish I could see what exactly was being denied...
20:28TimMcOh right, it's try/catch that clojurebot doesn't like, not eval.
20:36tolstoyOn data.json :value-fn, how come (case (type v) java.util.UUID (str v) ...) doesn't work? Odd.
20:36tolstoy(cond (instance? java.util.UUID v) (str v) ...) does.
20:38hiredman,(type 'java.util.UUID)
20:38clojurebotclojure.lang.Symbol
20:38hiredman,(doc case)
20:38clojurebot"([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and need not be quoted. If the expression is equal to a test-constant, the corresponding result-expr is returned. A single default expression can foll...
20:38tolstoyOh, hm.
20:40tolstoy,(= (type (java.util.Date.)) java.util.Date)
20:40clojurebottrue
20:41tolstoy,(case (type (java.util.Date.)) java.util.Date :foo :bar)
20:41clojurebot:bar
20:41tolstoy,(condp = (type (java.util.Date.)) java.util.Date :foo :bar)
20:41clojurebot:foo
20:41hiredman"... They must be compile-time literals ..."
20:42hiredman,(type 'java.util.Date)
20:42clojurebotclojure.lang.Symbol
20:42hiredman,(type (resolve 'java.util.Date))
20:42clojurebotjava.lang.Class
20:43tolstoyI guess I'm a little confused about "literal" and class names, but I think I see it.
20:45hiredman,(type (read-string "String"))
20:45clojurebotclojure.lang.Symbol
20:46hiredman,(type (eval (read-string "String")))
20:46clojurebotjava.lang.Class
20:46hiredmannot a literal
20:46tolstoy,(str (class (java.util.Date.))
20:46clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
20:46tolstoy,(str (class (java.util.Date.)))
20:46clojurebot"class java.util.Date"
20:46tolstoyOh, well. condp solves it for me. ;)
21:15srrubyDoes anybody have a source code formatter that follows bbatsov's guidelines? https://github.com/bbatsov/clojure-style-guide#source-code-layout--organization
21:16tolstoyhttps://github.com/weavejester/cljfmt maybe?
21:18sfz-and https://github.com/venantius/vim-cljfmt which uses it as a vim plugin
21:18srrubytolstoy: Thanks!
21:50sdegutisWhich (ns) form is more correct when I just want to use Server as a class name? (:import org.eclipse.jetty.server.Server) or (:import [org.eclipse.jetty.server Server])
21:57sdegutisHow do you do that thing like this? (.. ^Server server (stop) (join)) ?
21:58sdegutisOh right, (. ^Server server (stop) (join))
21:58sdegutisYay! Thanks amalloy.
22:21sdegutisOh man justin_smith this is a great idea.
22:21sdegutisYour routes thing is working amazingly.
22:30ajbIf I have a vector containing maps that all share a common key of `:tags` and that has another vector containing shared tags, how would I filter that based on one of the tags in the vector?
22:36TEttingerajb: something like [{:tags [1 2]} {:tags [2 3]} {:tags [100 200 300]}] for the first thing you mentioned?
22:36TEttingerassuming strings instead of ints
22:36ajbyeah
22:37TEttingerso in that case, if you wanted to look for the tags [1 100], that would return the maps that have (I didn't have any other data, so just the taglist) [1 2] and [100 200 300], but not the other one?
22:39ajbcorrect
22:40TEttinger,(for [data [{:tags #{1 2}} {:tags #{2 3}} {:tags #{100 200 300}}] wanted [1 100] :when ((:tags data) wanted)] data)
22:40clojurebot({:tags #{1 2}} {:tags #{300 100 200}})
22:40TEttingerthat uses sets not vectors, but I assume you don't want duplicate tags
22:41TEttingerit shouldn't be too hard to convert to use vectors, I just don't remember the fn off the top of my head
22:41ajb(vec)?
22:44TEttingerno no, I mean searching a set is just what the set does, I don't remember which searches a vec for an item
22:46TEttinger,(for [data [{:tags [1 2]} {:tags [2 3]} {:tags [100 200 300]}] wanted [1 100] :when (some #{wanted} (:tags data))] data)
22:46clojurebot({:tags [1 2]} {:tags [100 200 300]})
22:47TEttinger,(for [data [{:name "TEttinger" :tags [1 2]} {:name "ajb" :tags [2 3]} {:name "rhickey" :tags [100 200 300]}] wanted [3] :when (some #{wanted} (:tags data))] (:name data))
22:47clojurebot("ajb")
22:47ajb:D
22:47TEttingerthat look like what you wanted?
22:47TEttingerfor is a great piece of code
22:49ajbexactly what I wanted, thank you so much!
22:49ajbI tried to do that weeks ago and just ended up switching to datascript because of the cardinality it offers
22:49ajbI can finally use just plain clojure, woo
22:53TEttingerI am almost certain there's a more efficient way to do it; for goes through all combinations as part of something like...
22:54TEttinger,(for [x [1 2 3] y [10 20]] [x y])
22:54clojurebot([1 10] [1 20] [2 10] [2 20] [3 10] ...)
22:54TEttingerso if testing for many tags or many items, it tests more than maybe it needs to
22:54TEttingerthen again, that might be appropriate here
22:55TEttingersince each tag is actually independent of the data, it could appear in all items or not at all
23:21sdegutisHey.
23:21sdegutisIs it possible to-- oh wait!
23:36sdegutisWoo!
23:41ajbsdegutis: care to share?
23:41sdegutisC-x cider-refresh
23:41sdegutisOr C-c C-x for short
23:41sdegutisSo far it mostly works, but it's not entirely working.
23:43sdegutis/cc ajb
23:43ajbawesome!
23:44ajbwhen are we going to get an all clojure window manager? :p
23:45ajb/cc sdegutis
23:45sdegutisajb: haha, I already made ClojureScript bindings for my HTTP-based one a few years ago
23:45sdegutisI forgot what I called that one.
23:45sdegutisIt was before Phoenix or Hydra though.
23:45sdegutisMan was it silly.
23:46ajbhah, sounds like a fun project
23:46sdegutisHuh, now I wonder what that was called.
23:46sdegutisOh! Zephyros!
23:46sdegutisMan I was so crazy.
23:47ajbAren't you in progress of making a new one?
23:47ajbthat's paid/closed source
23:47sdegutisOh boy, not even in the slightest.
23:47sdegutisI gave up on that years ago.
23:47sdegutisNobody uses window managers, and the few people who do, aren't willing to pay, because there are many free ones.
23:47sdegutisAnd there are many paid ones too.
23:47ajbhave you seen kwm?
23:48sdegutisProbably.
23:48ajbhttps://github.com/koekeishiya/kwm
23:48ajbit actually takes the windows and tiles them sort of like amethyst
23:48sdegutisNeat.
23:48ajbsort of like an OS X version of i3
23:48sdegutisOh yeah I saw that one.
23:49sdegutisI just use AppGrid these days.
23:49ajbI just sort of gave up on the osx wm front and just switched over to fedora/i3 a while ago
23:49sdegutishttps://github.com/sdegutis/appgrid
23:49ajboh, nice!
23:49sdegutisCool. I'd love to switch over to Linux, if it would just add all the features I need.
23:49ajblike what?
23:50sdegutisWell the main one is being able to support my Apple hardware as well as OS X does.
23:50ajbyeah, that's a bit lacking :/
23:50sdegutisThat's actually pretty much it.
23:50sdegutisIf they could get that working, I'd be sold.
23:51ajbbut in my (albeit limited) experience with it, there aren't that many problems with hardware compatiblity on linux with the macbooks
23:51sdegutis100% of the apps I use on OS X are Chrome and Emacs anyway.
23:51sdegutisWhat about retina MBP?
23:51ajbI have to say though, the one thing that I missed for the first few weeks was alfred
23:51sdegutishttps://wiki.archlinux.org/index.php/MacBook#MacBook_Pro_with_Retina_display
23:52sdegutisAh yeah, I know some people who use Alfred. I don't.
23:52sdegutisBut, that reminds me, I do use Dash.
23:52sdegutisDoes Linux have Dash?
23:52ajbNot sure, I am typing this on an 11" MBA right now
23:52ajbI think so
23:52ajbor something like it
23:52ajbhttps://zealdocs.org/
23:52sdegutisI use it for Java 8, jQuery, and Clojure. If they got that, then great.
23:53sdegutisWow, such 1990s UI.
23:53sdegutisHmm. I may experiment with trying Linux out on my stupid little 2013 rMBP.
23:53ajbyou should try it!
23:54sdegutisHmm. Then again...
23:54sdegutisI'd rather use that time making cool things in Clojure instead.
23:54sdegutiscuz that makes me money.
23:54sdegutisAnd OS X only super-annoys me like no more than 5% of the time.
23:54sdegutisPlus it lets me sync my stupid iPhone ever few months.
23:54sdegutisThen again I don't really need to do that anymore I guess.
23:55sdegutisThe main thing though is figuring out why 9alter-var-root #handler (rebuild-handler)) is not seeming to do the thing I want it to.
23:55ajbhuh? what's that?
23:55sdegutiss/9a/\(a/
23:55sdegutisSomething I'm working on in Clojure for work.
23:57sdegutisHuh. It seems that (run-jetty #'handler ...) is completely ignoring changes to handler's root.
23:57sdegutisI.. I thought that was the whole point??
23:57srrubyI'm on MBP/Linux
23:58sdegutissrruby: is it terrible on your battery & wifi?
23:58sdegutisI just imagine it must be.
23:59ajbonce you get tlp setup the batterylife is pretty much the same
23:59srrubysdegutis: I'm really enjoying it. Battery life and wifi seems good.
23:59sdegutisHmm.
23:59ajbmaybe even a little longer in my case
23:59sdegutisI dunno.