Camelia, the Perl 6 bug

IRC log for #mojo, 2012-10-28

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

All times shown according to UTC.

Time Nick Message
01:09 ki0 joined #mojo
01:19 xaka joined #mojo
01:54 GabrielVieira joined #mojo
03:50 noganex joined #mojo
04:05 kbenson1 joined #mojo
04:11 kbenson1 Is there any interest in ordered attributes in Mojo::DOM?  I implemented a fix (in 3 lines) using Tie::Hash::Indexed, but that's without providing regular hash fallback and/or a way to specify that ordering is not needed/wanted, which would be a bit more work.
04:12 kbenson1 I tested on a few different large-ish HTML pages of differing complexity, and it seems to come with a fairly consistent 10% perfomance penalty.
04:13 kbenson1 That is, 10% when doing a full parse and render, as evidenced by ojo::x.
04:19 tempire I don't think you're going to get much support there.  Attributes are more of a set rather than a list.
04:20 kbenson1 Understood.  This was mostly because I found that ojo worked really well for loading in HTML docs, transforming when in specific ways using selectors and HTML::DOM, and writing them back out.
04:21 kbenson1 Unfortunately, the attributes for elements are not written in the same manner they were read.  While this makes no practical difference when presented to the browser, it DOES make a difference for source control.
04:23 kbenson1 In other words, this is awesome, but I want it to be *more so*: perl -Mojo -MFile::Slurp -E 'for (@ARGV) { write_file( $_, x(scalar(read_file $_))->at("#user-info")->replace("")->root ); }' test.html
04:25 tempire well
04:25 tempire you can make it a little more awesome by using Mojo::Util instead of File::Slurp
04:25 kbenson1 Oh?  Did I miss a better way to pull in local content?
04:27 tempire for example perl -Mojo -E 'say x(b("test.html")->slurp)->at("title")->text'
04:27 kbenson1 nice, thanks!
04:28 tempire ojo all the things!
04:29 kbenson1 I was looking for something, but didn't find it.  I figured there had to be a way, but wasn't approaching from the right direction (I was trying g() on file://, etc)
04:46 vishwanathms joined #mojo
04:46 vishwanathms_ joined #mojo
04:47 inokenty joined #mojo
04:52 laouji joined #mojo
04:52 laouji joined #mojo
04:54 lukep joined #mojo
05:42 marty joined #mojo
06:11 vel joined #mojo
06:35 Vandal joined #mojo
07:19 Mike-PerlRecruiter_ joined #mojo
07:19 sh4 joined #mojo
07:25 Vandal joined #mojo
07:52 ObseLeTe joined #mojo
07:53 ObseLeTe joined #mojo
08:15 judofyr joined #mojo
08:15 kbenson joined #mojo
08:16 kbenson left #mojo
08:53 marcus jberger++
09:03 alnewkirk joined #mojo
09:42 amirite joined #mojo
09:43 stocks joined #mojo
09:44 Britzel_ joined #mojo
09:51 amirite joined #mojo
09:59 batman joined #mojo
10:00 batman http://whiteboard-jhthorsen.dotcloud.com <-- made a drawing app in mojo yesterday :)
10:01 marcus batman: it only shows a single red dot here.
10:01 batman https://gist.github.com/3964764 # funny example
10:01 batman marcus: look now
10:01 marcus woot
10:01 marcus Iwanna draw poop too!
10:01 batman http://whiteboard-jhthorsen.dotcloud.com/?master=1 <--- master=1 makes you able to draw
10:02 batman test it on your iphone :)
10:02 batman hehe
10:03 batman it's cooler on the iphone
10:03 marcus its' cooler on ipad, actually
10:04 marcus <3 chrome cloud tabs too
10:04 batman ah. "cooler on touch device"
10:04 marcus btw, you missed an epic party on friday. :-)
10:04 batman rub it in :P
10:04 marcus of coure
10:04 marcus course
10:04 batman :)
10:06 judofyr joined #mojo
10:27 ryozi joined #mojo
10:53 sh4 joined #mojo
11:02 Foxcool joined #mojo
11:19 batman it's funny to waste time on useless stuff :)
11:19 batman i just added support for more whiteboards. yay!
12:08 kitt_vl joined #mojo
12:09 batman joined #mojo
12:11 * sri yawns
12:18 memowe_ joined #mojo
12:22 marcus I really like the iPhone 5
12:23 Foxcool joined #mojo
12:24 sri i really like bacon
12:26 marcus Having a longer phone even makes the terminal usable with the soft keyboard.
12:26 marcus And it's great for movies too of course :)
12:28 crab bacon movies.
12:28 marcus Sri: I don't eat nearly enough bacon.
12:29 crab i haven't eaten any bacon in years.
12:29 sri having a more tasty breakfast makes waking up in the morning a more pleasant experience
12:29 crab oh wait, i don't eat meat. that explains it.
12:29 sri and it's great with scrambled eggs too of course :)
12:30 crab are you still taking care of horses?
12:30 sri nope
12:32 marcus I primarily eat bacon with fried eggs.
12:32 marcus But I tend to forget that we have it in the fridge.
12:36 sri mmmmmm
12:38 DaTa http://mcphee.com/shop/bacon-toothpaste.html
12:38 DaTa for the pleasant morning :)
12:40 sri :S
13:12 Vandal joined #mojo
13:22 ki0 joined #mojo
13:27 rem_lex|pivo joined #mojo
13:33 trone_ joined #mojo
14:05 d4rkie joined #mojo
14:07 marty joined #mojo
14:23 dbr joined #mojo
14:39 jberger mmmm, I wish I had some bacon
14:40 jberger marcus: I wanted to allow per-page sanitization, but that really only works if you restrict editing to certain editors
14:41 jberger I do want to implement per-page owner/authors at some point, I just haven't gotten there yet
14:43 jberger for now its a global policy
14:44 jberger but you can turn it on and off in the config file and reload
14:44 sri kbenson1: i agree with tempire btw.
15:04 gryphon joined #mojo
15:12 scrooby joined #mojo
15:13 scrooby Hi
15:13 scrooby I think I've found a bug in Mojo::UserAgent with extremely high numbers of async requests
15:17 Britzel_ Hi. Can't get I18N plugin to work. i18n language is always 'en' (the internal default), although browser is set to french. Accept header is: 'fr-fr,de;q=0.8,en;q=0.5,de-de;q=0.3'. Tried with FF, Chrome and IE9 under Win7 and FF under Linux, all the same, alwas 'en'. Any ideas?
15:18 sri scrooby: details?
15:19 scrooby I have a file with 39 million lines
15:20 sri are you saying you're making 39 million parallel requests?
15:20 scrooby I'm using Mojo::IOLoop::Stream and Mojo::UserAgent
15:21 scrooby I post each stream chunk as a post_json with the ua
15:21 sri stop right there
15:21 sri that makes no sense
15:21 scrooby (libev) select Invalid argument
15:21 scrooby This is what I gegt
15:22 scrooby Why does it make no sense?
15:22 scrooby I can do it with AnyEvent::Curl::Multi
15:23 sri Mojo::IOLoop::Stream is not for file i/o
15:23 scrooby Ok...
15:23 sri the whole idea of reading a file non-blocking is silly
15:23 scrooby It seems to work for small numbers of requests though
15:24 sri it just does not work
15:24 scrooby But if I try to read ot blockingly the request won't kick off util the whole 39million are read
15:24 sri i have no idea what exactly is going wrong in your program, but that part is already wrong
15:25 scrooby would you mind having a look at a pastebin?
15:25 sri if it's not a wall of text
15:26 scrooby it's a small script. Thanks.
15:26 scrooby just an IOLoop with a nested Useragent
15:26 sri first of all, file i/o is *never* non-blocking, you can just it blocking in chunks
15:27 sri *read
15:28 sri to make it look non-blocking to an event loop it would have to happen in a separate process/thread
15:30 sri and they are always readable and writable, so by putting them in EV/Poll you're wasting resources and gain absolutely nothing
15:31 sri depending on platform... event loops like EV may not even support that kind of file descriptor
15:31 sri which may very well be your problem
15:32 scrooby http://pastebin.com/mnr3n1nq
15:32 scrooby Do you recommend chunking the file?
15:33 scrooby The error is consistently (libev) select: Invalid argument
15:33 sri sorry, but that is too messed up for me
15:34 sri i don't even know where to start
15:34 scrooby Ah
15:34 scrooby Whoops
15:34 scrooby what's the biggest mistake and I'll go back to the draing board
15:36 sri i think the error "(libev) select: Invalid argument" means that you've reached the file descriptor limit of select()
15:37 scrooby do you know of a way to increase the file descriptor limit?
15:37 sri perhaps this example can help http://mojolicio.us/perldoc/Mojoli​cious/Guides/Cookbook#Nonblocking
15:37 sri that's how it's properly done, with a queue
15:38 scrooby Ok
15:38 scrooby so a timer might help...
15:40 scrooby I'll scrap the current code and start again from this approach
15:40 sri and don't use Mojo::IOLoop::Stream
15:42 scrooby M::I::Stream seemed to be doing what I want for smaller batches (30,000) of lines. It's a pity I can't use it.
15:42 sri it doesn't do what you think it does
15:42 scrooby I'll maybe try AIO
15:42 sri that's just as useless in this situation
15:43 sri just use the normal Perl api and read in chunks
15:43 scrooby I'd like to start receiving the results from the webservice before the whole file has to be read
15:44 scrooby I tried the chunking approach, seeking and sysread but it still blocked until all the chunks where read.
15:45 scrooby what do you think of this -> http://search.cpan.org/~xantus/​MojoX-AIO-0.05/lib/MojoX/AIO.pm
15:46 scrooby 39million lines takes a long time even to just pipe to STDOUT never mind to a webservice
16:05 sri you might want to take a look at Mojo::Asset::File, it shows how to use sysseek and sysread correctly
16:05 vishwanathms joined #mojo
16:05 vishwanathms_ joined #mojo
16:14 scrooby thanks for the pointer sri.
16:15 scrooby I'm completely changing my approach after this. If I ever get a working solution I'll post for your interest.
17:05 xaka joined #mojo
17:39 pierrick joined #mojo
18:00 d4rkie joined #mojo
18:36 tempire bacon pancakes
18:42 jberger sri: how many bytes should a secret be?
18:43 jberger I am thinking about having some automation on secrets, especially if '/dev/urandom' exists (i.e. on linux)
18:43 jberger I mean I'm doing this in Galileo, though it might be useful in Mojolicious too
19:06 ki0 joined #mojo
19:09 * tempire accidentally a math http://mathb.in/1096
19:10 zpmorgan perceptron?
19:10 tempire decepticon
19:11 zpmorgan oh
19:11 zpmorgan looked like backpropagation for a second
19:11 tempire gradient descent, actually
19:11 zpmorgan what for, if i may ask?
19:12 dabudabu joined #mojo
19:13 tempire supervised learning, so I think it's the same area of what you're talking about. perceptron is classification, right?
19:13 zpmorgan yes. or regression.
19:14 tempire oh, then maybe you're right.
19:14 zpmorgan https://github.com/zpmorgan/AI-Nerl :)
19:14 batman joined #mojo
19:14 * tempire keeps mathing
19:19 Mike-PerlRecruiter_ joined #mojo
19:35 jberger sri: I see in Mojo::Util::_hmac that it wants at least 64 bytes, do more help or are they superfluous?
19:41 oldiie joined #mojo
19:41 oldiie hey
19:41 tempire HEY!
19:41 oldiie could anyone tell me how I can get the part after </h4> from http://pastebin.com/i6TQGNmh
19:42 tempire after or within?
19:42 oldiie <div> and <h4> are there serveral times likes this...
19:42 oldiie I want to get: €2,137,456 (Italy) (15 April 2012) (420 Screens)
19:43 tempire look in Mojo::DOM at the text* methods
19:43 oldiie you mean text after?
19:43 oldiie text_after
19:45 oldiie $week=$dom->find('div[class=txt-​block]')->div->/h4->text_after;
19:45 oldiie something like this?
19:45 oldiie this isn't right, correct?
19:51 tempire try 'div[class=txt-block] h4'
19:52 jberger 'div#txt-block > h4'?
19:53 jberger I guess you don't need the >
19:53 ki0 joined #mojo
19:55 oldiie but the prob is that there are serveral kinds of <div class="txt-block"> <h4 class="inline"></h4>
19:56 oldiie just the text between <h4 class="inline"> and </h4> is different and I want just the part after Opening Weekend:</h4> until the next </div>
19:58 tempire try messing around the with selectors in Mojo::DOM::CSS
19:58 tempire nth-child may be of use to you
20:00 oldiie but it don't show on every title :|
20:01 oldiie not every movie has some information before and so there is a different order...
20:04 jberger $ua->find('div#txt-block h4#inline')->grep(sub{$_->text eq 'Opening Weekend:'})->pluck('text_after')
20:11 heytrav joined #mojo
20:12 jberger oops s/#/./g
20:13 oldiie thank you, that's cool :)
20:16 jberger https://gist.github.com/3969742
20:16 perlite_ joined #mojo
20:32 sri jberger: that doesn't sound like such a good idea
20:33 jberger ?
20:33 sri automatic secrets
20:34 jberger why not?
20:34 sri how and when would you generate it?
20:36 batman joined #mojo
20:36 sri plugin 'RandomSecret';?
20:37 jberger either on setting up the application (install time), or instantiation, hadn't decided yet
20:37 jberger https://www.youtube.com/watch?featur​e=player_embedded&amp;v=YDW7kobM6Ik
20:37 sri yea, that falls apart as soon as you add a second server
20:37 jberger basically he recommends generating secrets from urandom rather than from system data
20:38 jberger ok, thats true, I haven't ever gotten that dar
20:38 jberger far
20:41 jberger it might make an interesting plugin
20:41 jberger I like that idea
20:41 jberger with a caveat that its probably better for small projects
20:43 lukep joined #mojo
20:46 ki0 joined #mojo
20:51 sri would also suck to invalidate all sessions just because you restarted the server
20:51 sri makes zero downtime restarts useless
20:56 jberger galileo has a command which writes out a configuration file, that is what I meant by "install time"
20:56 jberger that file could be copied to other servers
20:56 jberger but yeah, thats more app specific
21:02 nic One of my ideas is to create the secret based on lex least mac addr plus date plus something app specific
21:02 nic It would only be for one-box apps
21:04 nic I could use the filename of the code setting the secret as the app-specific bit
21:05 jberger nic: thats exactly what that video tells you not to do
21:05 jberger seriously watch it
21:05 jberger kinda scary
21:11 SmokeMac_ joined #mojo
21:30 Britzel_ Hi. I need to put one variable in all my templates, regardless which route they came from. Where/How do I do this? Bridge? under/oder?
21:30 Britzel_ s/oder/oder/
21:30 Britzel_ fsck
21:30 Britzel_ s/oder/over/
21:31 batman app->defaults(foo => 123);
21:31 batman stash() will contain all the variables from defaults() on each request
21:32 Britzel_ Ah, sure, ok, but I forgot to say that this is a variable which is determined from the request, so I cannot put it in a quasi 'static' variable.
21:32 batman app->hook(before_dispatch => sub { my $c = shift; $c->stash(foo => 123) });
21:33 Britzel_ ok, cool, thanks. Never looked at hooks before.
21:36 ki0 joined #mojo
21:37 asarch joined #mojo
21:57 Averna joined #mojo
22:26 * marcus prepares to test a django app
22:26 * marcus phears the pip
22:32 * tempire pips
22:41 jzawodn joined #mojo
22:45 ki0 joined #mojo
22:49 SmokeMac_ joined #mojo
22:50 marcus https://github.com/37signals/sub is pretty neat
22:51 marcus wow, the django app just worked out of the box
22:51 marcus something must be wrong.
22:51 marcus :)
23:00 SmokeMac_ joined #mojo
23:38 human39 joined #mojo
23:41 SmokeMac_ joined #mojo
23:57 ki0 joined #mojo

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