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

IRC log for #mojo, 2015-07-24

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

All times shown according to UTC.

Time Nick Message
01:39 absolut_todd joined #mojo
01:51 absolut_todd joined #mojo
02:53 da5id joined #mojo
02:59 noganex_ joined #mojo
04:21 berov joined #mojo
04:53 asarch joined #mojo
04:55 stuart joined #mojo
05:37 ans joined #mojo
05:50 berov1 joined #mojo
06:02 arpadszasz joined #mojo
06:12 jontaylor joined #mojo
06:16 dod joined #mojo
06:43 dod joined #mojo
06:48 dod joined #mojo
06:49 Vandal joined #mojo
06:50 McA joined #mojo
07:11 trone joined #mojo
07:15 AndrewIsh joined #mojo
07:17 eseyman joined #mojo
07:27 cpan_mojo Mojolicious-Plugin-Log-Elasticsearch-1.152051 by JUSTIN https://metacpan.org/release/JUSTIN/Mojolicious-Plugin-Log-Elasticsearch-1.152051
07:29 melo joined #mojo
07:38 berov joined #mojo
08:01 berov left #mojo
08:34 y1mmm joined #mojo
09:07 inokenty joined #mojo
09:12 berov joined #mojo
09:14 rwp joined #mojo
09:18 dotandimet joined #mojo
09:41 jnbek joined #mojo
09:57 jnbek joined #mojo
10:19 phillipadsmith joined #mojo
10:36 chansen joined #mojo
10:55 neilhwatson joined #mojo
11:09 melo joined #mojo
11:12 stephen joined #mojo
11:33 dexteruk joined #mojo
11:39 mattastrophe joined #mojo
11:50 dexteruk_ joined #mojo
11:56 mattastrophe joined #mojo
12:03 Andreas2 joined #mojo
12:13 dotandimet joined #mojo
12:18 nicomen I'm trying to alter content of possibly wrong links in after_render, but apparently I'm assuming the wrong things about encoding etc. what is $output exactly? Bytes?
12:33 bwf joined #mojo
12:45 nicomen it only happens if the content contains &#<unicode-char> in the content it seems
12:45 nicomen wonder if Mojo::DOM is expecting something from the content
12:50 nicomen ah Mojo::DOM seems to convert entities automatically
12:50 nicomen on stringification
13:09 nicomen I know this is incorrect, but it fails strangely:
13:09 nicomen perl -wle 'use Mojo::DOM; my $a = "<-?-> æøå &#10151;"; print $a; print Mojo::DOM->new($a);'
13:09 joelb joined #mojo
13:14 zivester joined #mojo
13:20 ZoffixWork joined #mojo
13:43 joelb oh wow
13:44 joelb just went to my address bar, typed "mojolicio.us tutorial", and up came the http://mojolicio.us specific search results
13:44 joelb that is smart
13:45 joelb I have no idea why they're so ugly/hard to read, but gift-horse & mouth
13:47 gryphon joined #mojo
14:16 dod joined #mojo
14:19 punter joined #mojo
14:38 Kogurr joined #mojo
15:18 absolut__ joined #mojo
15:32 berov left #mojo
15:36 inokenty joined #mojo
15:41 bjakubski joined #mojo
15:43 y1mmm joined #mojo
15:48 lluad joined #mojo
15:55 PryMar56 joined #mojo
16:13 sh4 joined #mojo
16:14 cpan_mojo Mojolicious-Plugin-WebAPI-0.03 by RENEEB https://metacpan.org/release/RENEEB/Mojolicious-Plugin-WebAPI-0.03
16:18 kaare_ joined #mojo
16:37 mattastrophe joined #mojo
16:51 dod joined #mojo
16:54 hernan605 joined #mojo
16:57 mattastrophe joined #mojo
17:03 mattastrophe joined #mojo
17:04 trone joined #mojo
17:17 disputin joined #mojo
17:20 stephen joined #mojo
17:51 marty joined #mojo
18:11 disputin joined #mojo
18:12 marty joined #mojo
18:15 jberger sri / regular minion users : do you think it is a reasonable thing to have a minion task that as its last action it re-adds itself with a start delay and use that in place of cron?
18:16 jontaylor joined #mojo
18:18 mst what does this gain you over cron?
18:19 Grinnz i'm not a regular minion user so feel free to disqualify this, but i feel "cron" has to be more robust than that, anacron/cronie account for all the gotchas
18:20 jberger mst: can I answer that by asking a different question? how do you have multiple servers (which might be the only one at a given time) and make sure that one of them does a cron job
18:20 jberger ?
18:20 jberger I suspect my first question was the B to an A/B problem
18:20 CandyAngel jberger: Unless cron is capable of distributed tasks, it sounds perfectly reasonable to me
18:21 mst jberger: I'd do that by picking a machine, probably in this case the database server since that's already a central resource, and putting a cron job on there that injected the task
18:21 mst using minion to execute it doesn't seem unreasonable to me
18:22 Grinnz you would have to guarantee that 1. the task always gets to its readd action, 2. the interval doesn't drift
18:22 mst which is why I'd prefer to use cron for the cron part
18:22 CandyAngel The only issue I see with doing cron injection is if they don't get executed, you end up with lots of inactive tasks to do the same thing
18:23 CandyAngel Which may be a problem
18:23 kaare_ joined #mojo
18:23 jberger we are setting up consul to handle service discovery DNS so actually the db might fail over to a different host
18:23 mst right, so you have your failover scripts enable the cron job on the new master too
18:23 jberger Grinnz: I don't think we mind a small amount of interval drift
18:23 mst CandyAngel: that's a problem with minion tasks full stop
18:24 jberger the first point (always add) is the more important one
18:24 thowe I can't seem to make $c->session('something') act like I would expect.  I must be missing something...  If I assign an ARRAYREF to it, it says it is an array...
18:24 mst right, not only is there a risk of the task disappearing due to a transient failure
18:24 jberger currently these jobs aren't minion at all, just on a single cron host
18:24 mst there's also the fact that now you have to invent your own pause mechanism
18:24 mst and really hope it works
18:24 mst or you could use 'comment or uncomment the crontab line'
18:25 thowe Which is OK, I guess, but then I am pushing hashrefs into that array, and when I do "foreach $thing ($c->session('something'))' the $thing end up being an array too...
18:25 jberger mst: then enable with some kind of ansible rule?
18:25 preaction does it matter if the task is run more than once?
18:25 mst basically, reinventing that bit in minion will give you different, less well understood, problems, than dealing with cron
18:25 Grinnz thowe, what "says it is an array"?
18:25 jberger preaction: generally not, but we'd rather not
18:25 preaction can it be detected if it has already run?
18:25 thowe when I debug with "ref($thing)" or "ref($c->session('something'))"
18:26 jberger preaction: that is the other option, add a table in the db which just marks the last time the job was run and let all potential cron hosts check that first
18:26 preaction if it doesn't matter, i tend to just do it both places. i'd rather have things happen twice than not happen at all
18:26 Grinnz ARRAY(foo) is an arrayref
18:26 jberger preaction: but that starts to feel like a job queue in a way, which is what had me thinking on these lines
18:26 Grinnz $c->session('foo') always returns a scalar, so it would be an arrayref in this case; you want foreach my $thing (@{$c->session('foo')})
18:27 jberger hmmmm, I wonder what sri would think of a minion proposal for repeating jobs
18:27 preaction jberger: it's a log. you're checking a log. does minion have a log? can you just check it?
18:27 thowe I'm trying to keep a record of visited accounts..  So when an account is visited, I want to add it to an array that is stored in the session.
18:27 Grinnz push @{$c->session('foo')}, $something, $anotherthing;
18:27 CandyAngel jberger: I already have minion jobs that effectively reschedule themselves
18:28 jberger thowe: foreach $thing (@{ $c->session('something') })
18:28 jberger also probably "my $thing"
18:28 thowe Grinnz, Yeah.  I have push $self->session('visited_accounts'), { 'name' => $account->customer_name, 'id' => $account->customer_id };
18:28 Grinnz don't use the ref for push.
18:29 jberger thowe: push onto arrayrefence is removed in blead
18:29 thowe But if I do foreach $thing (@{ $c->session('something') }) it tells me it is not an ARRAYREF
18:29 mst maybe it isn't yet because you didn't set an arrayref there yet?
18:29 Grinnz where have you set $c->session('something')?
18:29 jberger foreach $thing (@{ $c->session('something') ||= [] })
18:29 mst session in lvalue?
18:29 thowe when I start with $self->session( 'visited_accounts' => \@visited );  it tells me $self->session( 'visited_accounts') is an array, not an arrayref
18:29 jberger mst: ah good point
18:30 mst thowe: "it tells me" is vague. please be specific
18:30 Grinnz thowe, "what" tells you?
18:30 jberger foreach my $thing (@{ $c->session->{something} ||= [] })
18:30 Grinnz it is never an array, that's not physically possible
18:30 mst thowe: you're flailing and thereby forgetting to give us context
18:30 thowe sory, When I don't get what I expect I am using "ref($c->session('whatever'))"
18:30 thowe see above comment
18:30 Grinnz [14:26:12] <Grinnz> ARRAY(foo) is an arrayref
18:31 mattastrophe joined #mojo
18:31 jberger ref gives you the type of reference
18:31 jberger or more like the type of the thing that the reference point to
18:31 jberger but the scalar is still a refernce
18:32 thowe should this work:  $self->session( 'visited_accounts' => \@visited );   Followed by this: push $self->session('visited_accounts'), { 'name' => $account->customer_name, 'id' => $account->customer_id };
18:32 Grinnz don't push to the reference
18:32 thowe I'm expecting to work with an array of HASHREF
18:32 Grinnz [14:27:41] <Grinnz> push @{$c->session('foo')}, $something, $anotherthing;
18:33 jberger thowe: have you read perldoc perlreftut?
18:33 jberger I highly recommend it
18:33 thowe Grinnz, When I try that it tells me it isn't an ARRAYREF
18:33 preaction ARRAYREF isn't a reftype
18:33 thowe I get an error from Mojo that it isn't an ARRAYREF
18:34 jberger thowe so what is it?
18:34 preaction because you tried to treat it as one, and it's not
18:34 Grinnz can you paste the code and the error, you are transcribing this badly
18:34 thowe An array, apparently.  YEah, it's in like three files...  Your telling me all the things I expect to happen, but can't seem to get to.
18:35 Grinnz it is not an array.
18:35 Grinnz functions in perl cannot return arrays, they return scalars or lists of scalars
18:36 Grinnz in this case, ->session only returns a scalar
18:36 mst thowe: how about you start with a trivial example
18:36 dotandimet joined #mojo
18:36 mst that does something like
18:36 mst $c->session(foo => [ 3 ]);
18:36 mst Dwarn $c->session('foo');
18:36 mst and build up from there
18:36 thowe also, when I try to do "grep {[something]} @$c->session('foo')" I get an error that $c->session('foo') isn't an arrayref
18:37 Grinnz that would be incorrect syntax
18:37 mst thowe: start from the simplest case
18:37 thowe need the @{ } ?
18:37 Grinnz also, grep {[]} makes no sense
18:37 Grinnz not sure what you're trying to do there
18:38 thowe grep { $_{'id'} == $account->customer_id } is the code, sorry
18:38 Grinnz thowe, yes, matter of precedence. @$c->session is equivalent to @{$c}->session
18:38 thowe That's for checking that I don't add the same customer to the list repeatedly
18:38 Grinnz $_->{'id'}, the values are refs not hashes
18:38 jberger thowe: http://pastie.org/10310269
18:38 thowe er... OK, maybe this is part of where I am falling down.  Can I use postfix deref?
18:38 jberger reload that a few times
18:39 Grinnz if your perl supports it and you've enabled it, yes
18:42 amon joined #mojo
18:47 mst thowe: dude
18:47 mst thowe: stop flailing, step back, start from the simple case first
18:47 mst thowe: build the code up slowly
18:48 mst thowe: you're trying to write the entire thing at once and tying yourself in knots because you aren't sure where you're misunderstanding
18:48 thowe mst: yeah.  I think I've found I was trying to use @$ where I needed @{$}.  I'm /almost/ there now...  Just getting my comparison operators in a row now....
18:49 mst thowe: I pretty much always use the {} to avoid that particular class of mistake
18:51 thowe Yeah, but I started getting in a hurry, and I have 8 people here asking me things...  I'm trying to get in the habit of postfix deref, but I don't remember how to activate it off the top of my head, so I am starting with older syntax and will move to it here once I know I have any clue how to use the session.
18:52 thowe *sigh*  trying to code the billing system while people want me to engineer road crossings and write their contracts for them and whatever else isn't working for me.  I'm about to start workig from home...
18:53 thowe Anyway, I should stop....  Sorry
18:54 thowe Oh, and I just got it working....  Thanks for your help ,everyone.  You guys always come through for me.  jberger++ mst++ Grinnz++
18:55 mst trying to get you to stop hurrying was rather my point :)
18:56 mst also I still don't really get what the obsession with postfix deref is, at least for 'push' having the @ at the front tends to read nicer
18:56 mst push @{$c->session('foo')}, $thing;
18:56 mst versus
18:56 mst push $c->session('foo')->@*, $thing;
18:56 mst the former seems clearer to me
18:56 mst this may, however, be lack of familiarty with postfix deref
18:57 genio same here.  I still prefer @{}
18:59 thowe I have arguments in my head for both, but I'm not sure I could express them well right now.  I don't have a strong opinion yet.
19:02 berov joined #mojo
19:06 Grinnz_ well, push @<stuff> is the idiom, sort of the same with foreach; for something like $c->session('foo')->@[1,2] it makes more sense, basically when you don't care that it's an array until near the end of the statement
19:07 Grinnz_ i probably won't use it anyway until it becomes non-experimental though, i don't like having to enable syntax :P
19:08 Grinnz_ and then i probably won't use it since it will only be non-experimental in 5.24+...
19:10 mst right, for that case postfix deref makes total sense
19:31 jberger Grinnz_: it is already non-experimental in blead
19:31 jberger mst: yeah for just "give me the array" I will likely use circumfix often
19:31 Grinnz_ jberger: right, that's why i said "until it becomes non-experimental"
19:31 Grinnz_ but my next staatement is more realistic :/
19:32 jberger Grinnz_: for CPAN libraries yeah its gonna be a while
19:32 jberger or until signatures go non-experimental, then you'll be able to use them in mojo code :-P
19:32 Grinnz_ that plus i doubt we'll move to it here anytime soon, unless i manage to wrest control of our perl build
19:36 mattastrophe joined #mojo
19:37 preaction if non-experimental signatures bumps the version requirement, do we get to call a fork that's still compatible back to 5.10 Slojo and Slojolicious?
19:37 Grinnz_ lol
19:38 jberger I don't know for sure that we would move to use it in mojo core, but they are SO nice for callbacks
19:41 mst preaction: Gerontolicious, after https://en.wikipedia.org/wiki/Gerontophilia
19:41 Grinnz_ oh god
19:42 jberger there's that old japanese guy
19:42 jberger took up porn as a retirement hobby
19:43 jberger his family has no idea
20:00 Dave O.o
20:01 Dave I learned a new word, which is rare. Even rarer is the idea that I didn't want to learn that word. :)
20:05 dod joined #mojo
20:13 kaare_ joined #mojo
20:29 hernan605 gerontophile :))
21:18 yko left #mojo
21:32 trone joined #mojo
21:33 PopeFelix joined #mojo
21:35 PopeFelix Testing a new route in Mojo with Mojo::Test.  When Mojo::Test instantiates the app, is it running in a separate process from the test?
21:35 mst not normally, no
21:35 jberger (Test::Mojo)
21:35 jberger and no, same process
21:36 PopeFelix So in theory, then, I could use Sub::Override to override some method in my app and it would work?
21:36 jberger (agreeing with mst)
21:36 jberger PopeFelix: yes
21:36 PopeFelix Excellent.
21:36 PopeFelix I have a piece that communicates with a couple of external resources, and I'd like my test not to actually contact those resources.
21:37 Grinnz_ the other thing you can do is have those communication methods check some configuration, that you can set in the test
21:38 Grinnz_ $t->app->config(dont_talk_to_stuff => 1) or some such
21:39 PopeFelix Yeah, that's what I was going to do, but I think using Sub::Override is going to be cleaner.
21:39 Grinnz_ depends on your definition of "cleaner" ;)
21:39 PopeFelix ;)
21:40 PopeFelix Cleaner in that I don't have to implement a "dummy mode".
21:41 mst I'd have an object that encapsulated the communication
21:41 mst then temporarily replace that
21:41 mst you're still implementing a dummy mode, just in the t/ file (which is where I'd want it too)
21:42 jberger mocking is a valid answer for testing without external services
21:43 * PopeFelix nods.
21:43 mst a mojo equivalent of p3rl.org/Test::LWP::UserAgent would be nice if it doesn't already exist
21:44 jberger hmmm, I've never seen that
21:45 jberger yes, you can handle things in the test ua in a similar way, but it takes some deeper knowledge
21:45 jberger then again, that even assumes that PopeFelix is using external web resources, it might be db or whatever
21:46 PopeFelix They are external web resources, yes.
21:47 jberger so, you can actually make a mock external web service as a different Mojo app (inline using ::Lite probably) and attach it to the useragent
21:47 jberger but it might just be easier to mock out the method in you code that calls it
21:47 jberger depending on how that works for you
21:49 Adurah joined #mojo
21:50 PopeFelix Good things to think about, thanks.
21:52 jberger PopeFelix: https://metacpan.org/source/JBERGER/Webservice-Shipment-0.03/lib/Webservice/Shipment/MockUserAgent.pm
21:52 jberger ^^ be afraid :-)
21:53 PopeFelix LOL!
21:54 jberger then use it in tests: https://metacpan.org/source/JBERGER/Webservice-Shipment-0.03/t/usps.t
21:54 jberger kinda insane, but its helpful in the right case
21:56 PopeF joined #mojo
21:56 PopeFelix https://metacpan.org/source/JBERGER/Webservice-Shipment-0.03/lib/Webservice/Shipment/MockUserAgent.pm
21:57 PopeFelix wanted to get that to my work computer. :)
22:11 jberger PopeFelix: use that with care, NO RUNNING!
22:25 PopeFelix :D
22:25 PopeFelix I might jack around with it.
22:41 mattastrophe joined #mojo
22:50 absolut_todd joined #mojo
23:18 bpmedley jberger: May I ask what your decision was on the cron / job rescheduling issue?
23:31 mattastrophe joined #mojo
23:32 bpmedley http://timkay.com/solo/ <-- Could something like this be used with a tcp load balancer that would allow for only one cronjob at a time?
23:46 preaction that's a neat solution
23:47 bpmedley preaction: Looks really sweet.  Use localhost to serialize local jobs and a remote host to serialize in some distributed fashion.  I'm not sure serialize is the correct word, in this context.
23:48 preaction it doesn't appear to let you use remote hosts, and you'd need to solve the problem of which host connects to which. zeromq might be able to help there
23:48 bpmedley preaction: Right, the code would need modification for remote hosts.
23:49 bpmedley I've never setup zeromq.  Is is there much configuration?
23:50 preaction no. it's more of a socket library
23:50 preaction with messaging patterns

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