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

IRC log for #mojo, 2013-11-24

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

All times shown according to UTC.

Time Nick Message
00:02 rem_lex|pivo joined #mojo
00:46 marquezc left #mojo
01:20 mire_ joined #mojo
01:28 KindTwo joined #mojo
01:43 KindOne joined #mojo
01:46 athenot joined #mojo
02:31 duncanthrax2 joined #mojo
03:00 Zoffix joined #mojo
03:00 Zoffix left #mojo
03:10 mattington joined #mojo
03:23 asarch joined #mojo
03:23 KindOne joined #mojo
03:56 mschreck joined #mojo
03:59 mschreck hello party people. I have a question about forming UserAgent post requests, is there anyone out there willing to lend a hand?
04:00 mschreck specifically, how do I set headers like User Agent and Content-Type, while also adding some headers of my own
04:05 preflex_ joined #mojo
04:06 mschreck i've got working python code, but can't seem to get mojo to formulate the request quite righr
04:10 abra joined #mojo
04:24 d4rkie joined #mojo
04:28 rem_lex joined #mojo
05:15 jnbek joined #mojo
05:37 jberger_ joined #mojo
05:39 jberger_ mschreck: http://mojolicio.us/perldoc/Mojo/UserAgent#get and note that DNT is a header
05:40 jberger_ sri: on a branch of ForkCall, I am doing something which works on windows
05:41 jberger_ I am implementing my first go, using the mojo client/server for IPC
05:41 jberger_ using it as an alternate implementation, which becomes the default on windows
05:41 jberger_ https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/server/lib/Mojo/IOLoop/ForkCall.pm
05:42 jberger_ the run method now delegates to one of two run_via_ methods
05:44 jberger_ I now understand why mlehmann does all the shenanigans in AE::Util
05:44 jberger_ but I also don't really want to do them all, so once again, I fall back to something higher level
05:44 jberger_ in this case the mojo client/server pair
05:46 jberger_ sadly, because the client is necessarily non-blocking, this means I cannot use Child (sans IPC) for the fallback, because the child calls exit after executing it's callback
05:46 jberger_ its
05:58 ronsavage joined #mojo
06:13 ronsavage1 joined #mojo
06:34 KindTwo joined #mojo
06:50 elvis joined #mojo
06:50 batman joined #mojo
07:17 rem_lex|pivo joined #mojo
07:24 KindOne- joined #mojo
07:47 Vandal joined #mojo
08:21 elvis joined #mojo
08:21 batman joined #mojo
08:46 punter joined #mojo
09:34 basiliscos joined #mojo
09:48 hummeleBop joined #mojo
09:58 dotan joined #mojo
09:58 trone joined #mojo
10:07 rem_lex|pivo joined #mojo
11:04 dod joined #mojo
11:56 denisboyun joined #mojo
12:18 KindOne joined #mojo
12:30 mire_ joined #mojo
12:54 asarch joined #mojo
13:15 denisboyun joined #mojo
13:27 batman does mojo do anything like chdir $app->home ?
13:45 batman https://github.com/jhthorsen/locale-maketext-from-strings # comments?
13:45 batman marcus: ^ could be interesting when making ios apps and web apps (?)
14:12 ryozi joined #mojo
14:20 sh4 joined #mojo
14:38 sh4 joined #mojo
14:58 good_news_everyone joined #mojo
14:58 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/uFmVEw
14:58 good_news_everyone mojo/master dada154 Sebastian Riedel: small optimization
14:58 good_news_everyone left #mojo
15:03 sh4 joined #mojo
15:21 gryphon joined #mojo
16:05 rem_lex joined #mojo
16:39 hrupp joined #mojo
16:41 d4rkie_ joined #mojo
16:46 denisboyun joined #mojo
16:56 denis_boyun_ joined #mojo
16:57 d4rkie joined #mojo
16:58 btyler joined #mojo
17:18 marcus batman: not quite clear to me. Can it be used to generate .po files?
17:19 batman not in one step.
17:19 batman haven't you used .strings in a ios project for translation?
17:19 marcus batman: We've just translated them in xcode afaik
17:19 batman not sure what that means...
17:21 dotan joined #mojo
17:22 marcus oh, ser nå at poeditor virker direkte med .strings filer
17:22 marcus then I don't quite know what the use case for your module is.
17:22 batman guess i misunderstood something then :/
17:23 marcus btw, finger print scanning is frickin' awesome.
17:23 marcus (Got my 5s this weekend :)
17:23 batman :)
17:23 batman NSA OWNS YOUR ASS!
17:23 batman ;)
17:24 marcus all our asses
17:24 marcus (are belong to NSA)
17:24 batman hehe
17:28 marcus authy is super nice too. Finally 2 factor auth with minimal hassle.
17:28 marcus "Finally"
17:28 purl somebody said "Finally" was "always execute this, no matter if there was an exception or not"
17:29 * sri hugs his nexus 5
17:37 batman is .po better than Locale::Maketext ?
17:44 marcus sri: One of the reasons I like authy is sync with the htc one.
17:44 marcus Bluetooth sync is even greater tho
17:50 btyler joined #mojo
17:55 dod joined #mojo
17:56 maxhq joined #mojo
18:04 btyler joined #mojo
18:10 asarch joined #mojo
18:16 * marty wonders if  creating a helper like 'state $mango = Mango->new()' is the best way to instantiate mango.  Or if it would be better to do it in the startup sub.
18:18 batman marty: i don't think it matters for Mango
18:20 marty batman:  thanks.  It works well as a helper but I was not sure if that made the most sense.   I guess I'll keep it in there.  :)
18:21 batman marty: i like to instantiate all my models in startup(), but that's just a matter of taste in most cases
18:22 sri mango doesn't care
18:22 sri startup used to be a bad choice though
18:23 sri since, if a connection gets established right away, your model needs to be fork aware
18:23 sri which, Mango and Mojo::UserAgent now are... but many other possible model choices aren't
18:24 msa-baba1 joined #mojo
18:24 denisboyun joined #mojo
18:27 marty good info.  Thank you, sri.
18:28 msa-baba1 smtp needed
18:38 russum1 joined #mojo
18:39 batman msa-baba1?
18:39 russum2 joined #mojo
18:44 jberger__ joined #mojo
18:45 marty maybe a non-english speaker.   msa-baba1: http://search.cpan.org/~sharifuln/Mojolicious-Plugin-Mail-1.0/lib/Mojolicious/Plugin/Mail.pm
18:47 powerman joined #mojo
18:48 powerman sri: hi. not sure is this client-side issue or something is wrong with css on http://mojolicio.us/
18:49 powerman one my friend reported it to me, I've checked it and I've same issue too
18:49 powerman we both use Firefox/Linux
18:49 powerman here is how it looks: http://powerman.name/tmp/mojolicious-selected.png
18:50 powerman selected text sees double by vertical
18:51 powerman this doesn't happens on metacpan
18:52 sri can't confirm with firefox on os x
18:54 batman powerman: it's probably because of firefox + text-shadow
18:55 batman it doesn't look too bad in chrome + ubuntu
18:56 powerman yeah, in chromium everything is fine
18:57 batman powerman: can you inspect the <pre> element and remove text-shadow in ff just to see the difference?
18:58 powerman in opera when several lines selected this issue happens on some of them (probably every second line or so)
18:59 russum joined #mojo
19:00 powerman batman: yeah, removing text-shadow from <pre> fix this issue
19:01 dvinciguerra joined #mojo
19:04 batman sri: wanna add pre::-moz-selection { text-shadow: 0; } # or something?
19:04 sri not really
19:05 denisboyun joined #mojo
19:06 batman haha
19:07 batman https://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-NamespaceForm-0.01
19:10 marty DANGER ZONE
19:10 jberger__ speaking of DANGER ZONE
19:10 jberger__ sri, all: thoughts? https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/master/lib/Mojo/IOLoop/ForkCall.pm
19:12 batman jberger__: thanks for showing me Child.pm. i like it :)
19:12 jberger__ sri showed me
19:12 batman ok. thanks sri :)
19:12 batman Perl::OSType ? can't you just do $^O eq 'Win32' ?
19:12 jberger_ future proofing mostly
19:13 Mike-PerlRecruiter_ joined #mojo
19:13 jberger_ also, in case we find that some other platform should default to the slow method
19:13 * sri giggles as he experiments with adding a parallax effect to the http://mojolicio.us banner
19:14 jberger_ its core as of 5.14 anyway
19:14 batman jberger_: ok. i don't like then start() method. i think it's clutter without extra functionality.
19:14 jberger_ I've been back and forth on that
19:15 jberger_ it lets you do ->run()->start()
19:15 jberger_ but I'm not sure that that is worth the confusion
19:15 jberger_ as you say
19:15 batman same with run_with_callback()
19:15 jberger_ that's a different thing
19:15 batman we had start() on Mojo::Redis before i started hacking on it.
19:16 jberger_ I like run with callback for using it in steps
19:16 batman i know it's different. i just don't see how it's useful.
19:16 jberger_ it will look more symmetric with other non-blocking calls
19:17 jberger_ but since run does not require a callback, there is no way to know if a trailing coderef is intended as a job argument or a callback
19:17 batman i would just use run() for that.
19:17 batman how is it not possible? @_ > 2 and 2 == grep { ref $_ eq 'CODE' } @_;
19:18 jberger_ ->run( sub { 'this is intended as a job argument, not a callback' })
19:19 batman that's corner case imo
19:19 batman you could do ->run($code, [@code_args], $cb);
19:19 jberger_ the only way to resolve it that I can see would be to not emit finish but rather require a callback to run
19:20 batman so the args need to be put into an array-ref and unpacked: $code->(@$code_args);
19:21 jberger_ I don't mind that api, but then I wouldn't have $job be an attribute either
19:21 jberger_ sri: thoughts?
19:21 purl i like cheese
19:22 batman i wouldn't have job either :)
19:22 jberger_ Mojo::IOLoop::ForkCall->new->run($job, @args, $cb)
19:22 batman the $cb / no $cb issue can be solved with Mojo::IOLoop::ForkCall->new->run($job, \@args, $cb)
19:23 jberger_ it would simplify the constructor a lot
19:23 batman but i really like the fork_call() function
19:23 jberger_ if I allow a callback to run, it would be required
19:23 sri jberger: it looks way cluttered to me now
19:24 jberger_ would removing the job attr and the finish event improve it?
19:24 batman jberger_: yeah. the constructor is crazy :(
19:24 batman jberger_: i like the finish event.
19:25 jberger_ I guess I could do \@args, but its not my preference
19:25 jberger_ and if $cb is provided it would attach via once
19:25 jberger_ hmmmm
19:26 batman i would completely remove new() and start()
19:26 batman that would be a nice start :)
19:26 jberger_ I would only remove the new method if I remove the job attr
19:27 batman then remove the job attr. i don't see why you need it...
19:27 jberger_ the nice thing about the job attr is if you want to reuse the ForkCall object to repeatedly invoke the same job with different arguments
19:27 jberger_ but I guess you could do that as easily passing $job to run
19:28 batman i think that's a "nice to have" feature. not really a useful feature...
19:28 jberger_ documentation driven design :-)
19:28 jberger_ ok, let me see what this looks like simplified
19:28 batman my suggestions would kill half of the lines of code...
19:29 jberger_ btw, fork_call is a function provided by AnyEvent::Util
19:29 jberger_ the whole point is creating a Mojo::IOLoop drop-in replacement
19:30 batman yeah, i saw it...
19:30 batman did you see my ReadWriteFoke module?
19:30 batman *Fork
19:31 jberger_ I did, and it was what reminded me that I had wanted to do this for a while
19:31 batman :)
19:31 jberger_ they are in the same conceptual space, but approach things in a very different manner and with a different api
19:35 batman yes. my module is for interacting with a process (like ssh, telnet, ...) while yours is for running blocking functions.
19:35 batman ...i think
19:35 jberger_ right
19:35 jberger_ of course you can make an external process call from the forked function, but that is where the different style/api comes in
19:36 jberger_ batman++
19:36 batman i really like fork_call() it's super smooth.
19:36 batman i'm a bit surprised why the oo api isn't as smooth...
19:36 batman that's all
19:37 jberger_ it got bigger as it went :-s
19:38 batman :D
19:44 batman Mojo::IOLoop::ForkCall->new->run($job, @args)->on(finish => $delay->begin(0)); ?
19:45 batman hm... will that ever fire the finish event? will the object go out of scope?
19:46 batman also $cb->(@_); vs $fc->$cb(@_); # to avoid begin(0)
19:47 jberger_ emit takes care of that
19:47 punter joined #mojo
19:48 jberger_ batman: https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/simplified/lib/Mojo/IOLoop/ForkCall.pm
19:48 batman hm... so it's a memory leak until the "close" event on the handle is triggered?
19:49 jberger_ that would be a reason not to use emit
19:49 jberger_ you see how I avoid that with the child process
19:51 russum joined #mojo
19:51 jberger_ I'm not too worried about that though
19:51 batman right. you might be on to something there...
19:52 batman so if you kill EventEmitter, then you could also call run($job, \@args, $cb) as many times as you like...
19:52 batman that makes sense :)
19:52 jberger_ except to call it like $fc->$cb(@_) you would still need to close over $fc
19:53 batman then _emit_result() could also be a function
19:53 batman yes. but do you really need that?
19:53 batman i just came up with that, because i was thinking about how $ua and other api...
19:54 batman i guess that's why i liked fork_call($job, ... $cb): the thing i'm really interested is the result from $job
19:55 jberger_ oops and I now have a bug in there ;-)
19:56 batman :)
19:56 jberger_ I guess I never test having an argument to the job
19:57 batman are you going to remove 'finish' event?
19:58 jberger_ I haven't decided
19:58 batman it looks a lot better already.
19:59 jberger_ hmmm, run could return the child pid in case you want to manually kill it later
19:59 batman but i do hate memory leaks.
20:00 batman i think you need to decide first: can an instance of Mojo::IOLoop::ForkCall call run() more than once?
20:00 batman if the answer is "yes", then returning the pid could make sense
20:01 batman if the answer is "no", then you could keep the Child object around and call methods on it.
20:01 jberger_ but there is not guarantee that there is a Child object
20:01 jberger_ no
20:02 batman no?
20:02 jberger_ not if you _run_via_server
20:03 batman my $pid = fork # you need to check if it's defined()
20:03 batman same bug in Child.pm i think.
20:04 jberger_ I also have a nit for Child.pm
20:04 jberger_ I wonder if we might contact the author
20:04 batman "nit" ?
20:04 jberger_ the reason I don't use it for the server approach is that it calls exit immediately after running the job
20:04 batman waitpid $pid, 0; # couldn't this hang forever in the parent process?
20:05 batman ok? what's wrong with that?
20:05 jberger_ the client is a non-blocking interface
20:05 batman and..?
20:05 jberger_ so the process would exit before it could send to the partent
20:05 jberger_ parent
20:06 batman are you sure? i thought that was dependent on the socket type...
20:07 jberger_ the cb to Mojo::IOLoop->client(..., $cb) is used as the on connect handler
20:07 jberger_ it would start connecting and then exit
20:08 jberger_ if Child allowed switching off that exit, say via some attribute or argument, then I could use it for the client/server approach too
20:08 jberger_ client/servier
20:08 jberger_ aaah, what was that :-)
20:09 * batman don't follow
20:10 batman anyway... i think i need a break
20:10 jberger_ https://metacpan.org/source/EXODIST/Child-0.009/lib/Child.pm#L72
20:10 jberger_ batman, thanks for the fresh eyes, I like this better already
20:10 batman :)
20:11 batman two new modules today and three new versions... that's enough for one day i think :P
20:12 * jberger_ hands batman a beer
20:12 batman haha! i had enough on friday for a whole month i think :S
20:12 batman super fun and super awful at the same time :)
20:12 * jberger_ hands batman a glass of water and an aspirin :-)
20:12 batman thanks
20:13 sri jberger: continuing to run the ioloop in the child will have horrible consequences
20:13 batman have you started using Mandel?
20:14 jberger_ now that I have finished with YAPC::Brasil I intend to start using it for the comic website (which is still using my MangoModel atm)
20:14 batman cool
20:14 sri you may be inheriting listen sockets and keep accepting connections that never get processed
20:14 batman looking forward to it
20:14 batman sri: how do you fix that?
20:15 sri batman: i don't go there
20:15 sri that stuff is messed up
20:15 batman hehe
20:16 jberger_ "Also, on most windows platforms some memory will leak for every invocation." -- AE::Util::fork_call
20:16 batman so you can't do Mojo::IOLoop->singleton->max_connections(0); ?
20:17 batman jberger_: that's stupid. i hope it's mhleman who has written that.
20:17 jberger_ who else
20:18 batman don't know :/
20:18 batman sri: so you can't do Mojo::IOLoop->singleton->max_connections(0); to prevent that ?
20:18 jberger_ I'm just saying that the client/server implementation in only intended as a fallback for platforms which cannot do it well
20:19 sri i won't even speculate... there is too much else to go wrong
20:19 batman jberger_: but you should take what sri says to consideration.
20:19 jberger_ mlehmann may be mlehmann, but he can code. if its the best he can do I'm would be surprised if I could do better
20:19 batman i don't get it though.. there must be some method to close all listening sockets?
20:19 sri seriously, if you fork and reuse a running event loop you're screwed
20:20 jberger_ oh
20:20 batman i would not be surprised if you could do it better jberger_.
20:20 jberger_ I hadn't thought about that, seems obvious now that you say it that way
20:20 batman you're doing something he doesn't: you ask for feedback and listen.
20:21 jberger_ right (I didn't understand the feedback a few lines ago :-) )
20:21 sri batman: listen socks are just one thing, another are already active connections... epoll and kqueue instances... and and and
20:22 sri *sockets
20:22 sri even running and duplicated timers can fuck things up
20:22 jberger_ batman, sri: but I really don't want to have to understand what this does :-( : https://metacpan.org/source/MLEHMANN/AnyEvent-7.05/lib/AnyEvent/Util.pm#L98
20:23 jberger_ sri: could I start a different ioloop?
20:23 sri oh... a recurring timer that performs fork_call.... yea... shit now you have a fork bomb!
20:23 jberger_ sri: don't do that :-D
20:24 jberger_ ok, I'm convinced ... I'm just not sure what to do about it
20:26 batman sri: but it's ok to fork as long as you're not messing around with the singleton ioloop..?
20:27 batman jberger_: easy way out: i would not worry about win32 :P
20:28 batman hehe
20:28 jberger_ dammit, that's where I was two days ago! ;-)
20:28 sri go figure why i'm in the job queue camp
20:29 sri things just work
20:31 jberger_ sri: in the child, if I do Mojo::IOLoop->new->client(...) would that be good enough?
20:32 jberger_ (simplified version is becoming the only version btw)
20:33 jberger_ actually, if I can use a new ioloop in the child process, I could use Child.pm to do so!
20:34 jberger_ $new_ioloop->start would block before the child reaches exit!
20:36 lukep joined #mojo
20:41 asarch joined #mojo
20:47 beyondcreed joined #mojo
21:12 zackiv31 joined #mojo
21:16 jberger_ sri: is this any safer? https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/childloop/lib/Mojo/IOLoop/ForkCall.pm#L59
21:19 jberger_ should I explicitly give it a poll reactor? EV is very global singleton right?
21:19 athenot joined #mojo
21:23 russum joined #mojo
21:25 jberger_ actually it seems that Mojo::Reactor::EV->new does that for me
21:25 jberger_ still perhaps it should be explicit
21:26 themage joined #mojo
21:26 themage left #mojo
21:27 rem_lex|pivo joined #mojo
21:31 * sri added a soft parallax effect to http://mojolicio.us/
21:31 powerman jberger_: sri is right, in general fork() in event-loop app is very bad idea, a lot of things may and will broke in different ways
21:32 jberger_ powerman, I'm aware, but in this case I'm doing it for a very specific reason, see AnyEvent::Util::fork_call
21:32 powerman but Lehmann says it's possible with EV - just read carefully everything mentioning "fork" in EV doc
21:32 jberger_ the question is really just the mechanism of IPC on windows
21:34 sri maybe i'll animate the clouds a little too
21:34 powerman another problem with all these AnyEvent* thing is what you can't be sure you're using EV
21:34 * jberger_ is investigating IO::Pipely
21:35 jberger_ powerman, indeed, I'm trying to port it to Mojo::IOLoop
21:35 jberger_ that is actually the point ;-)
21:38 powerman I see, but… probably it's better to not go there at all. Either fork before starting event loop, or, better, run separate process which will use fork() and blocking i/o without event loops, and communicate with that process(es) from another, event-loop based process.
21:39 jberger_ powerman, it all started with this post: http://stackoverflow.com/a/19555801/468327
21:40 batman jberger_: can't you just do IO::Socket::INET in the child..?
21:41 batman just an idea...
21:41 purl it has been said that just an idea... is it possible to make CPAN a little more secure?
21:41 * batman gets some sleep
21:41 jberger_ batman, no idea, this is all lower level than I have ever gone
21:42 jberger_ I will look tho, thank
21:42 jberger_ nighty night
22:00 powerman left #mojo
22:02 msa-baba1 joined #mojo
22:06 gryphon joined #mojo
22:12 * jberger_ may have a simple solution based on IO::Pipely
22:19 jberger_ brb, have to reboot to windows to test
22:19 tba joined #mojo
22:19 tba hi all
22:19 tba whats the right way to assign the result of a javascript function to a key in mango (equivalent of mongodb "key: functionName()")
22:36 jberger_ joined #mojo
22:36 punter joined #mojo
23:43 Adurah joined #mojo
23:45 jberger_ it works! (mostly)
23:46 jberger_ I get some errors on closing, but they seem harmless (no such process)
23:46 jberger_ Child's is_complete does a non-blocking waitpid to check, so I think the way I'm closing the child might be a little smarter to avoid the warnings
23:46 * jberger_ releases Child::IPC::Pipely
23:46 jberger_ yay! its simple again!
23:46 jberger_ https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/master/lib/Mojo/IOLoop/ForkCall.pm
23:47 jberger_ also tba, I don't know about your exact problem, but the catchall solution might be https://metacpan.org/pod/Mango::Database#command
23:48 jberger_ ooh, Adura
23:48 tba jberger_: I can execute it that way, but with mongodb if I use someFunction() as a value in an insert, it gets done atomically - only way I can think to do it with mango requires two db operations
23:48 jberger_ Adura, if you are near your windows box, would you mind pulling again and doing another test?
23:48 jberger_ blast
23:49 jberger_ hmmmm, you are above my head sorry
23:50 sri that does look a lot simpler
23:51 jberger_ IO::Pipely ftw!
23:51 basiliscos joined #mojo
23:51 jberger_ and Child made it so easy to make the plugin for IO::Pipely, so Child ftw x 2!
23:55 basiliscos joined #mojo
23:59 denis_boyun__ joined #mojo
23:59 russum left #mojo

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