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

IRC log for #mojo, 2017-01-05

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

All times shown according to UTC.

Time Nick Message
00:01 mmorriso Does anyone have any experience incorporating a traditional TCP socket interface into a Mojo application? I'm having difficulty working out how I can incorporate an IO:Socket client into a Mojo application to retrieve data from a legacy service
00:02 preaction wrap it in a Mojo::IOLoop::Stream object
00:04 zivester joined #mojo
00:06 mmorriso Ah I see, the events emitted by the Stream object can be handled by callbacks in standard "app->start" event loop. Thanks for that.
00:07 jberger even better, open it with Mojo::IOLoop::Client
00:08 jberger see as an example: http://perltricks.com/article/212/2016/2/2/Get-an-in-browser-remote-desktop-with-Mojolicious-and-noVNC/
00:08 jberger in which I build a TCP/websocket bridge and send vnc over it
00:08 mmorriso Thanks a lot! That's exactly what I was after
00:10 Phil21 I heard someone mentioned Filco
00:10 jberger :D
00:12 mmorriso In that example, the socket is open is driven by a request to the /proxy URI. I'd like to open my socket connection at application start and process messages received over the socket asynchronously to service content over http. I think I can see how that would work though, just pull the socket instantiation out of the callback and create callbacks for the read events
00:15 jberger mmorriso: is your application a web server?
00:15 jberger or are you just using the Mojo stak
00:15 jberger stack?
00:15 purl well, stack is in the shack having a snack with a thwack
00:15 jberger useless bot
00:15 purl Obsolete flesh creature
00:16 disputin joined #mojo
00:16 mmorriso It's a web server that serves content based on data received over a TCP socket from a legacy application
00:17 jberger you might need to drive fan your content out by using a message bus
00:18 jberger assuming your server is going to prefork
00:19 Phil21 make sure to make it blocking
00:19 jberger it does get a bit simpler if you aren't but that doesn't scale
00:19 Phil21 jberger prefers that model
00:19 Phil21 block all you want, prefork lots
00:19 Phil21 async is for hipsters
00:19 * jberger slaps Phil21 with a mackerel
00:19 mmorriso That's sort of how the current implementation works. One thread to retrieve data from the socket, into shared memory and then served via a service built on HTTP::Daemon
00:49 aborazmeh joined #mojo
01:18 blop joined #mojo
02:37 cpan_mojo Mojo-Weixin-1.2.6 by SJDY https://metacpan.org/release/SJDY/Mojo-Weixin-1.2.6
02:42 cpan_mojo Mojo-Webqq-2.0.1 by SJDY https://metacpan.org/release/SJDY/Mojo-Webqq-2.0.1
03:11 noganex_ joined #mojo
04:40 tuna joined #mojo
05:04 dboehmer joined #mojo
05:07 aborazmeh joined #mojo
06:26 dod joined #mojo
06:33 dod joined #mojo
07:00 dod joined #mojo
07:11 dod joined #mojo
07:12 Vandal joined #mojo
07:25 trone joined #mojo
07:53 AndrewIsh joined #mojo
08:08 marcus phil21++ # :D
08:50 janl joined #mojo
08:58 sri oalders: you sure Net::HTTP should suggest IO::Socket::INET6?
08:59 janl sri: if you want it to support ipv6?
08:59 sri IO::Socket::IP is the good one
09:06 marcus Which one is the bad and which one is the ugly?
09:07 janl perl is the obvious ugly :p
09:07 marcus purl, i love you.
09:07 purl marcus: sorry...
09:20 osfabibi_ joined #mojo
09:36 osfabibisi joined #mojo
09:38 kes joined #mojo
10:24 * coolo was trying to run tests offline - and they got stuck. And now that I'm online, the next thing that popped up at the place they were stuck is "you want to update mojoliciou to 7.14".
10:24 coolo And the truth is, I don't. I want to hurt the one who added that online requirement to mojo startup :)
10:33 coolo ah, that is version command
10:58 sri huh?
10:58 sri coolo: the version check only runs when you run the version command
10:59 coolo sri: I do as part of testing. it appeared the simplest way to trigger asset generation
11:00 sri lol
11:00 sri at least use the eval command or so
11:01 coolo see script/generate-packed-assets
11:02 sri https://i.stack.imgur.com/jiFfM.jpg
11:03 batman coolo: asset generation..?
11:03 coolo sri: changed now to eval 1+0 :)
11:03 sri https://github.com/os-autoinst/openQA/blob/master/script/generate-packed-assets
11:03 batman coolo: maybe you want something like this instead? https://github.com/Nordaaker/convos/blob/master/t/build-assets.t
11:04 sri that's the script he was talking about
11:04 coolo batman: filling the cache
11:06 coolo sri: only indirectly. I do the same in full stack tests to avoid timeouts
11:09 sri hope i get around to working a bit on openqa again soonish.... this translation stuff is annoying the hell out of me :S
11:11 yukikimoto joined #mojo
11:14 sri coolo: so, what's your hackweek project?
11:15 sri just noticed the site is up https://hackweek.suse.com
11:24 coolo it always is
11:24 coolo they only change the css :)
11:26 coolo sri: Milli wants a coding competition as part of the week and I guess I will drive it. I have some ideas there
11:27 sri i mean the date has been updated ;p
11:28 coolo ah, it was announced shortly before christmas
11:28 janl what? the new year?
11:28 janl SuSE 2017?
11:31 coolo we even have new calendars :)
11:37 janl penguinical calendars?
11:48 kes jberber: Here some thoughts about the route matching improvement: http://stackoverflow.com/a/41484179/4632019
11:49 kes The Controller object should not be required to find matched routes for given method/path
11:54 kes or If controller is not supplied we may just skip routes with over conditions. In any case it is not quite correct to call condition in DEFAULT controller context instead of specified context of current route
12:04 coolo sri, batman: you guys broke my tests
12:04 batman really?
12:04 coolo 11:37:18] t/09-job_clone.t ........................ Mojo::Home::rel_dir is DEPRECATED in favor of Mojo::Hom::rel_file at /home/travis/perl_modules/lib/perl5/Mojolicious/Plugin/AssetPack.pm line 28.
12:04 coolo Failed test 'no (unexpected) warnings (via done_testing)'
12:05 sri testing for warnings is not a great idea
12:05 Lee tests++
12:05 Lee now know it's deprecated :p
12:05 batman i think it's a bad idea as well.
12:27 sri new perl releases might add new warnings, that's why we never ever use fatal warnings
12:27 sri warnings are warnings for a reason, testing or making them fatal just won't end well for you
12:28 Lee testing for warnings is fine if the scope is isolated, if you're depending on something else in that scope then you're asking for problems
12:28 sri if you're ok with the next perl release breaking your stuff
12:29 Lee that's what tests are for
12:29 Lee hence...
12:29 purl i think hence is clarity and precision.
12:29 sri no, with those tests you're forcing immediate action
12:29 sri which might be expensive
12:30 sri if that cost is acceptable to you, sure, go for it
12:30 sri warnings would be visible in test output anyway
12:30 sri but no immediate action would be required
12:31 sri for coolo the cost right now is that he has to block the next mojo release, possibly delaying important bugfixes
12:31 sri totally avoidable cost
12:31 Lee yeah, but given how quick the deprecation cycle in mojo is fixing *that* is probably a priority too
12:32 sri immediate vs 3 months
12:36 Lee IME 3 months is effectively immediate anyway
12:37 Lee (not a complaint BTW, just an observation)
13:27 jberger kes I have no idea what you are talking about and I'm not sure why you always highlight me
13:34 marcus it's because we love jberger
13:34 marcus so we jberger every setence
13:34 marcus our precious (jberger)
13:38 kes marcus ++
13:38 marcus jberger++
13:57 irqq joined #mojo
13:59 cpan_mojo Test-Mojo-Role-Selenium-0.06 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Test-Mojo-Role-Selenium-0.06
14:13 gryphon joined #mojo
14:13 Pyritic joined #mojo
14:14 jberger Awww thanks marcus
14:19 jamesaxl joined #mojo
14:27 user_9853 joined #mojo
14:27 user_9853 I have a question about Mojo::Mysql
14:27 user_9853 my $results = $db->query("select * from api WHERE api_key = \"$api_key\"");
14:28 user_9853 If one would write $api_key as :  _"; DROP TABLE_ api  (or similar)
14:29 user_9853 how to protect against it?
14:30 user_9853 or am i wrong?
14:30 nic you missed a ';' after 'api'
14:31 user_9853 I don't think this will protect against a mysql injection ;s. How can i sanitize the input like in PHP with bindparam()
14:33 Lee user_9853: https://metacpan.org/pod/Mojo::mysql#SYNOPSIS # second example
14:33 Lee use bind params
14:34 jabberwok joined #mojo
14:34 user_9853 Ah
14:34 user_9853 I missed that thanks
14:35 user_9853 Single $db->query has autocommit by default, right?
14:35 user_9853 I don't need to handle the transaction stuff, like begin->transaction
14:36 user_9853 unless I add more queries to a single transaction then $db->begin
14:36 user_9853 -single
14:38 marcus You're welcome, jberger.
14:39 bwf Typo in deprecated message:  https://github.com/kraih/mojo/blob/master/lib/Mojo/Home.pm#L57
14:39 bwf Mojo::Hom::rel_file -> Mojo::Home::rel_file
14:42 khfeng joined #mojo
14:42 zivester joined #mojo
14:42 jabberwok Reviewing the Mojo::File commits I again stumble across the cringe-worthy comment (# "Bender: Bite my shiny metal ass!") -- Profanity has no place in professional code. Maybe I was raised with Victorian sensibilities but I don't like seeing words like that.
14:59 hassmaschine joined #mojo
15:01 vicash user_9853: use this: $db->query('SELECT * FROM api WHERE api_key = ?', $api_key);
15:03 Lee jabberwok: https://www.youtube.com/watch?v=-pRnQYS0S5c
15:08 asarch joined #mojo
15:09 jabberwok Lee: it's still profanity.  Is that what passes for "comedy" nowadays?  Sad.  Jack Benny would never have used such language.
15:09 Lee http://www.quickmeme.com/img/f2/f21553d8d6669bbeadcbae4f6ef9e53ea96453052a410cde3623a7a561724e3e.jpg
15:10 jabberwok I am serious.  It pains me to see foul language used in a high-class project like Mojolicious.
15:11 Lee take it up with the core devs
15:11 Lee it pains me more to see extraneous comments in code
15:11 jabberwok It's just disappointing.
15:12 jabberwok i do like how Mojo::File is shaping up.
15:13 nic does 'ass' hold any meaning outside USA, other than the donkey relative?
15:14 nic to me it's just quaint dialect, like trashcan and sidewalk
15:19 disputin joined #mojo
15:21 jabberwok I would have been sent to bed without supper if I had said "ass" (meaning buttocks) in that context
15:22 perlpilot submit a patch to edit the comment to read:  # "Bender: Bite my shiny metal [behind]!"   ;-)
15:22 jberger jabberwok I'm sorry it offends you but generally it is seen as a fairly mild swear
15:23 jberger The quote comments in the core are just for fun, that quote is pretty iconic for the character
15:23 jabberwok I know. I'm not pushing. It's just disappointing how society has grown cruder over the past few decades.
15:23 jabberwok case closed on my part
15:26 perlpilot jabberwok: I remember when I was a teenager (1980s) a friend's mom said "crap" and then apologized for swearing.  I think the norm for crudeness is highly variable.
15:29 jabberwok *nod*  I really went without supper once for saying "suck" other than meaning to drink via straw
15:29 hassmaschine can I ask a mojolicious question? ;)
15:29 jabberwok oh please
15:30 hassmaschine I'm new to Mojo - stuck on something that's probably simple.  I'm trying to clear "stash" of a hash reference that I've passed to a template.
15:32 hassmaschine $self->stash(characteristics => \%characteristics);
15:33 hassmaschine I need the hash reference to be deleted after the template is rendered.  I've tried several things - including delete $self->stash->{characteristics};
15:33 good_news_everyon joined #mojo
15:33 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vMGO7
15:33 good_news_everyon mojo/master 7221281 Sebastian Riedel: fix typo in deprecation message
15:33 good_news_everyon left #mojo
15:36 sri jabberwok: WHY DO YOU HATE DONKEYS?!
15:39 sri hmm, a user called hatemachine (in german) coming from mibbit... think i'll pass
15:40 hassmaschine it's a musical reference. :)
15:41 jabberwok sri: I merely was pointing out that impolite language is impolite, despite modern "popular" culture.  next topic please.
15:42 sri well, fuck, i learned english from american tv shows and cat memes
15:43 sri ¯\_(ツ)_/¯
15:52 sri hahaha, a quick review of the $8999 laptop from yesterday https://www.youtube.com/watch?v=VgjyCLNCY_I
15:54 Zen_ Who buys such a laptop
15:56 mishanti1 Someone.
15:56 purl someone is high.
15:56 mishanti1 That's why they make them. :)
15:58 Zen_ I have repaired many Acer laptops, always crappy build quality
15:58 Zen_ maybe they should focus on that instead of making some crazy specced out model
15:59 sri there are so few laptops with good build quality
16:00 ribasushi jabberwok: while indeed Jack Benny wouldn't say "ass" ( it was virtually impossible to do so given almost all recording equipment essentially falling under FCC language rulings ), his sketch material is "questionable" at best given current cultural norms
16:00 ribasushi the point being - times change: https://youtu.be/2QJxD6T9L7U?t=137
16:17 perlpilot joined #mojo
16:17 kes When error occur static files are looked in wrong place:
16:17 kes /api/v1/mojo/prettify/run_prettify.js
16:18 kes This error occur under this route:
16:18 kes $r->any( '/api/v:api' )->partial( 1 )
16:18 kes is this expected?
16:18 vytas joined #mojo
16:19 kes This static file is available as /mojo/prettify/run_prettify.js
16:20 kes and there is 404 for /api/v1/mojo/prettify/run_prettify.js
16:43 perlpilot joined #mojo
16:43 lluad joined #mojo
16:47 jberger hassmaschine: I have to agree with sri, your nick comes very close to violating our code of conduct (yes, there are ways you could argue against that), I would appreciate it if you could change it and spare any actual discussion of what to do about it
16:51 hassmaschine apologies, it's a really old name - in reference to "Pretty Hate Machine" - honestly, sri is the first person in all the years I've used it to know the meaning
16:53 sri i like nin too, but it looks super sketchy
16:54 maschine joined #mojo
16:55 maschine easy enough to fix..
16:55 sri well, i'm german
16:57 maschine I've been searching the IRC logs for examples on clearing the stash - is there a better way to pass a hash to a template than a hash reference?
16:57 sri think the stash method docs even have an example
16:58 govno joined #mojo
16:59 jberger maschine: thanks, easier to just avoid the problem
16:59 jberger maschine: what do you need to do after rendering?
16:59 jberger I ask because if your render is really "render_to_string" you can pass temporary stash args with the render
16:59 govno sri: I hope you are not using Pinto at SUSE: it is slang for "puny cock" in brazilian
17:00 jberger which has less social implication than hate machine does
17:00 jberger goodbye troll
17:00 maschine sri I've read the stash method docs and tried the example.  the code works if I run it before rendering the template, but not after?
17:06 jberger maschine: I have no problem deleting a stash key after rendering
17:08 Janos joined #mojo
17:12 jberger maschine: https://gist.github.com/jberger/fa2953a87c587eab2f48ce93251c3776
17:13 jberger in the browser I see the private key, then in the console I don't
17:14 tchaves joined #mojo
17:18 dod joined #mojo
17:40 jamesaxl joined #mojo
17:46 gizmomathboy joined #mojo
17:51 maschine joined #mojo
18:09 maschine jberger, the delete *was* working - it was another mistake that I had made.  But thanks for the example, because it led me to realize what I had done wrong. :)
18:09 jberger cool, glad it helped
18:09 tchaves joined #mojo
18:11 PryMar56 joined #mojo
18:31 disputin joined #mojo
19:19 Pyritic joined #mojo
19:28 jacoby joined #mojo
19:33 irqq joined #mojo
19:42 stryx` joined #mojo
20:30 * sri yawns
20:35 dod joined #mojo
20:43 tchaves joined #mojo
20:53 cfedde joined #mojo
21:04 jamesaxl joined #mojo
21:12 ilbot2 joined #mojo
21:12 Topic for #mojo is now ???? nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
22:31 jberger batman: where was/is the MCT repo?
22:33 jberger nm, got
22:33 jberger got it
22:43 user_9853 joined #mojo
22:57 user_9853 How can i handle in Mojo::Mysql failed database connections?
22:57 user_9853 http://nopaste.linux-dev.org/?1120493
22:58 user_9853 It's not triggered.
23:03 sri user_9853: what does the documentation say?
23:07 jberger user_9853: you also don't want to subscribe to the error handler each time you call your helper
23:09 user_9853 That could be fixed.
23:09 user_9853 $mysql->on(connection .. ) is only for estabilisehd connections
23:10 user_9853 so i don't know how i would handle an unsuccessful connection, if on(error => is wrong
23:11 pink_mist why did you name the variable $pg if it's a mysql db?
23:11 good_news_everyon joined #mojo
23:11 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vMZcG
23:11 good_news_everyon mojo/master 4bed55d Sebastian Riedel: mention subclasses
23:11 good_news_everyon left #mojo
23:13 user_9853 The problem is not the variable
23:14 pink_mist I was just asking
23:15 mortisha joined #mojo
23:15 user_9853 pink_mist: http://search.cpan.org/~harryl/Mojo-mysql-0.12/README.pod#DESCRIPTION
23:15 user_9853 Please discuss it with the author of the module.
23:16 sri no need to be defensive
23:16 jberger I don't know if harry is on irc
23:16 jberger batman is involved in that effort though
23:18 user_9853 You guys don't handle connection errors in this documentation
23:18 pink_mist user_9853: well, that's an old version of it, so maybe take a look at the latest version of the documentation instead? https://metacpan.org/pod/Mojo::mysql
23:22 user_9853 Ok, nice. But can we discuss why the author has named it $pg in earlier versions?
23:22 batman user_9853: it just dies and then your app dies and it renders a 500 internal server error
23:22 batman s/app/request/
23:23 pink_mist user_9853: we could, but that's not very interesting and it won't help solve your problem ... (I got my own query answered though, so thanks)
23:23 batman user_9853: ...since $mysql->db is a synchronous call
23:24 batman user_9853: also note that constructing a Mojo::mysql object will never fail.
23:25 batman it doesn't fail until you try to connect to the database, which is what $mysql->db() does.
23:26 user_9853 lol
23:27 batman why lol?
23:35 zivester joined #mojo
23:50 user_9853 I had to turn off RaiseError.
23:53 pink_mist from the docs: "Note that AutoCommit and RaiseError are considered mandatory, so deactivating them would be very dangerous"
23:56 whidgle joined #mojo
23:57 user_9853 It's already dangerous that I don't see any possiblity to handle a connection error.
23:57 user_9853 I. e. if you insert into 2 different databases, and the second connection fails then the application dies
23:57 pink_mist just wrap the ->db call in an eval
23:58 pink_mist and handle the error if there is one
23:58 pink_mist why is that so hard?
23:58 sri oh, i've got a fu perl trivia question :)
23:58 user_9853 It's possible but why is there an EventEmitter?
23:59 pink_mist events are for async things
23:59 sri what is faster? path('/foo/bar')->to_string or path('/foo/bar') . ''
23:59 pink_mist getting a db handle isn't an async thing
23:59 sri s/fu/fun/
23:59 pink_mist sri: I'd presume the stringification would call ->to_string eventually

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