Camelia, the Perl 6 bug

IRC log for #mojo, 2012-12-19

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

All times shown according to UTC.

Time Nick Message
00:06 * marty ponders the meaning of of....hmmmm...  determines that it is symbolic for "walks like an egyptian"
00:14 Molaf__ joined #mojo
01:07 laouji joined #mojo
01:14 Mike-PerlRecruiter_ joined #mojo
01:49 atz really digging mojo.  recently i've been coming back to a common perl problem, namely command-line options handling.
01:50 atz I've been spoiled by some time writing in Groovy, where there is an excellent OO class CliBuilder
01:52 avenj what's wrong with Getopt::Long ?
01:52 * sri never considered that a problem and just used Getopt::Long
01:52 sri doesn't get much simpler than https://github.com/kraih/mojo/blob/mas​ter/lib/Mojolicious/Command/get.pm#L41
01:52 atz namely that it can't handle extension because it relies too heavily on the caller's package
01:54 atz http://groovy.codehaus.org/gap​i/groovy/util/CliBuilder.html  for comparison
01:55 atz sri: so consider when I want to write a hypothetical "superget",
01:55 atz adding a couple new options
01:56 atz it isn't possible to reuse and extend the GetOptionsFromArray functionality because it isn't a discrete logical (OO) component
01:57 sri perl is not a pure oo language
01:57 atz sure, but this is not a question of capability
01:57 atz it's just that most perl options handling have not made use of the OO-ness that is available
01:58 atz (and there are about 1000 different options handling packages, some of them are completely insane!)
01:59 d4rkie joined #mojo
02:00 atz this one is the closest I have found: http://search.cpan.org/~marcel/Getopt-In​herited-1.100860/lib/Getopt/Inherited.pm
02:06 atz so my plan is to use that in future projects.  i'll report back if it works out.
02:12 atz in an  ideal version, at execute each Command::XXX subclass could rely on the base to identify its attrs having static defaults, i.e. the ones that we can let the CLI user override via automatically generated and overlaid options
02:28 egopro joined #mojo
03:17 jberger joined #mojo
03:17 jberger o/
03:18 jberger I've got a naming question for y'alls
03:18 jberger I'm writing a module easing the use of Mojolicious with Module::Build
03:19 jberger it contains the modules: Module::Build::Mojolicious and Mojolicious::Plugin::ModuleBuild
03:19 jberger which of the two of these should be the main name of the dist?
03:23 crab Module::Buildlicious, of course
03:23 jberger crab: nice
03:24 sri haha
03:24 jberger course that isn't quite ... lets say descriptive
03:24 jberger I'm leaning toward the plugin
03:25 jberger the name of the M::B subclass is only important if you are already writing a Mojolicious app
03:25 jberger in which case you are more likely to be looking in the Mojolicious::Plugin:: namespace
03:27 jberger sri: do you ever sleep? aren't you in europe somewhere?
03:27 * sri never sleeps
03:30 jberger sri: when changing the path to templates or public, I see your examples set the [0]th component, however for an automated system that seems hasty
03:30 jberger if I unshift onto those arrayrefs is that more sensical?
03:31 sri situational i guess
03:31 jberger but if I'm making a system where the situation is known
03:32 jberger maybe its a stupid question
03:32 jberger nm
03:42 noganex_ joined #mojo
04:06 zivester joined #mojo
04:15 * sri wonders which html5 book to recommend these days
04:16 sri quality of those o'reilly books is terrible
04:16 egopro joined #mojo
04:19 egopro joined #mojo
04:32 zivester joined #mojo
04:43 Foxcool_ joined #mojo
04:51 zivester joined #mojo
05:03 laouji joined #mojo
05:06 xaka joined #mojo
05:35 amirite joined #mojo
05:47 amirite_ joined #mojo
05:53 batman____ joined #mojo
05:53 wircus__ joined #mojo
06:03 spleenjack joined #mojo
06:13 egopro joined #mojo
06:42 zivester joined #mojo
07:02 ka2u joined #mojo
07:32 dpetrov_ joined #mojo
07:34 wircus__ joined #mojo
07:34 batman____ joined #mojo
07:34 ka2u joined #mojo
07:37 amirite joined #mojo
07:38 ver joined #mojo
07:40 Vandal joined #mojo
07:41 ladnaV joined #mojo
07:46 amirite_ joined #mojo
07:51 amirite joined #mojo
07:56 tempire is there any skitch replacement?
07:59 wircus__ tempire: I still use skitch. I found I don't use the free evernote quota by far with my screenshotting needs.
08:07 tempire little snapper seems nice these days
08:10 tempire even has a blurring tool
08:11 tempire http://images.tempi.re/6420754397_667739cee1.png
08:12 tempire oh, skitch's digitizing tool is neat
08:23 Adurah joined #mojo
08:28 sinkovsky joined #mojo
08:29 alnewkir1 joined #mojo
08:35 dod joined #mojo
08:36 amirite joined #mojo
08:37 suy joined #mojo
08:40 dod joined #mojo
08:48 amirite joined #mojo
08:52 alexeiras joined #mojo
08:56 dotan joined #mojo
09:12 kwa joined #mojo
09:13 Molaf joined #mojo
09:17 mike_ joined #mojo
09:26 navi joined #mojo
09:39 yakudza joined #mojo
10:03 amirite joined #mojo
10:08 mjy left #mojo
10:09 marty joined #mojo
10:09 fhelmber_ joined #mojo
10:14 batman____ joined #mojo
10:14 wircus__ joined #mojo
10:19 miket joined #mojo
10:27 wircus__ yepp
10:30 miket hi folks, love mojo:)
10:30 miket can anyone exmplain why this websocket method is blocking: http://pastebin.com/KfzJNS46
10:30 miket (sorry if this has been asked before)
10:37 batman____ miket: the for loop is blocking
10:38 batman miket: you need to do $self->send("check $i", sub { $i++; $_[0]->send("check $i") if $i < 10 });
10:38 batman oops!
10:39 batman $cb = sub { $i++; $_[0]->send("check $i", $cb) if $i < 10 }; $self->$cb;
10:39 batman $cb is called when "check $i" is flushed to the socket
10:41 ObseLeTe joined #mojo
10:47 miket batman: thanks, just trying to get my head around this stuff
10:48 batman miket: it's important that you don't think about async as threads
10:48 batman async in mojo is cooperative programming, meaning that each callback (code block, sub{}) is blocking
10:49 miket it's just an example. what I really want to do is call an existing, long running sub, and stream the log messages back to the browser
10:49 Vandal joined #mojo
10:49 batman so your for(...) {} loop is blocking every other sub{}
10:50 batman the Mojo::IOLoop on the other hand keeps track of which code block that should be called on what time
10:51 miket this also blocks: http://pastebin.com/07NhVkjz
10:54 batman miket: did you just read what i wrote..?
10:55 batman miket: it's better to ask about what you don't understand, then to paste code that has the exact same issues as before...
10:58 batman miket: so... you CANNOT have a long running sub, because each sub is blocking the rest of your application
10:59 miket batman: yeah, fooey :(
11:00 batman fooey?
11:00 batman http://en.wikipedia.org/wiki/Computer_​multitasking#Cooperative_multitasking.2Ftime-sharing
11:05 miket batman: do you think threads / fork might save me here?
11:05 batman no
11:05 kitt_vl joined #mojo
11:05 batman not at all.
11:05 batman can't you just do what i wrote above, with the $cb = ...; ?
11:14 cosmincx joined #mojo
11:26 Averna joined #mojo
11:38 dabudabu joined #mojo
11:38 SmokeMachine joined #mojo
11:52 batman i think this conversation is purely async and not cooperative :P
11:57 nic :)
12:01 SmokeMachine joined #mojo
12:01 egopro joined #mojo
12:15 miket batman: thanks it's all good, I'll hack around a bit more until I understand async better
12:19 GabrielVieira joined #mojo
12:26 cosmincx joined #mojo
12:27 Vandal joined #mojo
12:38 wircus__ joined #mojo
12:38 batman____ joined #mojo
12:38 egopro joined #mojo
13:03 ObseLeTe joined #mojo
13:03 mjy joined #mojo
13:13 noize joined #mojo
13:14 Mike-PerlRecruiter_ joined #mojo
13:15 ladnaV joined #mojo
13:19 amirite joined #mojo
13:21 SmokeMac_ joined #mojo
13:23 jberger joined #mojo
13:24 miket seems like fork works ok - parent can still talk to websocket but child cannot, but at least child process doesn't block, I can live with this
13:31 Vandal joined #mojo
13:35 ladnaV joined #mojo
13:37 Miked joined #mojo
13:47 dod joined #mojo
13:49 egopro joined #mojo
13:53 ryozi joined #mojo
13:56 b2b joined #mojo
13:59 rem_lex|pivo joined #mojo
14:03 bobishh joined #mojo
14:03 amirite joined #mojo
14:05 bobishh hi guys, can u advice me how to process a long-time running request to db, it can take up to 10 minutes. I suppose i should use IOLoop and threading ? is there any common solution ?
14:12 nicomen fix the query? use a cron job? use a job queue?
14:12 nicomen (common ways)
14:20 inokenty joined #mojo
14:20 bobishh nah, i need to create a web interface for that request. Showing progress bar or smtng not to close connection while it loads. I can't fix request cuz don't know much oracle magic, and not even sure that some "fixing" might work, db is huge, and actually my boss wrote it, not me.
14:24 bobishh that's why i wrote about ioloop , thought it would be like 1) drawing 'your req is being processed 2) starting new thread and wait while it ends, 3) redirect to results when got data. I'm not much into web development though, started to learn perl about 0.5 year ago
14:27 nicomen aha
14:28 mjy bobishh: if it's postgres, you can probably start an asynchronous query, then print a dot or something every 10 secs (and flush) and print the result when it's ready
14:28 nicomen I guess I still would offload it to something and poll status from that
14:28 nicomen that way a new call to the request could get the status too
14:30 batman miket: you're down the wrong path if you're doing forking!
14:30 batman miket: please turn around...
14:31 nicomen maybe websocket together with async postgres?
14:35 gryphon joined #mojo
14:35 miket batman: he he thanks I suspect you're right but can't see another way that will work.  what's wrong with fork and what other option is there to call a long(ish) running sub?
14:36 batman miket: DON'T HAVE A LONG RUNNING SUB!!!!
14:36 batman ...
14:37 batman $cb = sub { $i++; $_[0]->send("check $i", $cb) if $i < 10 }; $self->$cb;
14:37 batman ^ have you even tried to run that code?
14:40 miket yes: ^ code works perfectly.  I have to call this sub do_task('mytask') as that's the whole point of my application.  When I do that, it blocks the loop :( only fork seems to not block it
14:40 batman you don't have to do jack shit. that's only in you're mind.
14:41 batman you're not thinking async
14:41 batman what you need to do is to think async and make it work
14:42 batman miket: https://gist.github.com/4337123
14:42 batman oops! typo again :(
14:44 batman https://gist.github.com/4337131 # refresh
14:44 batman you might also need to keep $tx around... i don't remember :(
14:44 amirite_ joined #mojo
14:47 batman so... miket... which part of that code don't you understand?
14:49 amirite joined #mojo
14:49 miket I think I misled you with for loop in my original example - it's not that that's the issue, just that I need to call a sub in an external library, that takes a while to complete.
14:50 miket what I don't understand is, how to make it do something useful i.e. run my task without blocking
14:51 nicomen http://www.slideshare.net/andy.sh/gearman-and-perl :-P
14:52 batman miket: i think you're solving the wrong task the wrong way
14:52 laouji joined #mojo
14:53 miket batman: possibly / probably, I am new to this async stuff, it is quite challenging
14:54 miket this actually *works* though: https://github.com/miketonks/rex-web​ui/blob/master/lib/Rex/WebUI/Task.pm
14:55 batman miket: it's not just that. if you're doing something that takes a while, then you should probably not mess with ws at all.
14:55 batman it's not robust enough
14:55 miket hmm I see
14:56 batman oh. i forgot to add "imho" :P
14:56 miket I did consider two requests, e.g. a post to trigger the task, and a ws call to tail the log
14:57 batman it makes sense what you're doing... somehow. but i think you also need to store the job id in a session.
14:57 batman or
14:57 batman nevermind.
14:58 * batman need sugar
14:59 miket yes +1, jobid is a good idea, need to add that plus logging & audit trail, authentication etc
15:00 sri haha, what's with all the forking today?
15:01 sri batman: DBD::Pg can do non-blocking btw.
15:01 batman sri: i'm not talking about DBD::Pg
15:01 sri it's terrible, but you can use it with a timer and not block
15:03 batman fork--
15:03 batman i think forking in a webapp is just bad
15:03 sri if you're forking in a mojolicious app, you're doing it wrong
15:03 batman it probably forces you to give it permissions which is not any good
15:03 batman just send the job to an external scheduler
15:15 Britzel joined #mojo
15:19 batman____ joined #mojo
15:19 wircus__ joined #mojo
15:22 alexeiras joined #mojo
15:22 labrown joined #mojo
15:25 ObseLeTe joined #mojo
15:31 d4rkie joined #mojo
15:35 jberger sri, devs, any comments before I push this to CPAN? https://github.com/jberger/Mo​jolicious-Plugin-ModuleBuild
15:38 sri don't ask me... last time i used Module::Build was in the early days of catalyst :)
15:43 jberger understood, still does it seem comprehensible?
15:43 jberger I won't ask you to critique the logic
15:48 sri well, it's not incomprehensible
15:49 jberger ok thats a start
15:52 * sri sometimes wonders if Mojo::Base shouldn't just utf8->import
15:52 jberger sri: that you so commonly encode using utf-8 made me rather surprised that you dont
15:53 jberger might you want to do some of the things that utf8::all does?
15:53 ObseLeTe joined #mojo
16:01 sri that seems prety damn dangerious
16:01 sri s/i//
16:01 jberger thats why I said SOME :-P
16:02 jberger obviously changing the filehandle encoding isn't needed by Mojolcious
16:03 sri what else is there?
16:05 good_news_everyone joined #mojo
16:05 good_news_everyone [mojo] kraih created utf8_everywhere (+1 new commit): http://git.io/_JU-VA
16:05 good_news_everyone mojo/utf8_everywhere 34d8bfa Sebastian Riedel: use utf8 in Mojo::Base
16:05 good_news_everyone left #mojo
16:05 sri so far it doesn't seem to break anything
16:05 * sri pokes tempire, marcus and crab
16:06 jberger I'm looking it up. I have gotten into the habit of just using it when I do utf8 stuff, and now I've forgotten
16:07 jberger charnames, warnings
16:07 jberger unicode_strings
16:07 sri all the global stuff seems evil
16:08 jberger the feature stuff is scoped
16:08 jberger and set by perl version
16:08 jberger warnings is scoped
16:09 sri unicode_strings is 5.14+ only
16:09 jberger 'feature'->import::into($target, qw{unicode_strings}) if $^V >= v5.11.0;
16:09 sri yay, a million new special cases for different perl versions!
16:10 jberger sadly thats where we are at
16:10 sri not if we don't use it
16:10 jberger I'm sure you've seen tchrist's ridiculous diatribe from SO
16:11 jberger I mean that's where Perl (and most programming languages) are at
16:11 jberger catching up to the unicode standard version by version
16:17 gryphon joined #mojo
16:23 SmokeMachine joined #mojo
16:26 sri travis reports for branches are neat https://travis-ci.org/kraih/mojo/builds/3741715
16:28 Vandal joined #mojo
16:28 SmokeMac_ joined #mojo
16:34 lammel2 joined #mojo
16:43 dod joined #mojo
17:06 xaka joined #mojo
17:13 jberger released: http://cpan.metacpan.org/authors/id/J/JB/JBERG​ER/Mojolicious-Plugin-ModuleBuild-0.01.tar.gz
17:13 jberger better link: https://metacpan.org/module/JBERGER/M​ojolicious-Plugin-ModuleBuild-0.01/li​b/Mojolicious/Plugin/ModuleBuild.pm
17:17 good_news_everyone joined #mojo
17:17 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/9zJy7Q
17:17 good_news_everyone mojo/master 9526ba6 Sebastian Riedel: new UTF-8 inline template example
17:17 good_news_everyone left #mojo
17:17 sri i've merged the branch
17:24 sri "When UTF-8 becomes the standard source format, this pragma will effectively become a no-op."
17:24 sri wonder what that means
17:30 tempire I won't comment on utf8 stuff.  I'm woefully noobish on the subject.
17:31 tempire WOEFULLY
17:33 sri "The use utf8 pragma tells the Perl parser to allow UTF-8 in the program text in the current lexical scope (allow UTF-EBCDIC on EBCDIC based platforms)."
17:34 sri it's pretty simple
17:36 sri for something to break you would have to have mixed raw binary data into your ascii scripts
17:37 yakudza joined #mojo
17:39 ladnaV joined #mojo
17:46 dwierenga joined #mojo
17:48 amirite_ joined #mojo
17:54 jberger sri: gotta love commits where most files are changed by removing an import. Feels nice and clean.
17:55 mire_ joined #mojo
17:56 sri i'm still not sure if it's the right thing to do though
17:56 sri most people don't understand unicode in perl, hiding some details might make it even harder to understand
17:57 Miked joined #mojo
18:00 sri but yea, removing lines of code always feels great :)
18:05 Vandal joined #mojo
18:14 anewkirk sri, you should include a command that acts like App::presto with Mojolicious
18:23 ObseLeTe joined #mojo
18:26 jnbek^dt joined #mojo
19:02 cfouts joined #mojo
19:06 cfouts hi, all. I have a question about respond_to(). The docs indicate it's okay to use callbacks as the values for a type, but when I do this the controller tries to express the result through a template. (which doesn't always exist because I'm rendering either JSON or PNG in some cases).
19:06 cfouts is there some further flag I can give that prompts mojo to send the raw data as a response rather than trying to find a template?
19:09 cfouts oh, I think I see. the callback can call render() with the appropriate flags
19:39 marcus sir: +1 for use utf8;
19:39 marcus sir even.
19:39 marcus Damn you android device
19:40 batman____ :)
19:41 sri :D
19:41 sri http://cdn.memegenerator.net/i​nstances/250x250/24467784.jpg
19:46 b2b joined #mojo
19:49 marty cfouts;  can you pastie an example?
19:53 cfouts marty: I ended up doing this: http://hastebin.com/sucetiwoye.pl
19:53 cfouts my aim is to lazify the evaluation
19:54 cfouts it's not as tidy looking as without the callbacks, but it works
19:58 wircus__ joined #mojo
19:58 batman____ joined #mojo
20:03 marty cfouts:  That looks very odd.  :)
20:04 wircus__ Apparently angry unicorn is pleased by the JSON config module https://twitter.com/_sattelli​te/status/281475816171384832
20:04 cfouts is there a more idiomatic approach? I'm new to mojo.
20:30 marty cfouts:  The more idiomatic approach (imo) would be to forgo the try block.  I must be missing something on what you are trying to accomplish.
20:32 amirite joined #mojo
20:33 lukep joined #mojo
20:33 wircus__ joined #mojo
20:33 batman____ joined #mojo
20:37 amirite joined #mojo
20:37 cfouts marty: the format_datetime() method can throw an exception in the instance the date wasn't found. so responding with a 404 seems appropriate in that case.
20:43 sinkovsky joined #mojo
20:43 marty Ahh ok.  I guess that works.  You could also test the stash value before the respond_to and handle it there.  Not sure if that is any better though.
20:44 marty afk for a while.  Heading up the cabin to see how much snow.  \o/
20:45 sri \o/
20:50 lukep joined #mojo
20:59 mattastrophe joined #mojo
21:07 mattastrophe joined #mojo
21:07 xaka joined #mojo
21:25 cooper joined #mojo
22:35 ifim joined #mojo
22:42 sri marcus: you still want multiple namespace support?
22:43 sri i might have a patch
22:44 sri i'm not sure what to do about the "Controller does not exist" message though
22:44 sri since there could be multiple candidates, do i list them all?
22:47 Averna joined #mojo
22:49 chorny joined #mojo
22:49 wircus sri: Maybe just list the last one.
22:49 sri the least specific?
22:49 wircus sri: I still think it's interesting functionality. I solved it by making empty subclasses for every controller for now.
22:49 wircus sri: I think so.
22:50 wircus the one where it gives up. :)
23:05 sri marcus: http://pastie.org/5554933 # here's a first patch
23:05 sri test case is ok i guess, but the router needs a cleanup
23:15 marty_ joined #mojo
23:29 wircus sri: yupp. looks pretty good.
23:29 wircus sri: +1 from me on this change.
23:31 jzawodn joined #mojo
23:31 good_news_everyone joined #mojo
23:31 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/WoTO5g
23:31 good_news_everyone mojo/master 6cce3a2 Sebastian Riedel: deprecated Mojolicious::Routes->namespace in favor of Mojolicious::Routes->namespaces
23:31 good_news_everyone left #mojo
23:32 sri marcus: please test :)
23:33 sri i'm especially interested in performance regressions
23:33 sri and the two related log messages not making sense in context
23:34 wircus sri: will report back any findings later this week.
23:34 wircus now it's bed time.
23:35 ObseLeTe joined #mojo
23:35 sri SLEEP THAT'S WHERE I'M A VIKING!
23:35 wircus__ joined #mojo
23:35 batman____ joined #mojo
23:39 batman____ joined #mojo
23:39 wircus__ joined #mojo
23:40 good_news_everyone joined #mojo
23:40 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/0Xow-w
23:40 good_news_everyone mojo/master fb87ecb Sebastian Riedel: fixed typo in test
23:40 good_news_everyone left #mojo
23:45 wircus__ Yay
23:55 ObseLeTe joined #mojo

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