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

IRC log for #mojo, 2016-02-11

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

All times shown according to UTC.

Time Nick Message
00:00 jberger wow I don't get that one
00:00 jberger the regex isn't taking that long
00:00 mspo perl6 has "token" which is nice for that kind of match
00:01 sri oh, you're right, 13ms for match
00:01 sri odd
00:01 jberger sri: what happens if you move that regex out to a package lexical?
00:01 jberger I'm saying what if it is the regexp compile time
00:02 sri 107ms to compile it? Oo
00:02 sri that's insane
00:02 jberger over and over again
00:02 sri but there is no dynamic element
00:02 jberger it doesn't have /o
00:02 jberger so it doesn't matter
00:03 sri that's not how it works
00:03 pink_mist 0_o yeah /o shouldn't make a difference; it should only be compiled once surely 0_o
00:03 pink_mist otherwise I'd call that a perl bug
00:03 sri i have no idea what eats the time there though
00:03 mspo sri: can you just split on : instead?
00:03 jberger inorite
00:04 jberger that's why I suggest it, not because I really think that but because I can't think of anything else it could be
00:04 sri mspo: what split pattern do you have in mind?
00:05 jberger /\s*:\s*/ I'd assume
00:05 jberger with a limit 2
00:06 mspo well just on :
00:06 mspo or maybe just read the string char-at-a-time until you find the :
00:06 mspo substr is usually faster than regex
00:08 jberger plus then you can just allocate the array immediately
00:08 sri patch?
00:08 jberger sec
00:11 jberger mine fails some tests
00:23 mspo is this any faster? "^(?>(\S[^:]*))(?>\s*):(?>\s*)(?>(.*))$"
00:23 mspo trying to disable backtracking
00:26 sri hmm, if i check the mode for the Time::HiRes stuff all tests still pass
00:26 sri something like that seems reasonable https://gist.github.com/anonymous/c372c84bbba92bed96bf
00:28 sri or i just make it an attribute
00:29 sri $app->timing(1) or so, with a default based on the mode
00:33 sri ok, first i'll profile an app with a template
00:33 jberger mspo: that regex passes tests
00:33 sri to see if it matters in the greater scheme of things
00:35 mspo and without trimming whitespace: my $line = $_; my $colon = index $line, ":"; my $h = substr $line,0,$colon; my $val = substr $line,$colon+1;
00:35 mspo jberger: use re 'debug' showed more steps in the output, but they were different so idk
00:36 mspo index + substr is usually fastfast
00:36 jberger I'm not setup to do profiling and I'm only on for another few minutes
00:36 jberger so if sri wants to profile that one its up to him
00:37 sri the regex makes no difference as far as i can see
00:37 jberger yeah, I didn't think so
00:38 jberger from the nytprof output the time isn't spent matching
00:39 sri profiling examples/hello-template.pl now
00:40 sri http://mojolicious.org/nytprof/index.html
00:41 sri not actually so different
00:41 sri dispatch and rendered still so high up
00:42 mspo my regex is slower in a while-loop test
00:44 mspo the index + substr is faster but I haven't handled whitespace yet; but if you're saying the regex isn't the slow part them it isn't going to do much :)
00:46 mspo I don't really know how to read that website
00:48 mspo # spent 34.7s making 1 call to Mojolicious::start  ?
00:49 sri yea, that doesn't count
00:49 sri same as EV::run
00:49 sri those call the mainloop, and therefore block forever
00:50 sri Mojo::EventEmitter::emit is similar, it executes many callbacks that do a lot of work and take time
00:51 sri you find that out by looking at the actual lines
00:51 mspo imho the thing to optimize for every web framework is ttfb or just accept -> start time
00:52 mspo so the router can be a real issue
00:52 sri the router is fast
00:52 sri dispatch and rendered actually run before the first byte is sent
00:53 sri so yea, disabling the Time::HiRes stuff would help with that
01:03 mspo is x axis time?  it looks like http://mojolicious.org/nytprof/lib-Mojolicious-pm-21-line.html#95 is slow
02:11 sri everything is labeled
03:10 noganex_ joined #mojo
03:38 good_news_everyon joined #mojo
03:38 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgr5l
03:38 good_news_everyon mojo/master 06abe8c Sebastian Riedel: the stash can be a little faster
03:38 good_news_everyon left #mojo
03:51 sri hmm, so for examples/hello-template.pl i have a change that turns 1050 rps into 1110 rps
03:51 sri it's not very elegant though
03:52 sri it's an attribute Mojolicious::diag, that defaults to sub { shift->mode eq 'development' }
03:52 sri and all ->log->debug(...) calls would become "->log->debug(...) if $app->diag"
03:54 jberger that's kinda a different paradigm though
03:54 jberger to this point I've been able to set MOJO_LOG_LEVEL=... and have that be different than MOJO_MODE if I so choose
03:54 sri yes
03:55 sri i'm not saying it's worth it
03:55 sri just something to think about
03:57 mcsnolte joined #mojo
03:59 asarch Where could I get the list of all the elements of the Document Object Model (DOM)=
03:59 asarch ?
03:59 jberger asarch: http://mojolicious.org/perldoc/Mojo/DOM/CSS
03:59 jberger oh elements?
03:59 jberger sorry I read that as selectors
04:00 jberger $dom->find('*') I think
04:02 asarch Thank you
04:02 asarch Thank you very much :-)
04:27 melo joined #mojo
04:28 sri it's easier to optimize based on this data http://mojolicious.org/nytprof/index.html
04:28 sri examples/fast.pl
04:29 sri i guess this might forever be the biggest hotspot http://mojolicious.org/nytprof/lib-Mojo-Server-Daemon-pm-177-line.html#71
04:29 sri no clue how to handle ->sockhost and friends differently
04:31 sri the parse methods are not very optimized yet, i bet there's many small things that can be changed
04:38 kivilahtio hi there! Is there any onformation on how Mojolicious deals with the app crashing? So when a route dies, where is the error message displayed?
04:38 kivilahtio If I throw an Exception from a route, where is it caught and how can I get it visible?
04:39 kivilahtio Is there any documentation about how I can control where the crash logs are written?
04:40 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Built-in-exception-and-not_found-pages
04:41 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Rendering-exception-and-not_found-pages
04:42 kivilahtio sri: thanks
05:22 zivester joined #mojo
05:54 sri looks like we've balanced out the performance losses from the refactoring
05:54 sri in fact, we even got faster
05:55 sri 6.0 vs master, from 3500 rps to 3650 rps
05:56 ribasushi I see you folks are micro-profiling
05:56 sri every now and then
05:56 ribasushi do you set clocks=2 for NYTProf while doing it?
05:56 ribasushi default is walltime, which hardly means much when you do what you do
05:57 sri nothing about clocks=2 in the nytprof docs
05:58 ribasushi because shitty API
05:58 ribasushi there's clocks
05:58 ribasushi which takes only the constant as defined by the system
05:58 ribasushi CPUTIME is 2 for linux+bsd
05:59 ribasushi errrr
05:59 ribasushi clock* (pre-coffee)
05:59 ribasushi NYTPROF=addpid=1:subs=1:stmts=1:sigexit=1:clock=2  <--- what's in my env
06:00 sri clock=2 does not appear to work on os x
06:01 sri "clock 2 not available (clock_gettime not supported on this system)"
06:01 ribasushi awwww
06:02 ribasushi well - something to keep in mind then - NYTProf shows you walltime, which on a dynfreq CPU is problematic to say the least
06:03 sri too bad
06:07 sri this is cool though... 4.0=3000rps, 5.0=3200rps, 6.0=3500rps, master=3650rps
06:27 inokenty-w joined #mojo
06:41 batman kivilahtio: I don't see how Mojo::JSON::Pointer *isn't* following the spec
06:43 batman How is the pointer "laxed"? I see that it doesn't enforce it, but it also doesn't work when you give it invalid data.
06:53 batman s/data/pointer/
06:54 kivilahtio batman: the documentation says it is a relaxed version of the JSON::Pointer?
06:54 kivilahtio did I make a translation error with laxed != relaxed?
06:55 kivilahtio batman: sorry, pushing changes to production :) it is stressful
06:55 sugar joined #mojo
06:55 kivilahtio batman: the pointer works by returning the whole data
06:55 kivilahtio batman: if you give an invalid pointer, it return the root element
06:55 kivilahtio batman: or the whole object the pointer is referencing
06:56 kivilahtio if you carefulyl read the spec you will see
06:57 kivilahtio batman: this      json-pointer = *( "/" reference-token )
06:57 kivilahtio batman: implies that there can be any amount or none of the pattern between parenthesis ()
06:58 kivilahtio it targets the pattern, which starts with / and continues with the reference-token
06:58 kivilahtio eg. /pets
06:58 kivilahtio but if you think it is too difficult, I don't think it is a biggie
06:58 kivilahtio I should have used a JSON schema validator in the first place
06:59 kivilahtio I just didn't have one at the time
07:05 batman Which part do you think I find too difficult? Reading the spec, taking your PR, ..?
07:07 kes joined #mojo
07:09 dod joined #mojo
07:10 and joined #mojo
07:12 batman sri++ # very cool :)
07:12 batman Incredible that it gets faster, even with tons of new code.
07:15 kes some problem with variable interpolation in template
07:15 kes http://paste.scsys.co.uk/505225
07:18 kes maybe someone has an idea how to fix that or suggest a workaround
07:18 dod joined #mojo
07:19 bjakubski joined #mojo
07:41 kes that is because of cache. After restart application the problem disappeared
07:46 kivilahtio batman: I mean the change. The pull request had comments that there are dependencies on this established behaviour and changing those has consequences
07:46 kivilahtio batman: and that sounds like a lot of trouble
07:48 osfabibisi joined #mojo
07:53 Vandal joined #mojo
08:00 batman kivilahtio: for me it boils down to which check gives you more than it costs.
08:05 dod joined #mojo
08:15 batman After I learned to write tests, I've almost stopped checking input.
08:16 batman Other than user input.
08:18 trone joined #mojo
08:19 AndrewIsh joined #mojo
08:24 trone joined #mojo
08:29 McA joined #mojo
08:44 kivilahtio batman: I am struggling with tests
08:44 kivilahtio batman: I am trying to make the shift to TDD/BDD
08:44 kivilahtio but it is difficult
08:47 kes >Most form helpers can automatically pick up previous input values and will show them as default. You can also use "param" in Mojolicious::Plugin::DefaultHelpers to set them manually and let necessary attributes always be generated automatically.
08:47 kes but the 'param' is not called from _input at all
08:48 kes there just: $attrs{value} = $values[-1]
08:54 batman kivilahtio: not a big fan of TDD/BDD as a general rule, but whatever makes *someone* write better and more tests is a good pattern :)
08:56 kes ah, 'set them manually' I though that I may overload 'param' from DefaultHelperl to fill some attributes automatically
08:56 batman kes: what do you mean..? https://metacpan.org/source/SRI/Mojolicious-6.45/lib/Mojolicious/Plugin/TagHelpers.pm#L70
08:57 batman kes: <% param foo => 123 %><%= text_field "foo" %> # this will end up with an <input value="123">
08:57 kes yes, I understand now
08:59 batman kes: cool :)
08:59 and joined #mojo
08:59 batman what i use it for most of the time is <% param foo => 123 unless param "foo" %>
09:00 kes I should define 'every_param' sub in my controller to generate default values from DB
09:02 kes but it seems will be safer if redefine just 'param'. And this works if I change https://metacpan.org/source/SRI/Mojolicious-6.45/lib/Mojolicious/Plugin/TagHelpers.pm#L83 to else { $attrs{ value } =  $c->param( $name ) }
09:02 kes But I do not know is it safe to do so (
09:04 kes batman: what do you think about that?
09:05 batman kes: i think that's a bad idea. why can't you just do $c->param(foo => 123) unless $c->param("foo"); in your controller?
09:08 bowtie joined #mojo
09:14 ashimema BDD?
09:14 ashimema batman driven development?
09:15 batman ashimema: haha. i think "b" stands for behaviour..? (no idea really)
09:15 ashimema aha.. :0
09:15 batman i also do wesmdd (what ever suits me drive development)
09:15 ashimema I prefer the Batman option ;)
09:16 ashimema hehe.. yeah
09:16 dod joined #mojo
09:16 batman haha. that's why we have #darkcode i guess ;)
09:16 dragos joined #mojo
09:16 kes http://paste.scsys.co.uk/505262
09:18 kes batman: because I do this in base class for all controllers
09:18 batman kes: i can't really help you more than saying i think you should solve it differently than overriding param() or every_param()
09:18 kes ok. thank you
09:19 batman sub _set_default_params { $c->param($_ => $default{$_}) for grep {!$c->param($_)} keys %defaults }
09:36 bowtie joined #mojo
09:37 batman kes: ^^
09:39 kes batman: thank you. I take it into account
09:41 batman i consider that to be a lot more robust than overriding param() or whatever
09:57 jontaylor joined #mojo
10:23 jontaylor joined #mojo
10:46 melo joined #mojo
11:01 kaare joined #mojo
11:01 kivilahtio hi there! How do I generate a GET request with POST parameters?
11:01 kivilahtio I am looking at Mojo::Message::Request
11:02 kivilahtio and looks like I need to parse a custom HTTP request
11:02 kivilahtio $req->parse("GET /foo HTTP/1.0\x0d\x0a");
11:02 kivilahtio I am testing a REST API endpoint using Mojo::Test
11:03 kivilahtio is there any other way than using $req->parse()?
11:21 * batman doesn't understand what kivilahtio wants
11:22 kivilahtio batman: nice
11:22 kivilahtio batman: I need to make a GET request with formData parameters in the body
11:22 kivilahtio batman: from the Mojo::Test
11:23 kivilahtio batman: os using Mojo::UserAgent
11:23 kivilahtio batman: rs using Mojo::UserAgent
11:23 kivilahtio batman: or using Mojo::UserAgent
11:24 batman kivilahtio: that is against the HTTP standard
11:24 kivilahtio batman: we have a simple 3rd party authentication mechanism.
11:24 kivilahtio batman: I tried to find out whether or not it is, but I never saw any standard which would forbid it
11:24 kivilahtio batman: many said that it is not recommended
11:25 kivilahtio batman: actually te HTTP request we need to test stands for: "Give me the permissions this user identified by username and password has"
11:26 kivilahtio so hence, we dont authenticate the user, we simply get the permissions he has
11:26 kivilahtio ashimema: working with constraints of a legacy system I might add
11:26 kivilahtio I mean we dont authenticate the user to our system, hence he wont be POSTing anything
11:27 batman ok
11:27 kivilahtio we GET permissions, but we cannot pass the username and password as GET parameters due to security issues
11:27 ashimema erm.. good luck ;)
11:27 kivilahtio and now that we have the system in production, we cannot just change the GET-request  parameters from formData to json-in-body
11:28 ashimema I'd suggest using https and sticking a bearer token or somthing in the headers or params?
11:28 kivilahtio this all used to work well with a previous version of Mojolicious and Swagger
11:28 ashimema I have no idea what your doing ;)
11:28 kivilahtio now I donät know if it works, so I am writing regressions tests before we migrate to the newest version
12:01 wingfold joined #mojo
12:04 melo joined #mojo
12:05 batman i really wish there was a way of writing non-blocking code and make it work in both blocking and non-blocking context.
12:06 batman Mojo::IOLoop::Delay->new(...)->wait kind of works, but not if you want to do blocking while the ioloop is running.
12:06 batman i wonder if that's a real case though
12:16 kivilahtio wow I did it!
12:17 kivilahtio Mojolicious comes to me, brick by brick!
12:17 kivilahtio I managed to make my test fail ;)
12:26 Jonis http://blogs.perl.org/users/alex_muntada/2016/02/simplest-way-of-serving-local-files-over-http.html
12:26 Jonis oh, I was scrolled way up
12:27 Jonis mojo http to serve local files from current directory would be sweet
12:29 dod joined #mojo
12:31 dod joined #mojo
12:38 batman Jonis: perl -Mojo -e'app->static->paths(["."]);app->start' daemon ?
12:47 jberger batman: the elusive "works blocking and non blocking style" has tempted adventurous coders throughout the ages
12:48 batman jberger: it *could* *maybe* work if we localized the ioloop singleton in blocking mode...
12:50 batman so you do something like local $Mojo::IOLoop::singleton = $cb ? Mojo::IOLoop->singleton : Mojo::IOLoop->blocking_singleton;
12:50 batman but... it's not very pretty :/
12:50 jberger Don't do it man! You have so much to live for!
12:50 batman I WILL NOT QUIT UNTIL I HAVE SOLVED THIS!!!!
12:50 nic /quit
12:51 * jberger sobs "we lost another one! "
12:51 batman jberger: but don't you think the local() hack would work?
12:52 batman that's /kind of/ what happens inside Mojo::UserAgent...
12:54 jberger Even if you did that it doesn't make the code independent of blocking status
12:54 batman at least if you add a couple of million grains of salt on top of "kind of" :)
12:54 jberger You still need to pass a callback that closes over arguments to return
12:54 batman jberger: no. you still have to do if ($cb) {...} but that's a minor compared to what i do now :/
12:56 batman future batman will hate me for not simply using Mojo::IOLoop->delay(...)->wait, but right now i want to explore it further
12:56 batman s/not//
12:56 jberger Mostly I've just taken to writing methods with delay wait at every level
12:57 batman nic: btw... you can use "/say" instead of " ", so "/say /quit" will not contain a space in front
12:57 batman jberger: and it seems to work..?
12:57 jberger Then the user can pass in a closure that closes over arguments
12:57 nic batman: aha, been wondering how people did that :)
12:57 batman yeah, but the user can't call the method without a $cb when the ioloop is running
12:57 batman jberger: ^
12:58 jberger Right the cb is a required usage
12:58 jberger But it then works in both cases
12:58 Jonis batman: yes, that, without all the typing :)
12:59 fortl joined #mojo
12:59 batman Jonis: alias serve_static_files="...."
12:59 nic people need to learn how to type ;)
12:59 batman jberger: cool. i will /never/ do that in a cpan module, but it might work @work
13:00 batman Jonis: also... you don't have to type. just copy/paste what i wrote ;-)
13:00 Jonis fnar ;)
13:02 batman Jonis: curl https://goo.gl/E6fZ05|sh - # mohahaha
13:03 Jonis better with a |sudo sh, for good measure
13:04 Jonis talking about sudo sh, I should letsencrypt some stuff one of these days
13:05 nic Anyone got anything mojo-ish for talking to letsencrypt?  (been away from Mojo chatter for a while)
13:08 jberger Jonis: I've got something coming on that front
13:08 jberger nic: yep
13:08 nic cool
13:09 jberger I'm in the polish stages
13:10 nic Our local supermarket has a sizeable Polish section, but I note they don't do Polish polish
13:10 jberger I'm getting ready for work but what I have is in my github
13:10 jberger It's feature complete
13:11 jberger For minimum feature set
13:11 nic sounds right up my lane
13:11 jberger It has one edge case that still has to be handled and lots of tests and doc to go
13:11 dod joined #mojo
13:11 nic pffffff, tests just slow me down
13:27 batman nic: https://metacpan.org/pod/Toadfarm::Plugin::Letsencrypt
13:27 vicash speaking of tests, is there a way to use Test::Mojo or another module to test javascript portions of a web page ? say I have to plot a chart using D3.js. how do I go about unit-testing that, if it is even possible.
13:28 melo joined #mojo
13:28 vicash or something simpler like say an element gets hidden after 5 seconds of display, how do i test that ?
13:32 Jonis vicash: you'd need to use something like browserstack for that.
13:32 vicash Jonis: never heard of it but thanks. it looks like Selenium
13:33 Jonis vicash: browserstack is one of the selenium sponsors, so yes :)
13:39 vicash is there an opinion on Selenium::Remote::Driver vs Test::WWW::Selenium ?
13:43 neilhwatson joined #mojo
13:44 nic "Use of uninitialized value $name in hash element at Mojo/Message.pm line 247."
13:45 nic When some js posts a file to my server, something calls Mojo::Message::_cache($self, 'cookies', undef, undef)
13:45 nic hah, I'm full of detail today
13:45 nic I'll probe some more
13:48 zivester joined #mojo
13:52 ramortegui joined #mojo
14:01 nic ah, apparently it's a byproduct of upgrading
14:04 jberger vicash: I wrote a phantom js integration
14:04 vicash jberger: link please.
14:04 jberger It's not as full featured as selenium but it's much easier to get working
14:05 vicash i am trying not to use selenium since i do not have that much JS in my code.
14:05 jberger https://metacpan.org/pod/Test::Mojo::Role::Phantom
14:07 jberger batman: now that I've written an acme client, I can tell you what that plugin is
14:08 jberger It just adds the ability to serve the challenge from in a data section
14:08 batman jberger: "batman" or "vicash" ..?
14:08 jberger If that's all you are going to do, just put the challenge file in your public/ directory
14:09 jberger batman you regarding that toadfarm plugin
14:09 jberger imo it's pretty useless
14:09 batman jberger: i didn't write the toadfarm plugin :)
14:09 jberger I know but you linked it
14:14 batman don't shoot the messenger!
14:14 batman ;)
14:17 Jonis -w 4
14:17 robinsmidsrod joined #mojo
14:18 jberger I didn't shoot
14:18 robinsmidsrod joined #mojo
14:23 batman jberger: j/k (sorry)
14:24 robinsmidsrod joined #mojo
14:25 jberger STICK EM UP
14:25 batman /o\
14:26 * jberger shoots nerf darts everywhere
14:27 * batman forgot his utility belt
14:28 bowtie_ joined #mojo
14:38 asarch joined #mojo
14:51 Grinnz sadly, "code that works both blocking and non-blocking" isn't any easier with futures/promises. you have the same problem where the blocking version needs to use its own mini event loop
14:51 Grinnz so far Mojo::UserAgent's way is the only way i know to solve it
14:53 mcsnolte joined #mojo
14:58 berov joined #mojo
15:01 batman sri++ #904 - i agree
15:02 * sri walks into the room and gets hit by a million nerf darts...
15:10 vicash how do I force a status 500 in a unit test ? I want to check that my custom exception.html.ep is rendered correctly.
15:10 nic $self->reply->exception(...)
15:10 nic sorry, that doesn't answer the question
15:11 nic In my real app I happen to have a route that always responds with an exception :)
15:13 jberger sri: that'll teach ya to look first
15:14 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Rendering#Status-code
15:14 jberger vicash: monkey patch the action to a sub { die }
15:14 vicash ah ok
15:14 Grinnz oh, without having a route that does that
15:15 jberger vicash: yeah or just add a die route on the fly in your test
15:15 vicash yea i figured out antoher way. i can add a custom route in the test using $t->app->routes->get('/exception' => sub { die; });
15:15 vicash yes jberger.. what you said
15:15 jberger Yep
15:15 jberger Great minds and all that
15:15 * jberger reloads
15:18 ribasushi you folks seem to have a higher-than-normal osx concentration: anyone fancies running me a smoke (just if it installs) of https://cpan.metacpan.org/authors/id/R/RI/RIBASUSHI/DBIx-Class-0.082820_01.tar.gz ?
15:23 genio give me a minute
15:23 jberger ribasushi: run tests enough or does it need to be installed?
15:23 ribasushi jberger: running tests enough (but from the tarball, not off the repo)
15:23 jberger right
15:23 jberger running now
15:24 * jberger opens a nerf barrage at ribasushi
15:24 ribasushi that reference is... lost on me :/
15:25 ribasushi ah I see
15:25 preaction https://www.youtube.com/watch?v=HlnCttr5kEM
15:25 jberger ribasushi: Successfully tested DBIx-Class-0.082820_01
15:25 genio taking a while to get through the prereqs
15:25 jberger This is perl 5, version 22, subversion 0 (v5.22.0) built for darwin-2level
15:25 binary joined #mojo
15:26 ribasushi genio: ~10 mins roughly for everything if you don't parallellise
15:26 binary Using Mojo::IOLoop::Delay's steps method, I'd like to be able to 'exit' out of the steps under a certain condition. Can I just not call $delay->begin->() to do that or should I do anything else to cleanup?
15:27 jberger binary: yes if a step doesn't call ->begin then it will not advance to the next one
15:27 preaction ribasushi: success on OSX perl 5.20
15:27 binary My program is going to be running 24/7, will everything be cleaned up ok?
15:27 jberger the finish event is then fired if you still need to do cleanup
15:27 genio ribasushi: ????   perl 5, version 22, subversion 0 (v5.22.0) built for darwin-2level
15:27 binary Ah ok, so I should call finish, great
15:28 ribasushi excellence
15:28 jberger call finish?
15:28 ribasushi preaction: since you piped up btw: there have been 0 automated OSX smokers for... about 2 years now
15:28 ribasushi just an extra data point
15:28 preaction what? i thought bingos had a whole slew of them...
15:29 ribasushi bsd: yes, osx: no
15:29 ribasushi ( it's close but not sufficiently )
15:29 preaction alright. i have been meaning to buy meself a new mac mini and dedicate it to that purpose anyway
15:29 genio hrm
15:29 sri jberger: so, did you manage to come up with a faster version of https://github.com/kraih/mojo/blob/master/lib/Mojo/Headers.pm#L107 ?
15:29 binary jberger: Oh, finish will be called anyway?
15:30 jberger binary: the delay object will emit a finish even at the completion of the last step that doesn't call ->begin
15:30 jberger preaction: you coming into the office today?
15:30 binary Ahh, I see. So it'll clean its self up if there's no begin calls at the end of the last step, and I can do extra cleanup if I need to inside a finish handler
15:30 jberger exactly
15:30 binary So there's nothing I need to do then, great
15:31 preaction jberger: yes. i'm trying to leave, but $work keeps bugging me. and i need to stop at the daley center and apply for a passport :p
15:31 jberger so I'll see you in time for the meeting then :-P
15:32 preaction if i'm lucky
15:34 hesh joined #mojo
15:38 jberger batman: you got a random link on reddit: https://www.reddit.com/r/perl/comments/453wir/applify_write_object_oriented_scripts_with_ease/
15:42 zivester joined #mojo
15:45 bowtie_ joined #mojo
15:46 jontaylor Before Mojo had its own native validation, I used to use Mojolicious::Plugin::ValidateTiny. The problem I have now is I want to move all my legacy mojo apps to use the new validation so I can standardise on whats supported. The problem is the APIs differ greatly so its going to be a lot of rework, and I can’t avoid that. From an academic standpoint what could I have done in the past, if I were wiser, to make this current task easier on myself?
15:46 nic A (js) client is uploading files to my server.  I can dump the content in $c->req->content->{parts}[0] but $c->req->every_upload is empty
15:46 nic Does that mean the format of the req fails some criterion for being a file upload?
15:47 jberger jontaylor: the built-in validation isn't necessarily better than what you were using
15:47 jberger with the exception that it is what supports the csrf protection
15:47 jberger (I don't have any experience with that plugin btw)
15:47 jontaylor the built in validation also has the advantage that more people will be familiar with it
15:48 jontaylor I just wonder, if I had done things differently back then, could I have avoided some of the work I have to do now
15:49 jberger the academic answer is you could use a dependency injection middle layer (Bread::Board, Beam::Wire) to abstract out api differences
15:49 jberger but that's a very iffy suggestion because it would have been a ton of work to build the DI layer for your needs
15:50 jontaylor thats true yeah, the total work would be more than what I actually did
15:51 jontaylor maybe there just isn’t a lesson to be learned from this one
15:52 jberger sure there is! DON'T VALIDATE ANYTHING!!! wooooo hooooooo
15:52 Grinnz_ the lesson is, nobody can completely plan for future changes :P
15:52 jontaylor :)
15:52 preaction i can
15:52 jberger preaction: has dependency injection for his dependency injection
15:53 jberger yo dawg, I dawg your dawg yo so I dog yo'd your yo dawg
15:54 jberger man I'm in a strange mood today :-P
15:54 nic Weird, my file is in $self->req->uploads->[0] but $self->req->every_upload is []
15:54 ribasushi jberger: yo mama.
15:55 Grinnz_ nic: every_upload still takes a name
15:55 jontaylor I was just thinking that
15:55 nic I see, thanks Grinnz
15:55 jontaylor it needs a parameter name!
16:01 someanon joined #mojo
16:01 someanon hi guys!
16:01 someanon I need help with controller's write and write_chunk methods. Here is example https://gist.github.com/anonymous/fac672eb7bc967b779da
16:02 someanon I'm getting memory leaks if my $n and write_chunk payload are big enough. Am i doing something wrong?
16:06 jberger well closing over your own sub reference is a leaky construct anyway
16:06 jantore joined #mojo
16:06 jberger refactor in terms of a named sub or else use the __SUB__ token for recursion
16:06 jberger then see if there are remaining leaks
16:08 jontaylor I would also get the controller instance again inside the sub routine
16:08 jontaylor as its the first parameter passed in
16:08 jontaylor rather than referencing the $self from outside the block
16:08 jberger jontaylor: I don't THINK that's a problem ... of course best to try it
16:08 Mikey joined #mojo
16:09 jontaylor I don’t think it is either, but when I get these problems I start going through the vars and trying to not hold references as much as possible
16:13 someanon ok, guys! now the question itself: what's the right way to use write_chunk to render very large file?
16:13 osfabibisi joined #mojo
16:15 jontaylor are you generating this file, or will it be a file from disk?
16:15 someanon from PostgreSQL
16:15 someanon using dbi fetch method with limit
16:15 someanon i want to render chunks by 1000 lines
16:16 someanon or 10000
16:16 jberger IIRC the postgres driver fetches all the data at once
16:16 jberger so that's your problem
16:17 someanon no
16:17 someanon look
16:17 someanon http://pastebin.com/zfxRdHqX
16:17 someanon this one also leaks
16:18 jberger ummmm, how is that related?
16:18 someanon same nonblocking scheme
16:19 jberger but its an entirely different architecture
16:19 someanon this how i fetch: my $rows = $select->fetchall_arrayref({}, 1000);
16:19 someanon 10000 rows
16:19 someanon then i want to write_chunk
16:19 jberger sorry, did you paste the right link?
16:19 someanon last one with AnyEvent
16:20 jberger that has no mojo nor pg in it
16:20 someanon yes
16:20 gryphon joined #mojo
16:20 someanon this is just example
16:20 someanon maybe problem in EV
16:20 jberger ok, well to me that seems completely unrelated
16:20 someanon haham ok=)
16:20 jontaylor seeing as fetchall_arrayref is blocking, you might as well just stick it all in a while loop
16:20 jberger fetchall_* will certainly fetch all the data
16:21 jberger that's a lot to hold in memory on a large read
16:21 someanon look to second arg - fetching limit
16:22 someanon it continues to leak one request after another
16:22 someanon not just in one
16:23 jberger https://metacpan.org/pod/DBD::Pg#Cursors
16:24 someanon okk, ill try
16:25 someanon i will try to show leaking /dev/random uploading example
16:26 jberger did you try like I said, not closing over the sub reference?
16:26 jberger that is a known leaky structure
16:28 someanon i will try, thanks
16:35 disputin joined #mojo
16:37 jkramer joined #mojo
16:37 jkramer Ahoy
16:38 jkramer Quick question about Mojo::Pg: if I start a transaction in a scope but leave the scope without committing, is the transaction rolled back or is it still open?
16:38 someanon rollback, i gues
16:38 jkramer The manual says it's a scope guard, so I guess it's rolled back, but it's not explicitly said
16:38 batman jberger: cool! Applify all the things :)
16:39 someanon look it's source, desctructor
16:39 jberger jkramer: yeah, starting a transaction returns a scope guard
16:40 jkramer Alright, there's a rollback mentioned in the source, so I guess it'll rollback
16:40 jkramer Thanks!
16:40 sri jkramer: it's literally spelled out right there http://mojolicious.org/perldoc/Mojo/Pg/Database#begin
16:40 jberger https://metacpan.org/pod/Mojo::Pg::Database#begin
16:40 jberger drat sri, I was just about there!
16:40 batman :)
16:41 jberger and I always forget that I can use mojolicio.us for Minon/Mojo::Pg
16:41 jkramer sri: Meh, why not in the transaction example of Mojo::Pg or in Mojo::Pg::Transaction? Mojo::Pg::Database is the last thing I would look at :)
16:42 batman jberger: you can use it for more: http://mojolicious.org/perldoc/File/Spec
16:43 sri jkramer: what?
16:44 sri you want a synopsis example to have a multi sentece description?
16:44 sri +n
16:44 sri whatever... that "Meh" means i'll leave the discussion
16:48 jacoby joined #mojo
16:53 jberger can I get some opinions on this: http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/
16:54 jberger how bad is it, from a RESTful perspective, to allow PATCH the way this guy says is wrong
16:54 someanon ok, no leaks with /dev/random, thanks
16:54 jberger someanon: glad to hear it
16:54 ashimema I read that ages ago jberger
16:55 sri jberger: he seems correct
16:55 ashimema but I had already come to the same conclusions I think..
16:55 jberger :s
16:55 jberger ok
16:55 ashimema I use json-patch (but swagger is -insert favourite explitive word here- incompatible with it)
16:56 jberger yeah, I'm doing this with swagger too
16:56 ashimema using batmans plugin?
16:56 jberger yup
16:56 ashimema you may like to chip in on this: https://github.com/jhthorsen/swagger2/pull/73
16:57 ashimema happy to discuss further in #swagger ;)
16:57 sri jberger: he's also wrong though
16:57 ashimema me.. or that post sri?
16:58 * ashimema hasn't read the article for at least a year ;)
16:58 sri jberger: the actual format of the patch is not defined anywhere, updated values or whatever are fine
16:59 sri you decide the format of the actual patch document
16:59 jberger sri: so sending say a partial object as PATCH and updating those values isn't evil?
16:59 sri i don't see why it would be
16:59 jberger ok, that's much nicer from my perspective
16:59 sri just using PATCH instead of PUT is wrong
17:00 dod joined #mojo
17:00 ashimema :( ashimema likes json-patch
17:01 ashimema having a defined patch specification makes really good sense to me (and if your using json already, then json-patch makes good sense)
17:01 jberger see, I'd think that if I did -- PUT /thingy/1 {"this": "that", "hi": "bye"} -- then -- PUT /thingy/1 {"partial": "updated"} -- that the "this" and "hi" keys would be removed
17:01 ashimema though there are alternatives out there.. json-transform or somthing like that I believe exists
17:01 sri PUT is for updating the whole thing, PATCH for partial updates
17:02 ashimema agree with you there jberger
17:02 jberger and all I want to do is change that example with PATCH the second time to have all three keys
17:05 jberger I'm gonna stick with that
17:39 PryMar56 joined #mojo
17:42 mspo http://www.mikeperham.com/2016/02/09/kill-your-dependencies/
17:43 mspo validation of the mojo way?
17:44 jb360 joined #mojo
17:54 sri that issue is much more nuanced
17:55 sri reinventing everything and then being unable to keep it maintained is also hell
17:57 sri but i think i know what made him write that post :)
17:57 sri *cough* actioncable *cough*
17:58 sri i do agree with a lot he says though
18:01 sri think when rails started requiring multiple databases they finally crossed a line
18:06 genio I agree with a lot of his points.  My point of contention is that when you think you're smarter than you are and you recreate a wheel poorly without knowing it. :/  Lots of us fall into that trap
18:16 Grinnz "Test gems loading in production." this just makes me sad again about all the dists which have test deps in build_requires
18:18 Grinnz thankfully the useragent situation isnt so bad in perl, almost everything uses LWP (though most of those things could be using HTTP::Tiny easily)
18:19 ribasushi Grinnz: he is talking about runtime, not in any way similar to build_requires
18:19 Grinnz yeah thats worse :/
18:30 sri would be nice to finally bump the perl requirement of mojolicious to 5.14
18:31 genio lots of RHEL6 and 5 instances out there left to shoot down.  5.16 when everyone finally moves to EL7
18:31 Grinnz RHEL5 is on 5.8, those are already gone :P
18:32 sri 5.8 seems finally dead, been ages since someone complained about it
18:32 Grinnz and i so wish it was gone from our servers, its openssh has a really annoying bug
18:32 sri mojo-legacy has been unmaintained since 2014 https://github.com/jamadam/mojo-legacy
18:34 ribasushi or people just gave up and stopped upgrading ;)
18:35 sri don't think so, those folks have been pretty loud
18:35 Grinnz maybe "gave up and moved to a non-system perl like anyone should on something that old" :P
18:35 genio too bad EL7 came with the huge change of systemd which slowed the upgrade path
18:35 mspo linux distros ruin most things
18:36 genio I don't mean that as a slight to systemd (not going down that war path) only that the change was a large one and causes lots of extra thought before upgrading from 5/6 to 7
18:36 sri anyone got a working .travis.yml for postgres 9.5?
18:36 sri https://travis-ci.org/kraih/minion/jobs/108605774
18:37 sri that's how far i got
18:39 sri using the slow travis workers sucks
18:48 ribasushi sri: they are already whitelisted: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise#L9369
18:49 ribasushi which means they are available without sudo via: https://github.com/dbsrgits/dbix-class/blob/current/blead/.travis.yml#L42-L46
18:49 sri oh
18:49 ribasushi s/they/pg 9.5 packages/
18:52 sri getting closer https://travis-ci.org/kraih/minion/jobs/108609990
18:52 sri https://github.com/kraih/minion/blob/master/.travis.yml
18:55 sri best i can find is this https://github.com/travis-ci/travis-ci/issues/4264#issuecomment-155404724
18:55 sri which does not appear to work atm
18:57 ribasushi sri: I don't actually use a 9.5 pg, just know of the apt whitelist hence linked it
18:59 bjakubski joined #mojo
19:04 sri argh
19:04 sri https://travis-ci.org/kraih/minion/jobs/108612388
19:04 sri and a little closer
19:09 jkramer sri: Sorry, left work earlier. What I meant is that there's an example for using transactions right in Mojo::Pg and either there or in Mojo::Pg::Transaction would be a better place to explain the it. I just wouldn't expect it to be in ::Database
19:11 jkramer Even a comment after the eval block in the example would suffice
19:23 jberger re dependencies: I think its a testament to Perl and CPAN and the toolchain that such large and deep dependency trees are possible
19:24 jberger but that ability does seem to tend to cause a mass hysteria of pulling in dependencies for everything
19:24 Grinnz_ the main sticking point is that more dependencies means more things you depend on not breaking
19:25 preaction deps.cpantesters.org
19:25 sri omg, i have a working .tavis.yml :o
19:25 sri https://travis-ci.org/kraih/minion/jobs/108614004
19:25 sri \o/
19:25 Grinnz_ and on the other side, that reinventing badly or without maintaining it is worse than not reinventing at all
19:26 Grinnz_ so its up to the individual situation really
19:36 jacoby_ joined #mojo
19:39 jacoby_ joined #mojo
20:02 jkramer left #mojo
20:07 sri omg
20:07 sri now i actually need $DBDPG_DEFAULT and it doesn't fricking work
20:09 sri been thinking about how to make this use an upsert https://github.com/kraih/minion/blob/master/lib/Minion/Backend/Pg.pm#L85
20:10 sri perhaps an upsert is just the wrong tool for the job
20:13 sri anyway, this will be minion 5 https://github.com/kraih/minion/commit/b99a3e3e0016724c2168659169cb0af70e5cac4b
20:15 good_news_everyon joined #mojo
20:15 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgiWN
20:15 good_news_everyon mojo/master b62a422 Sebastian Riedel: no need for quotes
20:15 good_news_everyon left #mojo
20:15 sri now is a good time to request breaking changes in minion
20:37 jacoby joined #mojo
20:40 HtbaaPi joined #mojo
20:51 sri just in case someone else wants a shirt like this https://shop.spreadshirt.com/kraih/mojolicious+raptor+(front+and+arm)-A104389001?appearance=2
20:51 sri don't think it will stay for long
20:55 jberger I can't keep buying stuff
20:55 jberger I just got my failraptor shirt and frosty mug
20:55 jberger I'm waiting to put my stickers on my mac until I get my centerpiece though
20:56 Grinnz_ sri: i think the reason for the quotes on perl version is so that e.g. "5.20" doesn't get interpreted as 5.2
20:56 Grinnz_ but i dont know how travis is parsing the yaml or if that actually matters
21:01 sri jberger: wait till the mojolicious jewelry collection gets released! ;p
21:02 sri Grinnz_: haha, it actually says 5.1
21:02 sri https://travis-ci.org/kraih/mojo
21:02 sri but it seems to work
21:03 Grinnz_ lol
21:03 Grinnz_ they probably ran into that before and added a workaround
21:04 good_news_everyon joined #mojo
21:04 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgiVd
21:04 good_news_everyon mojo/master c1475a3 Sebastian Riedel: keep versions quoted so 5.10 does not become 5.1
21:04 good_news_everyon left #mojo
21:07 neilhwatson cool
21:19 sri jberger: how is the frosty mug anyway?
21:19 sri i've only seen the european beer mug so far, which is pretty nice
21:22 chansen I'm looking for a efficient HTTP UA parser, any suggestions?
21:23 jberger it was a really cold day when it showed up so it was actually frosty when I opened it
21:28 chansen Damit sri! I don't ware community wares, just tell me what to buy to support Mojo the best!
21:31 sri i'll be getting one of these https://shop.spreadshirt.com/kraih/metacpan+cap-A104389783
21:34 chansen sri: Looks like a fine clothing cap! What's the most expensive item in your shop with most gain for you?
21:34 sri the donation shirts
21:34 chansen uri?
21:34 sri https://shop.spreadshirt.com/kraih/%24100+donation+and+glitter+shirt+(mojolicious+pirate+cloud)-A104286176
21:35 sri there's two variants in the us and eu shop
21:36 chansen The shop I'm looking at shows prices in USD
21:36 sri https://shop.spreadshirt.de/kraih/100+%E2%82%AC+donation+and+glitter+shirt+(mojolicious+pirate+cloud)-A105289799
21:38 chansen LOL, same prices in the USD vs EU
21:38 sri odd how the descriptions change from the shop overview to the detail view
21:38 sri they don't even tell you the print tech used anymore
21:39 sri chansen: i imagine shipping costs differ
21:41 chansen sri: Both shops list plus shipping ;)
21:41 chansen excluding the offered price
21:43 noganex joined #mojo
21:44 sri hmm, for germany the shipping costs are meh now too actually
21:44 sri $7.50 vs 5.99 euro
21:48 chansen The US shop says $117.90 plus shipping, the EU shop says 119.90€ plus shipping
22:01 chansen sri: Your order was successfully submitted, thanks Christian! Price 129,89 €
22:01 chansen sri: Are you between jobs?
22:01 sri \o/
22:02 sri still freelancing, but looking for something full-time
22:03 anon joined #mojo
22:03 chansen sri: Would t
22:04 chansen .. oops, would you consider relocatong to Sweden?
22:05 sri trying to avoid relocating
22:07 anon3252523 joined #mojo
22:08 sri for now my wishlist is remote work from germany, and a certain percentage of work time for open source
22:11 chansen sri: Now I only have to convince my accountant that purchasing T-shirts for 119,90€ was a necessity for the companies survival ;oP
22:12 sri business attire for the next conf, i think that counts :)
22:23 chansen sri: You clearly doesn't know the Swedish way ;oP
22:28 * chansen sorry for the noise
22:29 sri that was not much noise
22:31 * chansen it's not easy to keep cousins children away when they want to play mindcraft
22:33 * chansen anyway they can use my tablet or die ;oP
22:33 sri my nephew plays minecraft too, that game seems to only get bigger
22:35 sri everyone was laughing at microsoft when they bought it, but that game will be around for generations
22:36 Grinnz_ it has the mindshare
22:36 Grinnz_ people have tried to clone it but without much success
22:45 chansen sri: I agree, I'll hopefully come up with a reasonable explanation for next bookkeeping year!
22:46 perlpilot joined #mojo
22:47 chansen sri: Just make the contribution worthwhile! For you and your fell overs
23:00 disputin joined #mojo
23:00 chansen I'll postpone it until I'm confronted by my accountant!
23:08 sri i'm using this pattern so much now, maybe helper methods would be in order https://github.com/kraih/mojo-pg/commit/912d72791d43bd5a92fd64216b8f7f6cc7cd8abb
23:08 sri perhaps a scope guard
23:10 sri hmm, gotta think some more about it
23:34 disputin joined #mojo
23:37 asarch joined #mojo

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