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

IRC log for #mojo, 2017-08-24

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

All times shown according to UTC.

Time Nick Message
01:18 marty joined #mojo
01:35 wentian joined #mojo
01:36 wentian Oh
02:35 noganex_ joined #mojo
04:04 dboehmer joined #mojo
04:09 jberger So ... I'm just saying, the delay/callback api is rally simple ;p
04:10 jberger s/rally/really/
04:56 karjala_ joined #mojo
06:00 renormalist joined #mojo
06:04 marcus jberger: Futures would be simpler if await/async I suspect.
06:28 Vandal joined #mojo
06:31 trone joined #mojo
06:32 Grinnz don't feel like any of that was complicated... i was just finding a cooler way to do the first thing i said
06:36 karjala_ joined #mojo
06:42 inokenty-w joined #mojo
06:46 dod joined #mojo
06:50 jasanj Mojo::File not have a method to copy a directory to dest directory recursively ?
06:50 AndrewIsh joined #mojo
06:53 jasanj IO::All has a method copy can do this, io->dir($src)->copy($dest)
06:53 dod joined #mojo
07:50 petru joined #mojo
07:54 Lee_ joined #mojo
08:09 Lee joined #mojo
08:53 rshadow joined #mojo
09:15 Vandal joined #mojo
09:15 prg joined #mojo
09:43 sh14 joined #mojo
10:13 marty joined #mojo
10:13 gregf_ joined #mojo
10:56 tchaves joined #mojo
11:04 mariusz joined #mojo
11:28 dod joined #mojo
11:57 marty joined #mojo
11:58 marty joined #mojo
12:06 petru joined #mojo
12:32 aborazmeh joined #mojo
12:44 stryx` joined #mojo
13:03 dod1 joined #mojo
13:07 tchaves joined #mojo
13:17 gizmomathboy joined #mojo
13:18 aborazmeh joined #mojo
13:27 zerah joined #mojo
13:32 dod joined #mojo
14:14 DerAlex joined #mojo
14:19 lilybet joined #mojo
14:36 ChmEarl joined #mojo
14:47 sh14 joined #mojo
14:51 kgoess joined #mojo
15:00 kgoess joined #mojo
15:01 kgoess joined #mojo
15:25 mcsnolte joined #mojo
15:34 ashimema anything obviously wrong with this: $c->send({json => ['notification',$notification_hashref]});
15:34 ashimema it's silently failing for me.. not sending anything down the existing websocket
15:36 CandyAngel Does the json bit need a hashref instead of an array?
15:36 CandyAngel $c->send({json => { ... }});
15:37 Grinnz no reason it should
15:37 CandyAngel The examples in Mojolicious::Controller all provide a hashref
15:37 Grinnz https://metacpan.org/source/SRI/Mojolicious-7.43/lib/Mojo/Transaction/WebSocket.pm#L21
15:38 jberger its just JSON, any JSON payload will work
15:38 jberger ashimema: do you start the ioloop?
15:39 jberger (or equivalently, are you using one of the mojo servers)
15:40 ashimema I use hypnotoad
15:41 ashimema and $c->send({json => $notification_object}); works fine.. it's just wrapping is in the arrayref that makes it fail silently for me
15:42 jberger that makes no sense
15:42 jberger does it work if you manually encode to json and send it on the text op?
15:43 jberger (which is all the json pseudo-op does)
15:44 jberger in what way does it silently fail?
15:45 jberger are you talking to some browser js code or is this being tested via Test::Mojo?
15:47 ashimema sorry, got the daughter nashing at the ankles so answers are slow
15:48 jberger http://paste.debian.net/982866/
15:48 ashimema thanks
15:49 stryx` joined #mojo
15:49 ashimema random.. it's working for me locally.. think it must be an error between keyboard and screen with my colleague
15:49 sri am i the only one who views this kind of thumbs up as extremely negative? https://github.com/kraih/mojo/issues/1124#issuecomment-324648173
15:49 CandyAngel ashimema: Did you figure out your "websocket killing problem"?
15:50 jberger sri: I don't read it as that personally
15:51 CandyAngel I'm confused.. I don't see how that could be negative at all?
15:51 pink_mist me neither
15:51 pink_mist perfect use of thumbs up in my mind
15:51 ashimema I didn't manage to narrow it down CandyAngel.. but somehow it seemed to go away.. I think it may have been a local proxy or something issue
15:53 jberger that said, it conveys no new information, of course the OP would be in favor when someone agrees with them
15:55 pink_mist jberger: oh, right, it was the OP that did it
15:55 pink_mist right, then it's less useful
15:55 pink_mist I didn't notice it was the OP
16:07 sri that's what i mean
16:09 CandyAngel I still don't see how that is negative, let alone extremely so. Unless the liked post is another one of their accounts..
16:10 n16gel joined #mojo
16:10 Grinnz i would just say "poor taste"
16:11 CandyAngel It's poor taste to like that someone agrees with you?
16:11 sri CandyAngel: i asked for clarification and he just *likes* comments that agree with his incomplete proposal
16:11 sri maybe i'm too nitpicky
16:11 * sri shrugs
16:11 sri well, i'm closing the issue
16:12 sri since it's more a help thread now than a discussion about docs
16:16 CandyAngel It might not be useful or be unintentionally deceiving, but I don't see any reason to presume ill intent
16:16 CandyAngel Also, I can totally sympathise with the "I want this, but I can't think of a good enough solution" :P
16:49 petru joined #mojo
16:57 sri jberger: feel free to reopen it if you want to moderate the discussion
16:58 sri and consider the systemd .socket file approach
16:58 dod joined #mojo
16:58 sri you know, systemd socket activation
17:00 Pyritic joined #mojo
17:26 zivester joined #mojo
17:35 Pyritic joined #mojo
17:41 arcanez do people here like or hate docker?
17:54 itaipu joined #mojo
18:17 Pyritic joined #mojo
18:31 Pyritic joined #mojo
18:34 Lee joined #mojo
18:42 Lee joined #mojo
19:09 karjala_ joined #mojo
19:24 Lee joined #mojo
19:26 sri think it's pretty neutral
19:29 preaction just like all tech: it has things it's good at, and that's not always the things it's used for
19:29 tianon as someone typing from irssi inside a Docker container, I represent that remark :)
19:30 jnap I'd say docker mostly does what it claims, but it not magically pixie dust either.
19:30 preaction i mean, what it's good at is sometimes not even the things it was designed for
19:31 jnap well the whole idea of containerization isn't new either, you had them on mainframes in like the 70s I think.
19:32 jnap people sometimes get enthusiastic and think its some new great revolutionary thing that will make everything wonderful ;)
19:32 preaction there's nothing new under the sun, no ;) often i resent bad reinventions of things, but i'm not sure i'd put docker in that basket (systemd on the other hand...)
19:34 jnap well docker is more open that hardware level mainframe containers that is true.  Its not as robust though
19:35 sri it's kinda funny how the comment quality is much higher on reddit than on HN these days
19:35 preaction it's a good UI in front of the kernel virtualization APIs, basically. there are others in that space, too, but as i understand it they're not that great
19:36 preaction reddit seems to have tried to purge some of its less savory users, HN is still embracing them
19:36 sri the contrast is ridiculous
19:36 * sri has been following the btrfs discussions today a bit
19:48 karjala_ I like LXD
19:48 karjala_ but I don't know if I'm doing well
19:48 karjala_ by liking it
20:05 jnap is there a way to mark a block of test as 'don't escape' in Mojo::DOM?  For example $dom->at('script')->content("$('foo[name="bar"]').src('/ajax');");
20:06 jnap when rendering the DOM I get "$('foo[name="bar"]').src('/ajax');"
20:06 jnap which is good 99% of the time :)
20:07 pink_mist use Mojo::ByteStream 'b'; ->content(b('$(...') # untested
20:07 pink_mist if that doesn't work, I don't know what would work
20:10 Grinnz ->at('script')->replace('<script>...</script>')? dunno
20:11 Grinnz I don't think Mojo::DOM has any exceptions for bytestreams
20:12 Grinnz ah, but xml_escape does
20:12 Grinnz so depends if the bytestream object survives until then...
20:13 jnap yeah replace and b(...) didn't do it
20:13 arcanez jnap: cheating on catalyst?
20:13 jnap this is for Template::Lace
20:14 jnap I'm hacking in a basic way to fill vars into scripts since you can't manipulate script code with DOM right
20:14 sri jnap: nope, been thinking about it a few times, but couldn't find a good solution
20:15 jnap You can add stuff like <script data-arg1="" data-arg2=""? but that isn't always good
20:15 jnap figured so, hard to come up with something that isn't broken right
20:15 Grinnz the way i did it last time i needed to pass vars to js was just to add hidden form inputs and have the js read them
20:15 sri you can manually create raw nodes
20:15 sri hackish
20:16 jnap ->at(..)->[0] = 'stuff' ???
20:16 sri but a nice way to do it for attributes and text blocks would be neat
20:16 sri big problem could be performance though if you checked for bytestream objects all the time
20:17 sri ->tree->...
20:17 sri make a text node and change the type in the tree to raw
20:18 jnap right, its already borderline as it is for real temptate work, although I haven't even tried to offer patches.  I bet there's something that could be found for speeding it up.
20:18 jnap I'll think it over a bit.  Just wanted to verify there was no obvious answer :)
20:18 sri we need it in core too, so a proposal for a public api would have a very good chance https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/TagHelpers.pm#L172-L182
20:19 sri should be a similar use case to yours
20:20 sri that manually creates a Mojo::DOM tree structure
20:20 sri which... yea... not really a good idea
20:20 jnap well that gives me the basic idea
20:20 sri but we need it and had no better ideas
20:21 sri actually, i think that might be worth a todo list item
20:22 sri that said, i guess with Mojo::DOM roles on cpan manipulating the tree structure manually is going to happen a lot
20:22 sri since it's so damn efficient
20:23 sri every tiny bit of wrapper api makes the whole thing sluggish... like treebuilder
20:23 jnap right, I have a number of places in Template::Lace  that would probably be much better if I went closer to the metal
20:24 jnap xslate has this 'encoded_string' wrapper. something like that might be be terrible
20:25 sri in case you're thinking about making Mojo::DOM patches, i like to use this file for testing performance :) https://html.spec.whatwg.org/
20:25 sri parsing/rebuilding
20:25 jnap $dom->at(...)->content( is_encoded_str( $str) );    where   sub is_encoded_str { return bless \shift, 'UNCODEDSTRING' }
20:26 jnap you'd need to check for the blessed object though, everywhere...
20:26 jnap that would be my first thought
20:26 sri we have that too https://github.com/kraih/mojo/blob/master/lib/Mojo/Util.pm#L341
20:28 sri looks like Mojo::DOM::HTML already uses it in a lot of places
20:29 sri i guess $dom->at('foo')->{some_attr} = Mojo::ByteStream->new('&lt lalalala &gt') already works
20:29 sri and you should be able to manually insert Mojo::ByteStream objects into the ->tree
20:30 jnap I'll play with it
20:30 jnap there
20:30 sri push @{$dom->at('foo')->tree}, [text => Mojo::ByteStream->new('...')]
20:30 pink_mist (or b('...'))
20:31 jnap there's a number of places where messing with the tree might make it faster, like on the loops when I build an UL or OL
20:31 sri i've optimized so much in Mojo::DOM by getting rid of abstraction
20:44 marty_ joined #mojo
20:57 jnap I'm probably not holding this correctly but since TT modifies a reference directly I find: $tt->process( \$input, \%vars, \$dom->tree->[-1][1] );   actually works for this one case :)
20:57 jnap I probably don't grok the tree structure correctly
20:58 jnap yeah for speed critical stuff breaking abstraction is usually necessary.
21:16 marty joined #mojo
21:24 marty joined #mojo
21:24 Lee joined #mojo
21:34 mib_5orlvk joined #mojo
21:47 disputin joined #mojo
21:51 marty joined #mojo
22:41 mattp_ im noticing under a high load app (30-60req/sec) some requests are dropped with hypnotoad, and causing timeouts/proxy errors through apache proxypass
22:41 mattp_ i know thats a shot in the dark/could be a million things, but i havent been able to actually see where/why its happening. anyone have any ideas :)
22:42 claude joined #mojo
22:43 jberger mattp_ you'd have to do the math and figure out if you have enough workers for the load given pager load times
22:43 mattp_ jberger: load given pager? not sure I follow
22:43 jberger You have to tweak settings for different load cases
22:43 jberger page
22:44 mattp_ oh page load times
22:44 purl Sorry, I don't know load's email address.
22:44 jberger Like does each req take 1s or 0.01s
22:44 jberger And then how many workers
22:44 jberger And see if you are topping out
22:44 mattp_ most are fast, even under load. it just seems some are dropped on the floor somehow
22:44 jberger Try using wrt
22:45 mattp_ what is that?
22:45 jberger A load generator
22:45 mattp_ btw, its an api, not a web app
22:45 mattp_ ah, ok
22:46 jberger Run wrt and tweak your hypnotoad settings
22:47 mattp_ will give that a shot
22:54 pink_mist wrt? I've heart about wrk, but wrt?
22:55 Grinnz wrt is a linksys router model series
22:56 pink_mist right, I've heard about that one. that's not a load generator
22:56 Grinnz anything is a load generator if you try hard enough
22:56 pink_mist s/heart/heard/
22:58 sri mattp_: there were fixes in recent mojo versions
22:58 mattp_ sri: how recent?
22:59 mattp_ I think im on .. 7.3x .. ill check tomorrow
22:59 mattp_ - Fixed a bug where Mojo::Server::Daemon would close connections too quickly
22:59 mattp_ and interrupt requests.
22:59 mattp_ sounds promising
23:02 mattp_ i really, really hope this is it because ive been baffled
23:02 mattp_ sri, jberger: thanks
23:11 leffe joined #mojo
23:11 leffe Hi again!
23:12 leffe I have a somehow vague question
23:12 leffe I do not understand how to protect pages with login
23:13 leffe I have followed the expamples but  I don't get it.
23:13 CandyAngel leffe: Have you seen the 'under' routing stuff?
23:13 n16gel joined #mojo
23:17 leffe # Authenticate based on name parameter under sub {   my $c = shift;     # Authenticated   my $name = $c->param('name') || '';   return 1 if $name eq 'Bender';     # Not authenticated   $c->render(template => 'denied');   return undef; };   # Only reached when authenticated get '/' => 'index';   app->start
23:17 leffe Sorry for the paste, I thought it was going to be seen more clear.
23:19 leffe how is it supposed to work? routes written after under only work if sub returns true?
23:19 CandyAngel Yup
23:20 leffe it seems pretty extrange to me. how do they do this? any way ...
23:20 zerah joined #mojo
23:20 CandyAngel get '/login'; under {}; get '/loggedinonly';
23:21 Grinnz you can use group {}; around it so only the routes in the group are affected by the under
23:21 leffe The example I have is from a Lite app.
23:22 CandyAngel I don't know how the implementation works (especially in Lite), but it basically makes '/loggedinonly' only match if the under returns true
23:22 Grinnz under is an intermediate route. all routes that match it will run that route first, and then continue the routing only if the under route returned true
23:22 Grinnz all requests that match it *
23:23 leffe I'm going to check this and see if I get it now. I'll come back in a few minutes. Thanks!!
23:25 Lee joined #mojo
23:50 leffe HI again :)
23:51 leffe so group works just as under. Only it just kind of 'scopes' what is in it. Right?
23:51 CandyAngel Yep
23:51 Grinnz group is only a scope for under
23:51 Grinnz it doesn't do anything else
23:52 CandyAngel So you can do: group { under sub { is_auth() }; get '/loggedin'; }; get '/';
23:53 CandyAngel /loggedin only matches when the under is true, but '/' can match regardless
23:53 leffe yep.
23:53 leffe What I still don't get is this
23:54 leffe under '/' => {msg => 'whatever'};
23:54 leffe what is this supposed to do?
23:54 Grinnz just sets a stash value for all routes it applies to
23:56 leffe kind of decorator to all routes starting with '/' right?
23:56 Grinnz all routes start with /
23:56 Grinnz so, its just all routes
23:56 pink_mist (as long as they're not above the under)
23:56 Grinnz or outside the group scope
23:56 pink_mist yeah
23:58 leffe Reading 'Growing ...' doc, I came to an example that I don't get.
23:59 leffe my $logged_in = $r->under(sub {     my $c = shift;     return 1 if $c->session('user');     $c->redirect_to('index');     return undef;   });   $logged_in->get('/protected');

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