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

IRC log for #mojo, 2015-08-30

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

All times shown according to UTC.

Time Nick Message
00:16 tempire I like those ligatures
00:16 tempire Wish they worked in any of the editors I use
00:18 Zoffix I'm still wondering how much I enjoy typing "!" then typing "=" and all of a sudden seeing both disappear to be replaced by a slashed "="
00:19 Zoffix No support for Sublime.. so.. I won't find out for a long while :)
00:19 Zoffix s/I enjoy/I'd enjoy/;
00:19 iloveyou Hey all, if I am sending JSON data in a Mojo::UserAgent POST, should this work? post->($url => json => { 'json_object' });
00:19 iloveyou I.e., my json contains { and [, etc, so should I just single quote it?
00:20 Zoffix iloveyou, you mean you're passing a JSON string?
00:20 Zoffix Decode it
00:21 * Zoffix shamelessly plugs in JSON::Meth
00:21 Zoffix But use Mojo::JSON qw/decode_json/; and then doing decode_json on your string will work
00:22 iloveyou awesome, thanks!
00:23 Zoffix Oh. I got disconnected >_<
01:00 asarch joined #mojo
01:02 jberger iloveyou: you want to render a string that is already JSON?
01:02 jberger oh, you want to post one
01:02 bpmedley jberger++ cool stuff with the mini app
01:03 jberger bpmedley: thanks
01:05 jberger iloveyou: if you already have a json encoded string just post that as the body and manually set the content type
01:34 iloveyou joined #mojo
01:58 iloveyou joined #mojo
02:01 jontaylor joined #mojo
02:14 noganex joined #mojo
02:17 iloveyou joined #mojo
02:47 didge joined #mojo
03:09 iloveyou joined #mojo
03:13 iloveyou Using decode_json (from Mojo::JSON), I get this error: Input is not UTF-8 encoded
03:13 iloveyou Now, is there any way to find out where in my input (which is huge) is causing this?
03:15 Grinnz where are you getting input from that isn't UTF-8 encoded?
03:16 iloveyou I bypassed the error doing an Encode('utf8', $data);, but I'd like to know where in $data is causing the error.
03:17 Grinnz it doesn't matter where, the whole string should be UTF-8 encoded when you receive it
03:17 iloveyou Grinnz: I'm getting it from an API that I am paying for on mashape.
03:17 iloveyou It is 99% of the time, but now and then some piece of it is causing an issue.
03:17 Grinnz with a user agent?
03:17 iloveyou yeah, Mojo::UA
03:18 Grinnz how are you retrieving the contents from the response?
03:18 iloveyou $ua->get($url)->res->json;
03:18 didge joined #mojo
03:18 Grinnz can you check what the Content-Type header is in the response?
03:19 Grinnz $res->headers->content_type
03:20 Grinnz the ->json method and decode_json assume the input is UTF-8, but if you're getting JSON in some other encoding, you should manually decode it and then use from_json
03:23 Grinnz if the Content-Type is set correctly, you could do decode_json($res->text)
03:23 iloveyou application/json; charset=utf-8
03:24 Grinnz and calling ->json gives you that error?
03:24 iloveyou ok, so is ->json not the right method for this then?
03:24 iloveyou yeah, it gives me the utf8 error
03:24 iloveyou not all the time, rarely, but it happens
03:24 Grinnz the API is broken if it is setting that content-type and it's not actually UTF-8
03:24 Grinnz you could decode it manually but it would just be a guessing game at what the charset is
03:25 iloveyou no, wouldn't be surprising honestly. A lot of bad APIs on mashape.
03:25 iloveyou well, I was able to grab what I wanted using Encode
03:25 Grinnz something like decode_json(decode 'foo', $res->body), with decode from Mojo::Util, and whatever encoding instead of foo
03:26 Grinnz using Encode how?
03:47 didge joined #mojo
03:53 zivester joined #mojo
04:03 iloveyou joined #mojo
04:03 iloveyou Sorry, I'm just doing $json = Encode 'utf8', $json;
04:04 iloveyou from what I got from the API
04:04 iloveyou I tested with other JSON modules and none of the ones I tested worked.
04:11 Grinnz and $json is what you get from $res->json?
04:11 Grinnz or no, $res->body
04:12 Grinnz $res->json is not a string
04:27 didge joined #mojo
04:32 PryMar56 joined #mojo
04:50 iloveyou joined #mojo
05:10 jzawodn joined #mojo
05:15 didge joined #mojo
05:34 kaare_ joined #mojo
06:03 iloveyou joined #mojo
06:05 PryMar56 joined #mojo
06:18 didge joined #mojo
06:36 berov joined #mojo
06:55 asm35 joined #mojo
07:09 stryx` joined #mojo
07:10 Vandal joined #mojo
07:14 iloveyou joined #mojo
07:46 iloveyou joined #mojo
08:43 iloveyou joined #mojo
08:49 amon joined #mojo
09:47 meshl joined #mojo
09:52 iloveyou joined #mojo
09:55 sh4 joined #mojo
10:36 trone joined #mojo
10:46 trone joined #mojo
10:49 melo joined #mojo
10:58 dod joined #mojo
11:03 dod joined #mojo
11:26 sri support for non-blocking operations in router conditions would be interesting
11:26 sri perhaps similar to how we did it for under
11:28 sri if anyone is looking for a project to get to know the router inside out
11:29 sri (i don't actually know how to do it)
11:43 Zoffix :)
12:09 romel joined #mojo
12:11 Corgi joined #mojo
12:41 dod joined #mojo
12:44 meshl joined #mojo
12:46 cpan_mojo Mojo-IOLoop-ProcBackground-0.06 by BPMEDLEY https://metacpan.org/release/BPMEDLEY/Mojo-IOLoop-ProcBackground-0.06
13:11 iloveyou joined #mojo
13:22 lluad joined #mojo
13:26 asm35 joined #mojo
13:28 kaare joined #mojo
13:31 omega_ joined #mojo
14:19 jabberwok sri: am no expert at non-blocking, but in looking at Routes::Route.pm the thought occurs that a plugin to construct partial sitemaps of even dynamically-created controllers might be possible.
14:25 jberger jabberwok: two things, one, sri was talking about router conditions which are a very specific concept and very different from site maps
14:26 jberger two, making a sitemap from the router suffers from the same problem that I asked of the author of that testing module a while back: how do you handle placeholders?
14:35 ZoffixWork joined #mojo
14:38 ajr_ joined #mojo
14:55 meshl joined #mojo
15:04 asm35 joined #mojo
15:07 jontaylor joined #mojo
15:17 PryMar56 joined #mojo
15:18 Corgi joined #mojo
15:19 iloveyou joined #mojo
15:30 iloveyou joined #mojo
15:31 batman jberger: You don't include routes with placeholders in a site map
15:31 batman :)
15:31 batman Not sure why anyone would make a dynamic site
15:31 batman Map
15:32 jberger batman: I guess that's true
15:32 batman I think a design map should be designed, not generated
15:32 jberger though I stand by my question for automagic generation of tests
15:32 batman s/design map/site map/
15:32 batman Sure. That makes sense
15:36 ZoffixWork is cpan_mojo dead?
15:36 ZoffixWork It's announcing anything
15:42 iloveyou joined #mojo
15:43 asarch joined #mojo
15:53 jontaylor joined #mojo
15:59 ZoffixWork joined #mojo
16:01 ZoffixWork I'm curious, how would people run my application? (RE: http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Making-your-application-installable )
16:01 ZoffixWork Currently, I just use `hypnotoad script/XTaTIK`  ... but where would I point hypnotoad if my app is installed?
16:03 mst 65
16:03 ZoffixWork 65 windows 0.o
16:04 mst this irssi setup has <100 reserved for channels
16:04 mst I should really get around to re-consolidating, I've got too many channel windows off in the 3/4/500s atm
16:04 ZoffixWork :O
16:04 zivester joined #mojo
16:05 mst irssi is my panopticon
16:06 jberger ZoffixWork: this is how I document for galileo: https://metacpan.org/pod/Galileo#RUNNING-THE-APPLICATION
16:07 ZoffixWork jberger, thanks
16:08 sri jberger: seems like a bad idea to do "hypnotoad `which myapp`"
16:08 sri where does the pid file go?
16:08 jberger sri: you've said that before
16:08 jberger hmmm, that's a good questoin
16:09 mst ZoffixWork: I would use a Daemon::Control start/stop script and then write a small script that installs that
16:09 mst i.e.
16:09 mst sudo xtatik-create-service
16:10 jberger actually pid managment has been a difficulty for me since you can only specify that via config file and typical I start hypnotoad via rc script
16:10 sri jberger: i guess ideally you would have a config file with a sensible default for the pid file
16:12 mst surely you can just tell hypnotoad not to write a pid file?
16:13 ZoffixWork Seems like the guide needs to be updated to say you need to rename 'script/' to 'bin/'. cpanm doesn't seem to be installing executables that are in script/ in the distro: http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Making-your-application-installable
16:13 mst ZoffixWork: that's nothing to do with cpanm
16:14 mst cpanm doesn't install executables
16:14 mst MakeMaker does that, and can handle script/ fine if you configure it right
16:14 ZoffixWork Ah
16:14 ZoffixWork k
16:14 mst for example, Eval::WithLexicals bundles a tinyrepl script
16:16 mst ZoffixWork: https://metacpan.org/source/HAARG/Eval-WithLexicals-1.003005/Makefile.PL#L43
16:17 ZoffixWork I've just renamed mine to bin/ :)
16:17 * ZoffixWork is a Dist::Zilla baby
16:17 ZoffixWork I just let the magic happen :)
16:23 iloveyou joined #mojo
16:23 jberger hehe, Dist::Zilla is supposed to be unopinionated, but is complex enough that most people choose to use the defaults ;-)
16:23 mst hence why there's Milla for a normal-ish set of defaults
16:24 jberger we just did a "build tool shootout" at chicago.pm
16:24 jberger I represented your favorite system :-{
16:24 jberger :-P
16:24 jberger but other people presented dzil and minilla
16:29 sri plain EU::MM 4 life!
16:29 sri get off my lawn
16:29 * mst is still happy with Distar, tbh
16:30 mst but also very happy there's things like dzil so people who want to do complicated things can do them ... far far away from me ;)
16:30 ZoffixWork :D
16:31 * sri remembers when he was pushing for more Module::Install use
16:31 sri still like the DSL
16:33 thowe joined #mojo
16:33 mst yeah, hence why Distar provides a few DSL-y bits
16:33 mst I keep pondering adding more, but it gets more complicated
16:33 thowe mst, hey.  How are you?
16:33 mst would need to bundle data into inc/ or something
16:34 mst thowe: eh, tired, about to start departure prep for ::EU
16:36 thowe Nice.  Get some rest.  You giving a talk or two?
16:36 mst yeah, an updated version of the ::NA talk
16:36 mst which, annoyingly, is going to be "and I've got a design that solves the problems I identified, but it isn't fully implemented yet"
16:41 preaction sri++ # EUMM4EVA
16:45 iloveyou joined #mojo
16:51 asm35 hi, is there a way to provide only a hashref to the select_field tag helper and automatically gets it generate the <option> tags ?
16:52 asm35 sorry, found how to do it! don't bother
16:55 espen joined #mojo
16:58 batman ZoffixWork: what should it announce?
16:59 ZoffixWork batman, http://fpaste.scsys.co.uk/497804
16:59 ZoffixWork And I'm about to push my first release of XTaTIK :)
16:59 batman ZoffixWork: i'm starting hypnotoad with toadfarm
17:00 batman it handles all the pid stuff and has the same "interface" as an init script
17:00 batman ZoffixWork: https://metacpan.org/pod/Toadfarm
17:01 ZoffixWork I recall doing something with it: https://github.com/XTaTIK/XTaTIK/blob/master/lib/XTaTIK/Utilities/ToadFarmer.pm
17:01 batman i'm not sure, but maybe your module isn't showing up because it depends on Mojo::Base and not Mojolicious
17:02 batman that looks very complicated, but whatever floats your boat :)
17:02 ZoffixWork :)
17:05 batman why do you depend on Mojo::Base ?
17:06 ZoffixWork use Mojo::Base 'Mojolicious::Plugin';
17:07 ZoffixWork I think I just copied that from some other plugin... Is that not the right way?
17:07 mst wouldn't 'use Mojolicious::Plugin -base;' work?
17:07 jberger mst: no
17:07 ZoffixWork ¯\_(ツ)_/¯
17:07 jberger ZoffixWork: the Mojolicious package is the only one that declares a verison number
17:07 mst jberger: oh, I thought Mojo::Base's import extended to that
17:08 batman ZoffixWork: i meant here https://metacpan.org/source/ZOFFIX/Mojolicious-Plugin-FormChecker-1.001002/Makefile.PL#L20
17:08 jberger well, it might, but I've never used it that way
17:08 * jberger checks
17:08 mst the code looks like it will
17:08 ZoffixWork batman, ah. That's autogenerated by Dist::Zilla
17:08 jberger the documentation all says to use it the other way
17:09 mst perl -E '{package Class; use Mojolicious::Plugin -base} say for @Class::ISA'
17:09 mst yep, works
17:09 mst intentional or otherwise :)
17:09 batman indeed it does. that's very cool.
17:10 batman ZoffixWork: anyhow. that's why it's not announced.
17:10 pink_mist if the module in question doesn't implement its own import(), it would, since the module in question will get an ISA Mojo::Base
17:11 mst well, personally, I really dislike things being both superclass and exporter but ... if you're doing the Spiffy pattern then you may's well run with it
17:11 ZoffixWork batman, thanks :)
17:11 jberger mst: cool
17:14 meshl joined #mojo
17:25 iloveyou joined #mojo
17:31 guru joined #mojo
17:52 ZoffixWork Well... What started as a fevered dream of a madman has now actually allowed me build a functioning, custom-themed eCommerce site with 13 lines of config, 13 lines of SASS, and 3 images of logos....
17:52 ZoffixWork Mojolicious++ XTaTIK++
17:53 ZoffixWork Come to think of it.. I've made it so easy, my $boss can now replace me with a mimimum-wage teenager...
17:53 ZoffixWork http://abstrusegoose.com/563
17:53 cpan_mojo XTaTIK-0.001001 by ZOFFIX https://metacpan.org/release/ZOFFIX/XTaTIK-0.001001
17:53 ZoffixWork \o/
18:24 jberger ZoffixWork++
18:25 jberger hehe, you used my "Technologies Used" section
18:26 jberger looks great
18:26 jberger I like the demo too!
18:29 jberger Zoffix: I hope you blog (heavily) about it
18:29 jberger and speaking of that, here is my first cut of a blog post about my email demo: https://gist.github.com/jberger/df58fbbafdc964d9cbf3
18:31 mst jberger: flash considered harmful; see Catalyst::Plugin::StatusMessage for a non-awful approach to the same thing
18:32 mst the authors of Catalyst's flash feature all regret having helped make it exist; please don't copy our errors
18:35 jberger That only needs the token? So it must be db backed?
18:36 jberger Oh nm it does use the season
18:36 jberger Session
18:36 Grinnz 'tis the session
18:37 jberger Is the catalyst session a signed cookie too
18:37 jberger ?
18:37 jberger Grinnz++
18:38 mst jberger: that entirely depends on how you configure it
18:38 mst but the point is to use an id rather than just a name
18:38 mst because otherwise you get user-hostile UI behaviour
18:39 mst (notably - multiple tabs + flash -> FML)
18:40 jberger Well I'll keep that noted, but for this demo I'm already shaving enough yaks
18:41 jberger Unless there is a mojo plugin already available
18:42 mst I'm not sure; I know there's now a flash replacement plugin for Dancer2
18:42 ZoffixMobile joined #mojo
18:42 mst I'm not sure if the Mojo ecosystem has one yet
18:43 ZoffixMobile Why exactly is flash bad?
18:45 mst once you start relying on it you often end up using it for things that absolutely assume the user will only traverse a particular set of HTTP requests once
18:45 mst this falls down with page prefetching in browsers, and it also faceplants hard when a user has multiple tabs open
18:45 ZoffixMobile Hm. I'll keep that in mind.
18:45 mst and I'm fairly sure there's one other failure mode I've seen in the wild that I can't quite remember, but I was already done with it by that point
18:46 mst it was a rails 'feature' that Catalyst::Plugin::Session copied years ago and sadly everybody else seems to have to duplicate the mistake at least once ;)
18:46 ZoffixMobile Heh
18:47 mst jberger: I don't honestly mind it for demoware, I just think it's the sort of thing you need to warn people not to use in production if they care about user-friendliness
18:51 sri mst: please watch your language
18:53 mst sri: yep, sorry, so used to that website my brain doesn't expand it that far, will try and avoid that one in future
18:53 Grinnz i don't see any plugin that does the URL token thing, so that might be a good one to write
18:56 jberger mst: you bring up a good point with page prefetch
18:56 jberger How well does that place with the single consumption model of this plugin?
18:57 didge joined #mojo
18:57 jberger Sorry s/place/play/
18:57 mst ah, but you see, the plugin uses ?msgid=$id so the prefetched one without won't be mistakenylu used
18:58 jberger (You can always tell when I switch to my cell)
18:58 jberger Prefetch requests don't include query parameters?
18:59 mst I am unsure what you're imagining here.
18:59 jberger Maybe I'm not imagining a sensible thing
18:59 mst a prefetch request would follow a link
19:00 mst provided the POST+redirect redirects to something with ?msgid=$id with a $id that has not previously been seen
19:00 mst there's no way that could ever have been prefetched
19:00 mst and lo, do things work fine AFAICS
19:01 sri i believe prefetch can actually cause a race condition
19:02 mst given a StatusMessage style setup I don't believe it can
19:02 sri if the user clicks the link while it is being prefetched, the browser will kill the request and make a new one
19:02 mst the trick is to ensure such pages never actually get prefetched
19:02 jberger No, I believe that Prefetch breaks flash, I'm trying to understand how it doesn't break the catalyst plugin
19:03 sri same principle, same breakage
19:04 mst given StatusMessage redirects with a newly generated id that hasn't previously been seen before
19:04 mst that won't get prefetched
19:04 sri https://developer.mozilla.org/en-US/docs/Web/HTTP/Link_prefetching_FAQ#What_happens_if_I_click_on_a_link_while_something_is_being_prefetched.3F
19:04 mst yes. but it won't be being prefetched.
19:04 mst so that isn't relevant
19:05 mst I'm unsure what sequence of events you're imagining here but nothing I can come up with would trigger that problem
19:05 sri it's a theoretical race condition
19:06 jberger Oh, because it's used in a redirect, not in an otherwise rendered page
19:06 jberger Got it
19:06 mst sri: yes, but only if the link is being prefetched
19:06 sri yes
19:06 mst since the ?msg=$id versioln is never seen before the redirect
19:07 mst I don't see how it could be being prefetched
19:07 mst unless the browser has a TARDIS
19:07 mst which would be awesome but I'm pretty sure they don't
19:08 sri that's not any better than the flash though
19:08 sri just use the appropriate headers to prevent caching
19:09 mst it was the multiple tabs case biting production users that resulted in StatusMessage being written
19:09 * Grinnz avoids all of this by doing stuff through a JSON API from javascript
19:09 mst the subsequent conversation was merely "why isn't StatusMessage broken by prefetch too?"
19:10 mst though I still regard it as better because I don't have to remember to set headers every time I want to use it in a template
19:10 mst 'set the right headers' is a perfectly reasonable approach but much easier to forget IME
19:11 sri well, most forms are submitted with POST, so caching is not an issue anyway
19:12 mst sure, but then you don't need flash at all - flash is AFAICS mostly used for redirect-after-POST style
19:12 sri right, my last statement made no sense
19:15 mst this stuff is irritatingly easy to tie yourself in knots figuring out the workflow of
19:18 Grinnz yet another reason i like the javascript way :P
19:18 Grinnz doesnt work for everything of course...
19:18 mst <3 JS for things that are 'web apps'
19:19 mst for things that are 'web sites', sometimes they still need login of some sort
19:19 sri get off my lawn
19:27 dod joined #mojo
19:36 jberger anyway, now that that is "solved" any other thoughts on my post (or Zoffix's app for that matter)?
19:38 iloveyou joined #mojo
19:40 mst the rest of it seems pretty reasonable although I'd probably start off by showing how to JFDI the mail sending and then extract it inot a minion job separately
19:40 mst but ... that may be overkill, depending
19:43 jberger yeah, that was the hardest part of the writing of the post too
19:43 jberger I could rearrange those sections
19:44 jberger also, J*DI, sorry
19:46 * mst facedesks
19:46 mst the acronym thing is something I'm going to have to adjust to on a case by case basis, I think :/
20:04 bpmedley joined #mojo
20:05 bpmedley Zoffix: XTatIK look super cool
20:10 iloveyou joined #mojo
20:14 nathanael joined #mojo
20:23 nathanael_ joined #mojo
20:26 ZoffixMobile joined #mojo
20:28 ZoffixMobile bpmedley, thanks :) It's still a very early release, but I'm already happy with the results (original goal was to create custom-themed sites with fewer than 100 lines of code; I did it with 26). It will also make things at work much easier for me :)
20:29 bpmedley That's cool.  May I ask where you work?
20:29 ZoffixMobile stevens.ca
20:30 ZoffixMobile (No, I did not build that shitty site :) much job is currently to replace it with something that doesn't cost the company thousands of dollars :) )
20:30 ZoffixMobile Ooppss.. sorry for the language
20:31 AndroUser2 joined #mojo
20:31 bpmedley That's cool.  The site merely uses some older constructs.. :)
20:31 AndroUser2 joined #mojo
20:34 nathanael ZoffixMobile: 26 lines sounds good. just joined, do you have a link?
20:35 iloveyou joined #mojo
20:36 ZoffixMobile joined #mojo
20:38 ZoffixMobile nathanael, XTaTIK on CPAN and demo.xtatik.org  26 lines isn't the full story, as I had to setup a "company theme". Though I think that config is just a few dozen lines. And since we have a dozen of sites, those 26-lines per site really pay off, as the company config and products database is shared among the sites
20:54 didge joined #mojo
21:00 talexb__ joined #mojo
21:02 iloveyou joined #mojo
21:07 howitdo joined #mojo
22:39 sri maybe someone here wants to work on the cpantesters site? http://blog.cpantesters.org/diary/199
22:47 nicomen hm
22:53 nicomen just went down again
22:53 nicomen I sent a mail to barbie
22:54 nicomen ah no, just the reports site
23:07 ZoffixMobile joined #mojo
23:07 ZoffixMobile I'd love to, but I doubt I have the skills
23:07 ZoffixMobile mst++ for helping out barbie
23:19 jberger would be cool if the mojolicious community could step up as a group
23:23 iloveyou joined #mojo
23:26 ZoffixMobile That would definitely be cool!... so... let's do it?
23:27 ZoffixMobile I'm in...
23:29 ZoffixMobile joined #mojo
23:31 ZoffixMobile Even while loitering next to some stranger's house bacuse I called a cab up to their place because I'm drunk and my underwear is causing a blister... I'm in :) I got a $20 Linode account that isn't getting any use ATM, if that's handy
23:37 bpmedley What would we need to do help with cpan testers site?
23:40 ZoffixMobile I guess step one would be to get in touch with barbie amd ask how we could help out. mst would likely already know a bit what's up
23:47 mst part of the trouble is uncertainty as to what's actually nailing the box to the wall
23:47 mst I think maybe setting up a copy of the mysql db on another system and seeing if we can repro it in a less horrible way might be a nice thing to try
23:49 ZoffixMobile Let's do it!
23:57 * mst has to fly out to YAPC::EU in 3 hours

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