The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-08-04

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:09 cuechan joined #mojo
00:29 neilhwatson joined #mojo
00:30 neilhwatson joined #mojo
01:53 cpan_mojo Mojolicious-Plugin-RedirectHost-1.06 by ALEXBYK https://metacpan.org/release/ALEXBYK/Mojolicious-Plugin-RedirectHost-1.06
02:23 asarch joined #mojo
02:30 noganex_ joined #mojo
02:58 kid51 joined #mojo
03:23 ningu joined #mojo
03:49 zivester joined #mojo
04:07 sri jberger: hahahahahaha
04:07 sri your servercentral+juniper alliance tweet is the second juniper related tweet i saw today
04:08 * jberger phears what the first one is
04:08 sri the other was about the juniper backdoor winning a pwnie award
04:08 jberger nice
04:08 sri awesome timing!
04:08 jberger yup
04:09 jberger I'm not very deep on the networking side but I think we are basically a Juniper shop at this point
04:09 jberger so ...
04:09 sri basically an nsa front ;p
04:09 jberger insert into server_data (server_id, data) values (1, '{"oh":"boy"}
04:09 jberger hahahah
04:10 jberger copypasta fail too, what a nice
04:10 jberger ¯\_(ツ)_/¯
04:10 jberger I love making fun test queries btw; if you are wasting good test queries then shame on you
04:10 jberger oh boy!
04:13 sri ¯\_(ツ)_/¯
04:15 jberger Also that was the totally boring part of the query
04:16 jberger I've been working on "insert this row only if the new json document is different from the previous one"
04:16 jberger <3 postgres
04:16 ningu how do you do that?
04:17 ningu atomically I mean
04:17 jberger It's a funny query ;p
04:17 ningu I am not sure how to do a conditional insert although I know about upsert
04:20 jberger https://gist.github.com/jberger/5fe567677c9784c1b75a02a4578781f6
04:21 jberger so there are many servers each with evolving data that we want to track
04:21 jberger first you find the latest document by using a CTE (you could use a subquery too, I'm going to check tomorrow which is better)
04:22 jberger then just see if you found something and if the json was the same
04:22 jberger pretty cool that postgres json documents can be compared for equality
04:24 che-quest joined #mojo
04:24 sri think i never used equality on json fields
04:24 sri order of keys is insignificant?
04:30 jberger Nope
04:30 jberger Honestly i haven't found any real documentation on that feature (if it is one)
04:30 jberger But in my testing it seems to work
04:31 jberger Technically I'm using jsonb and that might be an important difference
04:31 jberger Maybe i should ask crab?
04:34 ningu I am not sure if order of keys matters in json, by spec. in practice, when there are multiple keys with the same value, I've found the default for various parsers is to use the last one
04:34 ningu but that is more of an implementation thing rather than json itself
04:35 ningu anyway, didn't realize you could add a where clause to an insert
04:36 jberger Aha
04:36 jberger "The standard comparison operators shown in Table 9-1 are available for jsonb, but not for json. They follow the ordering rules for B-tree operations outlined at Section 8.14.4."
04:36 jberger https://www.postgresql.org/docs/9.5/static/functions-json.html
04:36 ningu oh it isn't
04:36 ningu it's on the select
04:36 ningu hmmm
04:36 jberger ningu: Yep
04:37 jberger Tricky that
04:37 ningu yeah
04:37 jberger That's why it is select and not values
04:37 ningu and if the query returns no rows, nothing is inserted
04:37 jberger Right
04:38 ningu cool, that is an intersting case, I've used that form for inserting multiple rows but never for (possibly) inserting none
04:38 jberger I'm not sure if i have either
04:38 jberger Affluent most of the afternoon working on variations of that query
04:39 ningu glad it's making you rich ;)
04:39 jberger Affluent is clearly the same word as spent
04:39 jberger Thanks swipe
04:40 jberger Probably my cue  to put down my phone and go to bed
04:40 ningu hehe
04:40 ningu it's only 9:40 here
04:40 ningu and I am not a morning person
04:42 jberger Problem is that I'm still trying to get back onto Chicago time after being in Hawaii
04:42 jberger And i have to catch a train in the morning
04:42 jberger I'm almost back on time finally
04:42 jberger Going east is terrible
04:43 jberger The last few hours shift take forever since you can't convince your body to sleep
04:43 jberger Anyway nn
05:51 inokenty-w joined #mojo
06:23 mbudde joined #mojo
07:27 osfabibisi joined #mojo
07:30 Vandal joined #mojo
07:31 cpan_mojo Mojolicious-Plugin-OpenAPI-0.09 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-OpenAPI-0.09
07:59 trone joined #mojo
08:18 disputin joined #mojo
09:03 mib_v8liy4 Hey guys, if you're running a hypnotoad app, how can you set the --heartbeat-timeout option for prefork? hypnotoad bin/app.pl --heartbeat-timeout 300 comes up as an unknown option
09:04 mib_v8liy4 i have a route that takes a while to load the data, the worker says it loses the heartbeat and restarts
09:04 nic { hypnotoad => {heartbeat_timeout = 60, ...}, ... }  in your app config
09:05 nic s/=/=>/
09:05 mib_v8liy4 thanks :p
09:50 sugar joined #mojo
10:08 tchaves joined #mojo
10:35 cuechan joined #mojo
10:41 kaare joined #mojo
11:03 kid51 joined #mojo
11:04 tchaves joined #mojo
11:18 sugar joined #mojo
11:22 mishanti1 Have anyone run into tests taking _much_ longer to run for one user than another user? Like 5x more time.
11:22 mishanti1 Two orinary users running the same tests on the same checkout of a codebase.
11:22 mishanti1 Really weird issue.
11:23 nic is %ENV the same for both?
11:23 nic oh, you mean generally, not specific to Mojolicious?
11:24 mishanti1 Yeah, generally. That's whats weird.
11:25 mishanti1 Perl is compiled with the same flags (through plenv), and installed with the same version of modules installed with the same dependency handler.
11:25 nic So you should be able to construct a oneliner that doesn't do much interesting but has radically different execution times for them
11:26 mishanti1 Good point.
11:27 nic sounds like you're saying perl example.pl is fine but perl t/something.t is slow -- if that's the case should be easy to home in on where the edge is
11:29 mishanti1 Yeah, I'll try to simplify and scope down. Thanks for the input.
11:58 mpapec anyone familiar with IO::Socket::SSL?
11:58 mpapec http://stackoverflow.com/questions/38761553/iosocketssl-client-checking-server-certificate
12:10 cpan_mojo Mojolicious-Plugin-RedirectHost-1.07 by ALEXBYK https://metacpan.org/release/ALEXBYK/Mojolicious-Plugin-RedirectHost-1.07
12:31 sugar joined #mojo
12:39 itaipu joined #mojo
12:46 neilhwatson joined #mojo
12:48 Kripton joined #mojo
12:58 disputin joined #mojo
13:00 abra joined #mojo
13:17 abra_ joined #mojo
13:40 ptolemarch joined #mojo
14:03 disputin joined #mojo
14:15 disputin joined #mojo
14:17 Bean joined #mojo
14:29 jberger ningu: in case you read the log, the subselect version is maybe not as clean but the explain output is MUCH better (assuming I understand how to read that thing)
14:29 jberger https://gist.github.com/jberger/5fe567677c9784c1b75a02a4578781f6
14:37 lluad joined #mojo
14:56 zivester joined #mojo
15:16 zivester joined #mojo
15:17 zivester joined #mojo
15:42 sugar joined #mojo
15:50 jberger what do you all think, would it be bad form to zombie post a +1 on this ~5 month old email thread? https://www.postgresql.org/message-id/flat/CABoFc_hxX7F9n_nTGFP5-9y-Qy5v9_Wgn5j4DSaD8q-Gx0g%3D6w%40mail.gmail.com#CABoFc_hxX7F9n_nTGFP5-9y-Qy5v9_Wgn5j4DSaD8q-Gx0g=6w@mail.gmail.com
15:53 zivester joined #mojo
15:55 zivester joined #mojo
16:03 disputin joined #mojo
16:11 asarch joined #mojo
16:50 lluad jberger: Meh, maybe. Starting a new thread on -hackers referring to the old one, giving some context as to why you'd find it useful and asking whether anyone has a feeling for how difficult it'd be to implement is likely to be more productive than necro-ing.
16:51 lluad Oh, that thread was on -general. Yeah, ask on -hackers (after searching to see if anyone has already been talking about it).
16:51 jberger I ended up asking in their irc channel and the conversation is kinda/sorta happening
16:52 lluad Excellent. I was about to say "... or they have an IRC channel ..." :)
16:52 lluad s/they/we/
16:53 jberger their response so far is ways to get it implemented (1) cause your big company to leave postgres over the issue and blog about it (2) implement it yourself (3) write up some specs and post them to the mailing list
16:53 lluad Number 1 was Uber related humor, I suspect. Number 3 is the best bet.
16:53 AirDisa joined #mojo
16:54 jberger yeah 1 was a joke
16:54 lluad Unless you really like coding in C, anyway.
16:54 jberger the good news is that at least one other person on the irc list expressed interest in the feature
16:55 lluad Yeah, it's an obviously useful feature. If you bring it up on -hackers I'll definitely +1 it there.
16:55 jberger I wouldn't mind trying to write it, but even if I had the time to do it I almost certainly wouldn't have enough time to learn where the code lives
17:06 sri it might have been a joke, but the uber thing caused some interesting reactions
17:06 sri like https://www.postgresql.org/message-id/CABOikdMop5Rb_RnS2xFdAXMZGSqcJ-P-BY2ruMd%2BbuUkJ4iDPw%40mail.gmail.com
17:07 lluad Yeah. It's an interesting situation. The Uber people screwed up in several ways, but they highlighted some postgresql deficiencies. Nothing new, but it's good to look at them occasionally.
17:08 lluad s/screwed up/didn't behave how a postgresql expert would/ - their end result sounds like it's fine for them.
17:10 sri postgres definitely needs logical replication in core
17:10 lluad It does. And it's getting close.
17:12 lluad (Though there's a counter-argument that not everything needs to be in core, and that many of postgresql's advantages are that you can create powerful extensions that don't live in core).
17:12 sri replication is kind of a big deal though :)
17:13 sri looks like they might put pglogical into postgres 9.6
17:13 lluad Yeah. It's not a counter-argument I *neccesarily* buy for replication. But there's no one-size-fits-all perfect replication so having the hooks in core to be able to do that via a loadable module would be nice too.
17:14 sri of course
17:15 sri gotta say, postgres is one of the best managed open source projects out there
17:18 lluad Yeah. Not perfect, but the development process is close to it - at least from the perspective of a consumer.
17:32 jabberwok joined #mojo
18:07 Grinnz_ you would think there would be a more correctly implemented and minimalist pidfile handler out there by now than Proc::PID::File::Fcntl which was last updated in 2006 and isn't properly indexed on metacpan
18:07 Grinnz_ but i can't come up with anything good
18:08 cfedde It seems like one of those things that everyone thinks is simple.
18:09 Grinnz_ File::Flock::Tiny is the closest i found but it doesn't handle unlinking the pidfile
18:10 Grinnz_ since it's trying to be generic and not just for pidfiles...
18:11 cfedde I thiought that one of the Daemonize things had a pid file builtin.
18:11 * cfedde goes to look
18:11 Grinnz_ a lot of things do, but i'm looking for something standalone
18:11 Grinnz_ seems my best option is just to continue using this 10 year old module
18:12 Grinnz_ that or write one myself :P
18:12 Grinnz_ but then i have to be "responsible" for it being "correct"
18:12 cfedde heh.
18:13 cfedde It is one of those things that has a simple and obvious solution that is wrong.
18:31 cuechan joined #mojo
18:40 tchaves joined #mojo
19:16 Phil21 hmm, so a co-worker ran into a fun one with Mojo::UA
19:17 Phil21 writing a script that downloads a large amount of files (web scraper of sorts) on purpose
19:17 Phil21 we just found the http://mojolicious.org/perldoc/Mojo/Message#max_message_size limit
19:17 Phil21 the limit makes sense...
19:17 Phil21 the behaviour when you hit that limit does not
19:17 Phil21 we just found out we've been writing 16MB files to disk, and discarding all the rest of those files silently
19:17 Phil21 that seems... wrong to me
19:17 Phil21 I would expect all sorts of things to yell at me before it silently corrupts my data
19:18 Phil21 tossing there here since I'm not entirely sure if you guys would agree that's a bug
19:18 Phil21 er, tossing this
19:19 Phil21 thankfully the firmware inside these packages is checksummed prior to being applied to hardware :)
20:26 cfedde I thought I was getting an error when I saw that behavior.
20:26 cfedde Phil21: do you have a code example that demonstrates this behavior?
20:28 perlpilot .oO( Phil21 discovers that coworker was throwing away any error/warning that was generated )
20:30 Phil21 hehe
20:30 Phil21 well jberger is sitting next to me, talked to him about it
20:30 Phil21 basically the script was not checking $ua->success
20:30 Phil21 but yeah, I can provide example of the behaviour
20:31 Phil21 I still think it's... wrong.. but I see the argument of "you should be checking error if you care"
20:31 cfedde Phil21: glad you found it and I'd lean on  jberger for advice too.
20:32 cfedde BTW what would the correct edge case behavior be for this?
20:32 cfedde delete the data and continue as if nothing has happened?
20:32 Phil21 well, my argument to joel was "don't silently corrupt my data"
20:32 Phil21 yeah, I'd expect that
20:32 Phil21 and a warning/die()
20:33 Phil21 but I can see why die is problematic here
20:33 cfedde Ok so the fault was with the coder not inspecting the results of their action.
20:33 Phil21 yep, but I would argue for deleting the file fragment vs. leaving it around
20:33 Phil21 as I'm guessing someone else will do this same thing :)
20:34 Phil21 https://gist.github.com/phil21/ab8e45b693836686a191d0e47b8c4a97
20:34 Phil21 that was the code in question
20:34 cfedde it could be a disk filling service I suppose.
20:34 Phil21 like I said, not a big deal - we fixed it easy, it was more discovering it :)
20:35 cfedde yeah. still you could file a bug if you cared enough
20:35 Phil21 yeah, happy to if we think it's something to be changed - I could see both sides to this one though, hence asking #mojo
20:36 Phil21 as a "devops" style guy, basically silent destroying of data is athema to me, so it rustles my jimmies
20:36 cfedde it's not silent just because you are not listening.
20:36 Phil21 fair enough
20:36 Grinnz_ it just comes back to how important it is, with any user agent, to check for both http and transport errors, and understand how to handle them in a way relevant to your application
20:36 Phil21 I guess under that code, I would expect something to die() with "file not found!" or whatever
20:36 Phil21 since it.. didn't actually download
20:37 jehdin joined #mojo
20:37 Phil21 yep, just something we leared about useragent
20:37 Phil21 if that's the answer I'm fine with it, just was curious
20:37 cfedde network programming is scary.
20:37 Grinnz_ yet another reason it pains me whenever i see someone using LWP::Simple (basically no error checking possible other than get() returning undef)
20:37 cfedde lots and lots of silly edge cases
20:37 Phil21 yeah
20:37 Phil21 my die() action probably is horrible for someone else
20:37 Phil21 so checking probably makes sense in this context
20:38 cfedde Now we can go down the rathole that is error condition management.
20:38 cfedde is it an error? an exception? a long jump?
20:38 Grinnz_ luckily ->error and ->success make sense of "which HTTP codes are errors" for you, so that helps
20:39 Grinnz_ most useragents have a facility like this
20:40 Grinnz_ for fun with useragent errors... https://metacpan.org/source/DBOOK/Mojo-WebService-Twitter-0.002/lib/Mojo/WebService/Twitter/Error.pm
20:40 Grinnz_ i made that class entirely because having to try to handle transport, HTTP, *and* API errors everywhere was becoming a pain
20:42 Grinnz_ then for even more fun, there's APIs with non-fatal errors
20:42 Grinnz_ like wolfram iirc
20:42 Phil21 heheh
20:42 cfedde That's always a fun argument to have.  Is it an error when the search engine returns no values for your keywords?
20:43 Grinnz_ yeah... which errors should you show the client, which are reasonable to ignore
20:43 Phil21 yeah, we're building something where errors are really "fun"
20:43 cfedde there are a large class of conditions.
20:43 Phil21 since an error could be... the webserver failed, the mojo app failed, the remote API call failed... something on the remote API end unexpectedly failed, etc. etc.
20:43 Phil21 kind of annoying :)
20:44 cfedde I try to limit the scope of responsibility for any given layer I'm working in.
20:44 Grinnz_ always fun debugging random errors and finding out the apache proxy is misconfigured for some reason
20:44 Phil21 hehe
20:45 cfedde my favorite is sending SOAP stuff through websense proxy that is doing interesting keyword work on every request.
20:47 cfedde for some reason the thing inside a <CDATA chunk tickled a filter causing it to increment an abuse ticker.
20:50 ningu joined #mojo
20:54 * jberger abuses cfedde
20:55 jberger and yea, for the record, I should have come up with $coworker wasn't checking the ->success faster but my head is in a very different space right now
21:14 cuechan joined #mojo
21:19 sugar joined #mojo
21:39 itaipu joined #mojo
22:08 disputin joined #mojo
22:09 jehdin I'm a complete noob to Mojolicious, and what I'm trying to do seems very simple. Does anyone have a name or resource to a Mojo example of using a shell script to output data via a Mojo controller?
22:09 ningu jehdin: do you know perl? it's easy to get the output of a shell script in perl
22:09 ningu that part is nothing to do with Mojolicious
22:10 jehdin I do - I've written a tool to analyze some data, but I'm not sure how to push it to Mojo to render
22:10 Grinnz_ "push"?
22:11 jehdin Ultimately my goal is to have a form to upload a text dump, pass the file to my script, and then have Mojo render the data that's been parsed.
22:11 Grinnz_ unless you're talking websockets, the only "push" comes from clients making requests to your mojo server
22:11 Grinnz_ ok, so shell out to your script and get the output, `` also known as qx is the simplest way to do these two things
22:12 Grinnz_ if it takes a long time, you may want to use Mojo::IOLoop::ForkCall for it
22:12 Grinnz_ if you mean how to pass data back from your script, it's by STDOUT
22:13 Grinnz_ if you have a complex data structure you could encode it to json and then print that
22:13 Grinnz_ but json isn't so simple in bash :P
22:13 jehdin Nod - I do have my script set up to handle encoding into JSON
22:14 jehdin I'm just...not sure how to read that within Mojo
22:14 Grinnz_ if you use `` or qx(), it returns all STDOUT
22:14 Grinnz_ from the child process
22:14 jehdin Hmm
22:14 disputin joined #mojo
22:14 Grinnz_ https://metacpan.org/pod/perlop#qx-STRING
22:15 Grinnz_ for more control, see modules like IPC::Open3, IPC::Run
22:15 jehdin Well, that is completely different than what I had imagined, lol
22:15 Grinnz_ and also Capture::Tiny can be useful
22:16 jehdin Since my scripts are essentially .pm, can I include them within the mojo script and run it directly?
22:16 Grinnz_ if you make it an actual module function, absolutely
22:18 Grinnz_ think of it less of a script and more functions that you call and get something returned
22:18 jehdin So in reading through the documentation, is that where I'd engage helpers?
22:18 Grinnz_ you could do that, or make them plugins that install helpers even
22:19 jehdin Gotcha
22:19 jehdin Time to experiment.
22:19 Grinnz_ making them helpers is mostly useful for either convenience or if they need information from the controller object
22:19 Grinnz_ otherwise, regular old module functions work just fine
22:28 ningu Grinnz_: when would one use Mojo::IOLoop::ForkCall vs. Minion? is it a case of simple vs. complex?
22:28 Grinnz_ ningu: ForkCall when you want the result to be used for the response, Minion when you want the response to occur immediately and the job to happen whenever it gets around to it
22:29 Grinnz_ keeping in mind if something is taking longer than 30 seconds to generate a response for the browser, you probably want to rethink your approach regardless of ForkCall
22:30 ningu Grinnz_: ahhh right
22:30 ningu that makes perfect sense
22:35 ningu Grinnz_: so I have this huge former cgi script and the loading time for certain pages is, indeed, slow. not much more than 30 seconds but certainly more than 1 or 2 seconds in some cases
22:35 ningu I suppose one sledgehammer approach would be to wrap _every_ request in a ForkCall and not try to sort them into fast and slow but that seems kind of gross
22:35 sri Phil21: if you come up with a way to have it die please open an issue on github
22:36 sri be aware of the blocking/non-blocking hybrid api though
22:36 sri if you want to make that inconsistent there needs to be a very good explanation in the docs
22:37 Grinnz_ ningu: I just have a fork_call helper (basiclaly Mojolicious::Plugin::ForkCall) and call it for the requests that commonly need it
22:38 ningu Grinnz_: yeah, could do that
22:41 sri jberger: just looked at forkcall and was wondering why this check exists https://metacpan.org/source/JBERGER/Mojo-IOLoop-ForkCall-0.17/lib/Mojo/IOLoop/ForkCall.pm#L127
22:41 sri jberger: couldn't you just use that block all the time?
22:41 sri i mean, the overhead has to be pretty meh
22:42 disputin joined #mojo
22:43 Grinnz_ in fact the only difference between my fork_call helper and Mojolicious::Plugin::ForkCall is that i set Sereal as the serializer
22:43 * sri was wondering if forkcall was a candidate for mojo core
22:44 disputin1 joined #mojo
22:44 Grinnz_ it is a pretty common need at least in my experience
22:44 sri yes
22:46 sri i was a little worried it might have too much platform specific code, but most seems not really necessary
22:47 meshl joined #mojo
22:47 sri wonder if IO::Pipely is really required
22:51 sri i feel like there's a reasonably clean way to have it in core
22:51 sri now that bash on ubuntu on windows is the default way of deploying mojo apps on windows :)
22:52 * sri wouldn't even mind something like "die "ForkCall unavailable on this version of Perl" if $perl_has_no_real_pipes;"
23:15 PryMar56 joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary