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

IRC log for #mojo, 2017-05-31

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

All times shown according to UTC.

Time Nick Message
00:04 Lee joined #mojo
00:45 zivester2 joined #mojo
00:50 gryphon joined #mojo
00:51 marty joined #mojo
00:56 disputin joined #mojo
00:59 disputin1 joined #mojo
01:21 cheako joined #mojo
02:05 Lee joined #mojo
02:14 cheako joined #mojo
02:51 noganex joined #mojo
03:04 Lee joined #mojo
03:07 zivester joined #mojo
03:45 irqq joined #mojo
04:04 dboehmer joined #mojo
04:54 karjala_ joined #mojo
05:53 dod joined #mojo
05:59 dod joined #mojo
06:30 VVelox joined #mojo
06:55 Vandal joined #mojo
07:04 trone joined #mojo
07:12 inokenty-w joined #mojo
07:22 AndrewIsh joined #mojo
08:11 Petru_ joined #mojo
08:38 rshadow joined #mojo
08:57 irqq joined #mojo
09:00 karjala_ joined #mojo
09:00 karjala_ Where is the suggested place to store a downloaded file that I want cached on my server for the next month or so?
09:01 karjala_ /tmp is too temporary. redis requires installing a new server
09:04 rshadow joined #mojo
09:10 karjala_ I'll use this: https://metacpan.org/pod/CHI::Driver::DBI
09:24 rshadow joined #mojo
09:34 Petru_ joined #mojo
09:56 stryx` joined #mojo
09:57 prg joined #mojo
11:20 dod joined #mojo
11:25 tchaves joined #mojo
11:41 Petru_ joined #mojo
11:50 tyldis I'm thutoughly confused. I got a memory leak with my Mojo::UserAgent. When talking to the actual webserver memory uasge grows endlessly for each request. I then wrote a mockup in lite that serve the same data as the actual webservice: no leak.
11:52 aborazmeh joined #mojo
11:52 tyldis I've isolated the code down to a simple $ua->get() and no more...
11:53 tyldis Just swapping URL triggers the behaviour
11:57 zivester joined #mojo
12:16 gryphon joined #mojo
12:30 pink_mist joined #mojo
12:47 gizmomathboy joined #mojo
12:48 marty joined #mojo
12:49 marty_ joined #mojo
12:51 rshadow joined #mojo
12:55 chenri joined #mojo
12:58 zivester2 joined #mojo
13:28 chenri left #mojo
13:34 maschine joined #mojo
13:49 rshadow joined #mojo
14:05 mcsnolte joined #mojo
14:07 zivester joined #mojo
14:16 kell4133 joined #mojo
14:17 * sri yawns
14:17 pink_mist darnit, now you made me do it too
14:17 kell4133 Hi there. I'm currently experiencing an issue with development of a mojolicious application. It seems when every_param is called it works fine for parameters that are strings, but when those arrays are full of integers, it does not insert the parameters into the array.
14:18 kell4133 Is this a known bug in mojolicious?
14:21 jberger kell4133 can you make a minimal example?
14:29 kell4133 https://pastebin.com/GEYuJsNj
14:29 kell4133 Here is a problem description
14:33 gregf_ joined #mojo
14:34 jberger kell4133: can you make an example that I can run?
14:34 jberger I still can't follow the problem from that paste
14:34 kell4133 I'm not sure it's possible as the applications quite large.
14:35 jberger but surely it can be done with a simple Mojolicious::Lite app that takes some parameters?
14:36 kell4133 but basically every_param when called on an input that is a string/date works fine in populating the resultant array, but not for when the parameter is integers
14:36 pink_mist kell4133: so show us an application we can run that exhibits that behaviour
14:36 kell4133 Fuck it i'll just ask on stack overflow.
14:37 kell4133 Thanks for taking a look though :)
14:39 pink_mist kell4133: the problem is that what you're saying is not something that anyone has encountered before, so in our minds, it's likely your application that is doing something to cause that, not that it's a problem in Mojolicious - but if you recreate the problem using a small app it'll be much easier to find out what's going on
14:39 jberger kell4133: in order to help, I need to be able to replicate the problem
14:39 jberger in order to help you if you don't give me an example, I'll have to make one myself
14:40 jberger and who knows if I'll do it the same way that you do to get the problem
14:40 jberger for example, this works as I expect
14:40 jberger perl -Mojo -E 'a("/" => sub { print $_->dumper($_->every_param("thingy")); $_->rendered(200) })->start' get '/?thingy=1&thingy=1'
14:41 * kell4133 tips fedora
14:41 jberger so my question then becomes, in what way is my demonstration different from yours, but I can't know unless I see yours
14:44 sri you just had the opportunity to ask multiple members of the core team directly, stack overflow is quite the downgrade
14:44 sri but whatever works for you
14:46 kell4133 Well I think crafting an application from scratch is rather an ask
14:47 sri not at all, jberger was asking for a one-liner, like the one he just showed you
14:47 pink_mist is it? just generate a lite app using mojo, and put in the logic bits you already have in your problematic app
14:47 pink_mist or even what jberger did, yeah
14:47 jberger kell4133 is it any less of an ask for us to try to replicate a problem you are reporting without context?
14:48 jberger that sounds snarky as I read it back to myself, it wasn't intended to be :s
14:48 jnap its always great if you can contribute a failing test case, even if thats work for you its a wonderful way to pay back the community.  My first open source contribs were all test cases.
14:49 jberger I guess I'll simply say "Is this a known bug in mojolicious?" No, that is not a known bug, as demonstrated by my one-liner
14:49 kell4133 Honestly it would take me a few hours as mojolicious is fairly difficult to write applications in.
14:49 jberger if you believe it to be a bug in Mojolicious that can be reproduced in some other way, please give us a runnable case
14:50 jberger kell4133: do you think that disparaging the framework is going to make us more likely to help?
14:50 jnap understood, it took me a day to write my first test case for an issue I had in Catalyst, because there was a lot to figure out.  But it was an investment that paid back over the years tremendously :)
14:50 jnap you never know, a year from now you could be a core maintainer :)
14:51 jberger jnap++
14:51 rshadow joined #mojo
14:51 jnap I understand its daunting at the start.
14:52 kell4133 I don't particularly think i'm disparaging the framework, it is not the easiest framework to code in (compared to say cherrypy/flask/django/laravel).
14:53 jberger I personally disagree, is there a constructive way that you could expand on your statement? how could it be easier?
14:53 jberger and if you are going to say "the documentation" please be specific
14:53 jberger we are quite proud of it, though it must actually be read not skimmed
14:54 * kell4133 sighs
14:55 maschine You can only help those who want to help themselves...
14:55 jberger another "please do web for me and don't make me learn anything" ok got it
14:55 * jberger sighs
14:56 maschine FWIW I've learned more in the last 6 months of using Mojo than I did in the previous 20 hacking Perl. :)
14:57 jberger maschine: I'm glad to hear it
14:57 jberger I learned a ton when I started hanging out in here too
14:57 jberger back before I was a core team member
14:57 jberger (I still do tbh)
14:58 sri covfefe...
14:58 jberger sri: covfefe indeed
14:58 maschine lol
14:59 jnap sorry that didn't work out :(  Some people don't understand everyone here is a volunteer on unpaid time.  Its really worth it to struggle through your first contrib test case.
15:00 jberger I'm curious what they were seeing
15:00 jberger I suspect they were using Dumper wrong, tbh
15:00 jberger not exactly sure how
15:01 jnap might have been so wacky pragma or something local to the application, probably added by an earlier developer
15:01 jberger or using a PSGI adapter and middleware
15:01 jnap I see that all the time on Catalyst apps in the wild, people seem to really enjoy adding local hacks rather than contributing solutions.
15:02 jberger ("well we have to deploy on mod_perl and we have this middleware from another in-house project" etc)
15:02 jnap right, exactly
15:04 jberger and contributing a test case can still be tricky
15:04 jberger I don't know how long it took me to replicate that websocket close bug that I hit a few months back
15:04 jberger a month?
15:04 purl i think a month is from 0æ
15:04 jberger shut it purl!
15:04 * purl shuts it
15:04 pink_mist whoah, that worked
15:04 * jberger grins
15:04 pink_mist botsnack
15:04 purl thanks pink_mist :)
15:07 disputin joined #mojo
15:07 zivester joined #mojo
15:10 disputin1 joined #mojo
15:14 disputin joined #mojo
15:22 karjala_ Is there any chance Mojo::IOLoop::Subprocess will ever be able to "send progress" to its parent?
15:22 karjala_ in the future?
15:23 karjala_ would be nice with websockets
15:23 karjala_ Because I think (correct me if I'm wrong), a sub-process cannot send websocket messages to the client, if the websocket connection has been opened at the parent process
15:24 karjala_ But with "send progress to parent" we'd be able to combine the good of blocking code (subprocess) with websockets!
15:24 karjala_ What do you think?
15:24 purl I think karjala_ should try flossing more often!
15:24 karjala_ oh
15:25 disputin joined #mojo
15:43 sri karjala_: yes, there's a chance
15:47 PryMar56 joined #mojo
15:49 maschine general perl question, but do I need to worry about this warning "keys on reference is experimental"?
15:49 maschine seems to work fine for what I'm doing
15:51 pink_mist yes, you should just deref it
15:51 jnap FWIW I pretty much ignore anything Perl porters has added to Perl for the last number of years
15:51 pink_mist instead of "keys $ref->{foo};" do: "keys %{ $ref->{foo} };"
15:51 jnap that one in particular can lead to subtle bugs and might be removed in a future perl.
15:51 maschine pink_mist easy enough, thanks!
15:54 jberger or if you know that you are on a new enough perl, use postfix deref instead
15:54 jberger keys $ref->{foo}->%*
15:55 jberger the problem with using non-ref functions on refs is ambiguity
15:55 jberger the postfix derefs don't suffer that problem
15:56 pink_mist jberger: the problem with your suggestion is that for any perl supporting ->%* the warning he got would be a syntax error
15:56 jberger really?
15:57 pink_mist unless I misremember and the ->%* syntax worked in 5.22
15:57 jnap I really don't see much of a point, is keys $ref->{foo}->%* so much easier to understand than keys %{$ref->{foo}} that its worth being so incompatible...
15:57 pink_mist but iirc it started in 5.24
15:57 jberger I thought the experimental warning came in on the same version as postfix
15:57 maschine I thought keys "%{ $ref };" was pretty clear.  I was just liking using the references directly.  I had some really ugly scripts back in the day with like 5 or more hashrefs...
15:57 pink_mist no, it came when it was marked a syntax error instead of a warning
15:57 jberger jnap: it is on more crazy ones
15:58 jnap I stopped following Perl porters when it was clear nothing Stevan did on MOP was ever going to be good enough for them.
15:59 pink_mist https://metacpan.org/pod/release/RJBS/perl-5.24.0/pod/perldelta.pod#Postfix-dereferencing-is-no-longer-experimental
15:59 pink_mist https://metacpan.org/pod/release/RJBS/perl-5.24.0/pod/perldelta.pod#The-autoderef-feature-has-been-removed
15:59 pink_mist I guess I was slightly wrong
15:59 jnap I don't even use // :)
15:59 pink_mist it was when ->%* stopped being experimental
16:00 jberger jnap: remember, there's also a difference between library code and other code
16:00 jberger I don't use most new features in CPAN code either
16:00 jberger I usually will use // because Mojo requires 5.10.1 anyway
16:00 jnap true, sure.  For my CPAN stuff I stick to 5.8 syntax.  But then out of habit I tend to do the same on my application code as well
16:01 stryx` joined #mojo
16:01 jberger I'm ready to use __SUB__ and /r in my CPAN code
16:01 jnap its funny but I just don't run into so many cases where // is better than || with real life code and real life expected data
16:01 jberger and respond on a per-case-complaint basis
16:02 jberger I take the other approach now on // vs ||
16:02 jnap ah, right well that one is useful for sure.  Although the workaround isn't that ugly.
16:02 jberger I try to default to // for default values
16:02 jberger so that I don't accidentally screw it up when 0 is a valid case
16:03 jnap exactly just in my real life code 0 never really comes up :)  But not that big a deal I guess
16:03 jberger for me, usually when 0 is valid it is also the default
16:04 jberger so $item // 0 and $item || 0 are the same
16:04 jnap basically I see nothing added to Perl by Porters in the last 15+ years as particularly useful, beyond UTF-8 fixes.  Sad :(
16:04 jberger but in that rare case where $item // 1 vs $item || 1 then I have to think if $item == 0 is a valid case
16:04 jberger and I'd rather not have to think
16:04 jberger __SUB__ is amazing
16:04 jnap yeah I imagine its a programmer specific thing, how you setup your code and all that
16:04 sh14 joined #mojo
16:05 jnap does it really do more than my $sub; $sub = sub { ... }?
16:05 jberger yes, because my $sub; $sub = { ... $sub ... }; leaks
16:05 jnap its a nice shortcut, no doubt
16:05 jnap sorry, weaken
16:06 jberger this was my favorite use so far: https://metacpan.org/source/JBERGER/Mojo-FriendFeed-0.05/lib/Mojo/FriendFeed.pm#L38-59
16:06 jnap it could be I'm missing something wild of course
16:07 jberger sadly $RIP FriendFeed
16:07 jberger err #RIP
16:07 jnap ah well that is the thing, you are doing a lot more anonymous functions that I do because you can count on an event loop.
16:07 jberger right
16:08 jnap so yeah, probably you find it much more useful than I might
16:08 jberger I suspect that's true
16:09 jnap isn't there a pragma to drag that feature back to older Perls?
16:11 Grinnz jnap: keys on reference has already been removed. see https://metacpan.org/pod/Perl::Critic::Policy::Freenode::DeprecatedFeatures#autoderef
16:11 Grinnz oh, pink_mist already linked the perldelta for it
16:12 Grinnz jnap: ->%* doesn't seem worth it on its own to me either, but once i saw the slice syntax, it looks much nicer
16:12 Grinnz $foo{bar}{baz}->@[0,2,5]
16:13 Grinnz instead of @{$foo{bar}{baz}}[0,2,5]
16:13 Grinnz the first looks much clearer to me
16:14 jnap Grinnz: right that particular case is better but I guess I'd suggest if you have a data structure that complex it would have been better to model it behind an object.
16:14 Grinnz jnap: Data::Munge has a rec() function which emulates __SUB__ for older perls, as long as they have weaken available
16:15 jnap the number of times I've done @{$foo{bar}{baz}}[0,2,5] in 20+ years is low :)
16:15 Grinnz jnap: perhaps, but I don't tend to use objects unless I have more reasons than that
16:15 Grinnz I have quite a bit of invocations similar to that :P
16:16 Grinnz for other features p5p have added that are significant to me, 'bitwise' is one
16:17 Grinnz the bitwise ops are vulnerable as smartmatch was to whether their operands are stringy or numbery, the 'bitwise' feature explicitly separates the two types of ops
16:18 Grinnz refaliasing is also possibly useful, though due to not having it available, I don't write code that would make use of it
16:19 Grinnz both of those will hopefully become unexperimental soon
16:19 Grinnz then there's signatures.... who knows with that one
16:21 dod joined #mojo
16:21 jnap I never use it.  I lost hope :)
16:21 jnap and I find the subs pragma good enough
16:22 Grinnz ick
16:22 Grinnz package-scoped pragmas are weird
16:24 jnap most of my clients are stuck on 5.10.x anyway
16:25 Grinnz yeah, and same when i code for CPAN. but for my personal projects i like to make use of anything that makes my code cleaner
16:27 Grinnz i make heavy use of // and //=
16:27 jnap totally.  If I found that was the case for me, I'd probably do that.  And if there ever was a perl with meaningful updates with useful syntax updates I'd probably push for it with my clients.
16:27 rshadow joined #mojo
16:27 Grinnz as 0 or empty string are very often valid at least at work
16:28 Grinnz i also like /r and package BLOCK syntax, but those aren't too difficult to emulate on older perls
16:29 Grinnz (5.14+)
16:29 pink_mist I mostly don't see a reason to support such old versions in new code, so I don't
16:30 jnap I guess its a lot about the job.  I have  three clients all on 5.10.1
16:30 jnap I never even think about the newer stuff TBH
16:31 Grinnz yeah, we're luckily on 5.18 and I'm hoping to get us bumped to a 5.26 as soon as I can get us to stop depending directly on another project
16:32 Grinnz the performance improvements alone in the last few releases have been really significant
16:33 jnap Grinnz: have you actually benched that?  that would be something I could use to convince clients
16:33 jnap I found performance dropped from 5.10 - 5.20 at least
16:33 Grinnz no, but that would be pretty specific to what your code does
16:33 Grinnz as the performance improvements are often targeted to some op or another
16:36 sri i wish subroutine signatures had become non-experimental in 5.26
16:37 jnap sri:  they don't even have a way to introspect last I checked.
16:37 sri so?
16:37 purl well, so is Ah, so!
16:37 chandwki joined #mojo
16:39 pink_mist sri: yeah, but instead they got a major overhaul and got much much faster ... I think it's worth it
16:39 sri yea, the performance boost is nice
16:39 sri and we got indented heredocs
16:39 jnap I was using similar for doing some dependency injection experimentation but maybe I'm a freak :)
16:40 sri yea, i guess introspection would be nice for architecture astronauts
16:41 sri mojolicious uses depedency injection all over the place without the need for pretentious design pattern modules
16:42 * jberger wonders if anyone uses https://metacpan.org/pod/Mojolicious::Plugin::Kavorka
16:43 sri that said, i actually wouldn't mind a role module going into the perl core
16:44 Grinnz Role::Tiny being core would be really cool
16:44 sri Role::Tiny
16:44 purl Role::Tiny is a single file
16:44 sri heh
16:44 sri just to encourage good abstraction
16:44 Grinnz yea, it alone makes me write much cleaner code
16:46 Grinnz i'd like Class::Method::Modifiers too, similarly small and very helpful for me at least
16:47 jnap sri: if you don't mind pointing me to an example of the in the code for me o look at I'd be grateful
16:48 pink_mist jnap: an example of what? dependency injection?
16:48 jnap yeah
16:50 rshadow joined #mojo
16:50 sri jnap: it's all over the place https://github.com/kraih/mojo/blob/master/lib/Mojolicious.pm#L21-L58
16:51 jnap via lazy built attributes I guess
16:51 sri the logger for example gets changed a lot
16:52 cheako joined #mojo
16:52 * sri is a sucker for minimalistic solutions
16:56 Grinnz tbh I'm still figuring out what dependency injection even means in practical terms
16:56 Grinnz I guess I never wrote enough java :P
16:57 sri goes hand in hand with the delegation pattern
16:58 sri the Mojolicious object has attributes that contain other objects, you can change those objects to others implementing the same interface, that's minimalistic dependency injection
16:58 sri Mojolicious.pm only needs to know the common interface, and depend on tha
16:59 sri t
16:59 Grinnz i see
17:02 sri modules like Bread::Board make it seem really complicated
17:03 jnap BB is probably too much for normal code but I found how Angular did dependency injection on method signatures quite fun.
17:49 schelcj joined #mojo
18:04 stryx` joined #mojo
18:11 itaipu joined #mojo
18:23 zivester joined #mojo
18:38 stryx` joined #mojo
19:02 bwf joined #mojo
19:31 itaipu joined #mojo
19:39 rooter joined #mojo
20:09 Petru_ noob question here. What's the correct way of using a database in tests?
20:11 Petru_ I
20:11 Petru_ I'm using Pg and DBIx::Class
20:12 perlpilot Petru_: "correct" is highly subjective; there are a number of techniques that people use though.   1) fixtures with known data sets.  2) mocked DB connections.  3) connection to a live DB (with known data sets hopefully)  4) some other stuff I can't think of right now.
20:12 karjala_ joined #mojo
20:13 Grinnz try Test::PostgreSQL or DBIx::TempDB
20:13 Grinnz also this isn't really mojo related :P
20:18 Petru_ sorry
20:47 cheako joined #mojo
20:49 jberger for unit tests, mocked db/model methods is probably the "correct" way
20:49 jberger but then you need integration tests too
21:00 itaipu joined #mojo
21:06 jberger for that, I recommend temporary dbs (either temporary instances or schemas etc) prepared on demand in isolation then possibly populated with fixtures
21:06 jberger and as much as you can automate that ^^ the better
21:06 jberger because that is what you are going to need to reuse
21:12 Petru_ jberger, I'm trying to use Test::DBIx::Class but I don't know how to tell mojo to use the temporary db. Here's how I try to do it: https://pastebin.com/fAQRan31
21:21 jberger Petru_: sorry, I have no experience with that module
21:21 orev joined #mojo
21:22 Petru_ which module do you recommend? I have no experience with testing in perl. I'm using Pg for the app I'm building
21:23 pink_mist Petru_: I think Grinnz already recommended you some.
21:30 chandwki is there a best practice or a good example of how to structure a mojolicious application using DBIx class?
21:31 Grinnz don't know of anything like that, most mojo examples are using Mojo::Pg or similar
21:32 Grinnz but i know people do use them together, so i bet someone could make one
21:34 prg wasn't there some sort of stub in the github wiki?
21:34 Grinnz i suspect it's pretty similar to using Mojo::Pg or DBIx::Connector with mojo; just put your main object as a state variable in a helper
21:34 Grinnz everything else works pretty much independently
21:35 Grinnz (except Mojo::Pg gives you the ability to run queries async and the others don't really)
21:35 prg chandwki: here, catch. http://mojoexample.herokuapp.com/
21:42 rperry_madison joined #mojo
21:42 marty joined #mojo
21:44 * sri added some tests to the Mojo::Pg blog example https://github.com/kraih/mojo-pg/commit/6aec77beb9d92cd6e4780e10c7c5c222a7ff1a8f
21:46 Grinnz oo good idea
21:46 rperry_madison I must be looking in the wrong area of the docs... I want a route like 'images/:image' that matches images/abc123.jpg, but I get a 404 if I add any extension.  (it works without the .jpg, but that's not what I need)
21:46 rperry_madison can anyone point me in the right direction?
21:47 Grinnz rperry_madison: https://metacpan.org/pod/Mojolicious::Guides::Routing#Standard-placeholders
21:47 Grinnz you need #image to match the dot
21:48 Grinnz also keep in mind https://metacpan.org/pod/Mojolicious::Guides::FAQ#Where-did-my-file-extension-go?
21:48 Grinnz you probably want to disable format detection
21:48 rperry_madison perfect - thanks!
22:17 marty joined #mojo
22:38 nic Did anyone write an example Mojo::IOLoop::Inotify?
22:44 pink_mist I'm pretty sure someone did 0_o
22:44 pink_mist https://metacpan.org/pod/Mojo::Server::Morbo::Backend::Inotify
22:54 sivoais joined #mojo
22:56 vicash joined #mojo
23:25 stryx` joined #mojo
23:31 vicash hello. i am developing a parser for a set of web pages that have a lot of HTML and Javascript. The HTML parsing is easy with Mojo::DOM. Is there a recommended perl module for parsing Javascript so that I can extract javascript objects from them ?
23:38 Grinnz pink_mist: Mojo::IOLoop::Inotify would be something more generic, that was discussed before
23:39 Grinnz don't remember exactly what
23:55 mgrimes joined #mojo
23:59 pink_mist oh
23:59 pink_mist must have missed that conversation
23:59 pink_mist (or forgot it :P)

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