Camelia, the Perl 6 bug

IRC log for #mojo, 2013-07-17

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

All times shown according to UTC.

Time Nick Message
00:20 punter joined #mojo
00:26 punter A certain AJAX endpoint creates and returns random strings of fixed length. Is it normal that I often get the exact same string back returned?
00:26 punter in morbo?
00:27 punter Perhaps I should use a specialized random number generator module, instead of rand/
00:27 punter ?
00:33 shmuel joined #mojo
00:38 davido joined #mojo
00:47 punter left #mojo
00:54 whitebook joined #mojo
01:07 jberger mango is making me coffee as we sp ... ALL GLORY TO THE HYPNOTOAD
01:09 jberger should anyone (punter) read the logs, on restart it wouldn't be surprising to repeat the random iterations
01:09 jberger probably best to srand on restart
01:37 jberger any favorite free android irc client recommendations?
01:44 xablor joined #mojo
01:49 xablor Hey guys, I think I may have found a bug in Mojo::JSON. Does anyone else want to take a look at http://pastebin.com/raw.php?i=qFTGnTQv and see what they get? I'm getting 'is not a HASH reference at line 37'.
01:50 xablor Ordinarily I'd say this is user error, but the hash coming out of Mojo::JSON->decode doesn't have complete values.
01:51 xablor Looking at the JSON from ->encode seems valid, but I'm not an expert in the format.
01:53 omega xablor: $data->{tasks} is an arrayref
01:53 omega you assign that arrayref to an array, you get an array of one element, the arrayref
01:53 d4rkie joined #mojo
01:53 omega so when you do foreach @tasks, $task is the arrayref
01:53 xablor Hm. Thought I tried that...
01:54 omega use Data::Dump; Data::Dump::dump $task; shows it quite easiy
01:54 omega easily
01:54 xablor Okay, fair enough, I'm an idiot. Thanks!
01:55 omega I wouldn't say idiot :)
01:57 xablor Meh. Easily confused, then, how 'bout that? Thanks again.
01:58 abra joined #mojo
01:59 abra joined #mojo
02:16 jberger_ joined #mojo
02:18 jberger_ o/ from android
02:19 * jberger_ has joined the modern world
02:23 dotandimet joined #mojo
02:25 btyler joined #mojo
02:37 cfedde yay!
02:38 xablor left #mojo
02:49 whitebook joined #mojo
02:52 jberger_ joined #mojo
03:18 jberger__ joined #mojo
03:33 mrphilov joined #mojo
03:54 jberger_ joined #mojo
04:23 russum joined #mojo
04:23 russum left #mojo
04:26 shmuel joined #mojo
04:29 two_tired joined #mojo
04:54 d4rkie joined #mojo
05:26 prk joined #mojo
05:53 Britzel_ joined #mojo
06:07 gtodd1 joined #mojo
06:19 nicolaas joined #mojo
06:25 yakudza joined #mojo
06:27 dpetrov_ joined #mojo
06:28 Mike-PerlRecruiter_ joined #mojo
06:34 Meiermann joined #mojo
06:53 rem_lex joined #mojo
07:11 trone joined #mojo
07:22 Vandal joined #mojo
07:49 Moataz-E joined #mojo
08:00 dod joined #mojo
08:08 fhelmber_ joined #mojo
08:08 stephan48 joined #mojo
08:16 fhelmber_ joined #mojo
08:23 dod joined #mojo
08:30 fhelmber_ joined #mojo
08:34 maxhq joined #mojo
08:34 fhelmber_ joined #mojo
08:39 jzawodn joined #mojo
08:45 tiejl joined #mojo
08:46 sri why the hell is everyone recommending Data::Dump?
08:47 sri it messes up data structures
08:49 DaTa for example?
08:49 moltar joined #mojo
08:49 sri https://rt.cpan.org/Public​/Bug/Display.html?id=86592
08:50 DaTa because we only know that for 3 weeks? :)
08:50 bc547 sri: what would you recommend?
08:51 sri anything else
08:51 * DaTa uses Data::Dumper::Concise
08:53 alnewkirk joined #mojo
08:58 two_tired joined #mojo
09:03 moltar joined #mojo
09:07 * sri is amost annoyed enough to change number detection logic back to pre-4.0 state...
09:07 sri *+l
09:08 arthas joined #mojo
09:09 DaTa do it like lehmann: die if $INC{"Data/Dump.pm"}
09:10 batman lehmann--
09:11 cosmincx joined #mojo
09:12 dotandimet joined #mojo
09:17 DaTa http://cpanratings.perl.org/user/psaperl :)
09:41 abra joined #mojo
09:55 moltar joined #mojo
10:01 Adura joined #mojo
10:06 sri marcus, tempire, jberger, crab: any thoughts? should we switch back to stay consistent with JSON/JSON::XS?
10:08 sri the goal was to have number/string detection line up with user expectations... but apparently most just expect equal behavior
10:12 sri of course there's a selection bias... the folks it works for won't say so
10:17 sri ah right
10:17 sri Data::Dump messes up scalars for JSON/JSON::XS too
10:17 sri perl -MJSON::XS -MData::Dump=pp -E 'my $x = {foo => 23, bar => "23"}; say encode_json $x; pp $x; say encode_json $x'
10:18 sri it also stringifies all numbers, which trips up JSON
10:21 whitebook joined #mojo
10:25 ver joined #mojo
10:27 moltar Any idea what can cause this? https://gist.github.com/moltar/6019418
10:34 * sri releases mango 0.06
10:50 perlite joined #mojo
10:51 basiliscos joined #mojo
10:52 KindTwo joined #mojo
10:58 batman sri: i really don't like mango...
10:58 batman it makes me want to switch from Mojo::Redis :/
10:58 batman :)
10:58 sri (:
10:59 batman but i keep reminding me that i've been down the mongo road before... but then i keep thinking that the road might have less rocks this time
11:20 moltar joined #mojo
11:31 * crab scrolls back
11:35 * jberger uses Data::Printer
11:35 * sri is quite surprised how popular Data::Dump seems to be, considering how terrible it is
11:36 jberger when human inspecting that is
11:36 jberger I've never used it
11:36 jberger what is the supposed benefit?
11:36 * sri shrugs
11:39 jberger for me, I want Data::Dumper or Mojo::JSON to survive round trips, and I want Data::Printer for human inspection
11:41 jberger sri: I finally done got me one of those "smarty phones" sos that I can join in to the modern world
11:41 jberger I can't say that I will be very active on IRC during the day
11:41 jberger but at least I won't just vanish
11:41 jberger \o/
11:41 sri \o/
11:42 jberger you realize how much you use the internet when all of a sudden you can use most of it during the day
11:42 jberger can't\
11:52 d4rkie joined #mojo
11:58 moltar Any idea what can cause this? https://gist.github.com/moltar/6019418
12:04 sri moltar: repeating the same question pretty much never results in an answer, what you have to do is provide more information, until someone has an answer or you find it yourself on the way
12:05 moltar sri: thanks for your input, but i lost internet connection for about an hour, wasn't sure if it was answeered
12:05 sri see topic, there's a log
12:05 moltar And I don't really have more information, at least I don't know what else to provide....
12:06 moltar oh nice re log
12:06 moltar i wish more channels had that :)
12:06 asarch joined #mojo
12:10 batman moltar: Not sure if that question is really for us, since the error complains about Net::HTTP::Methods
12:11 batman moltar: but it's probably because of something dieing inside the app. you could try to do $SIG{__DIE__} = sub { Carp::cluck(@_) }; inside the app and see if your logs get populated with the error message
12:12 batman but for next time: remember to bubble the error messages to your log
12:12 batman error messages = exceptions
12:12 moltar batman: thanks for the pointer, actually it is probably something dying
12:12 moltar how do you bubble them up?
12:12 batman i bet my ice cold beer on it.
12:12 moltar I didn't design the app… normally i do log exceptiopns to file, but this is something i was handled to maintain and its a complete mess :(
12:13 batman eval { do_crazy_shit(); 1 } or do { log($@) }
12:13 moltar ok so basically just do exception handling. i thought there was some magical way in mojo to bubble up messages :)
12:13 batman then add the $SIG line i pasted and see if anything shows up.
12:14 moltar where is the best way to trap dies in mojo app?
12:14 moltar should i put it in the main class with routes?
12:14 batman i would probably put it into a $app->hook(before_dispatch => sub { ... }); hook, but either way it's a super ugly hack which WILL haunt you later on
12:15 moltar but its temporary just to figure out where the error is coming from
12:16 moltar because i had ran into another issue earlier where the app was receiving sigquit from somewhere unknown
12:16 moltar its totally retareded
12:16 moltar i had to capture that
12:16 moltar after every request it'd receive sigquit
12:16 moltar and i couldn't find it
12:18 d4rkie joined #mojo
12:19 shmuel joined #mojo
12:31 jberger__ joined #mojo
12:37 moltar_ joined #mojo
12:39 crab so i have a program that takes a url like this: /mythingy[/YYYY[MM[DD]]][/<tag-e​xpr>][/index[.<rss|atom|html>]]
12:41 batman crab: good for you! ;)
12:41 crab everything is optional, more or less. so /foo or /foo/index, or /foo/2013/index, or /foo/2013/something/index
12:41 crab what's a sane way to express that in the mojo router?
12:42 crab (in this particular case, i was just trying to get some legacy code to work, so i did /foo(*any) and then parsed any myself. doesn't matter, worked ok.)
12:42 crab but i was curious about whether there's a better way to do it
12:42 batman i would make multiple routes
12:43 crab and make each one set a thingy in the stash and call the same function in the end?
12:43 crab makes sense, i guess
12:43 crab but i'd have to write a route for each possible combination of optional elements
12:45 batman i would restrict the way to combine the path. figure out what you need and support that
12:46 crab that's what i need. compatibility with existing urls and all that.
12:46 batman oh.
12:46 crab anyway, you more or less confirmed my feeling that this is just not a nice situation to have.
12:46 batman that sucks :)
12:46 batman (i may be wrong)
12:46 crab but you're batman
12:47 jberger__ What about 'under'
12:47 batman crab: it sucks, but it's true: even i can be wrong...
12:48 crab well, what about under
12:49 jberger__ $foo = $r-> under ('/foo')
12:49 batman jberger__: what good does that do?
12:49 jberger__ I'm new to irc on a mobile phone
12:51 jberger__ Makes it easier to make routes under /foo
12:51 crab the trick to irc'ing on a phone is to throw out mysterious but faintly promising clues in a few words (e.g. "what about 'under'") and disappear and let other people speculate. ;-)
12:51 batman :D
12:52 jberger__ Perhaps I don't understand the problem:-)
12:52 crab batman: one thing i thought of is to make a list of the various components, and then generate all the valid combinations and stringify them and generate a route for each one, pointing to the same function
12:53 crab which is the same thing really, but a bit more maintainable if i have to change the url much (which in fact i don't, but anyway)
12:53 jberger__ OH
12:53 jberger__ I see
12:54 jberger__ Yeah nm. That's a tough one
12:55 jberger__ Yeah catch all and parse later would be my thought too
12:55 batman crab: maybe you could normalize the url in a "before_routes" hook which then always match the route /:date/:tag/index.:format
12:57 crab batman: so it'll rewrite "" to "///index.html"? hmm.
12:57 crab i'll see if i can do anything with that idea.
12:57 batman crab: i think the design sucks so i refuse to answer that question :(
12:57 batman ...just throwing ideas out there
12:58 crab oh, i could convert the date and tag exprs to stash values and just chop them out of the url
12:58 crab batman: i don't think the design sucks really. it's just awkward to handle by writing separate routes
12:59 crab it's a fairly sensible design from the url point of view.
12:59 batman crab: sorry. not "design" but my "before_routes" idea
12:59 batman crab: but i really don't like supporting every weird url format. i would rather support the most common one.
13:02 crab ok, based on this discussion, if i didn't already have working code and had to do it over, i think i'd do something like this:
13:03 crab $x = $r->route('/foo')->bridge->to(cb => sub { shift bits off @path and stick them in the stash as long as they're date or tag exprs }); $x->get('/')->to(...); $x->get('/index.:format')->to('same#thing');
13:04 crab it's not a fundamental change, just shifting the parsing problem to the bridge, but it does have the advantage that the action method will become short and easy to read.
13:04 crab thanks.
13:08 mrphilov joined #mojo
13:12 sri legacy URLs usually means rewriting for me
13:12 sri you don't want legacy stuff in your new code
13:14 batman crab: do you have mojo behind a proxy or directly on interne?
13:14 batman *internet
13:15 batman crab: if you're behind nginx or something alike, then i would do url rewrite in the webserver and then keep the url's clean in mojo
13:15 batman you could even do 301 from the webserver
13:16 sri rewriting in a before_dispatch is not a bad solution, still clean separation
13:16 sri and easier to test
13:18 sri what i would be worried about is a mess of legacy hacks in the middle of my pretty new routes
13:19 * batman agrees
13:20 crab well, what would the pretty new routes look like?
13:20 crab or you mean you're ok with keeping the route as '/' and passing the actual info in the stash?
13:20 crab while i agree that it keeps the routes pretty, it also feels at least a little dishonest
13:21 sri i'm usually opposed to the whole make a dozen things optional in a URL thing
13:21 sri clean RESTful URLs and everything too dynamic gets a query parameter
13:22 crab well, the only real option is to say /index?date=YYYY[MM[DD]];tags=...
13:22 crab yeah
13:22 batman crab: i don't agree
13:22 marty I use $self->dumper(); a lot.  Is creating my own helpers using something like Data::Printer a reasonable solution?
13:22 crab you don't agree that that is an alternative?
13:23 sri i have to admit i've not looked at your original problem yet though ;p
13:24 batman i would do "/index", "/:date/index" and "/:date/#tags/index" where :date can be an actual date or ex. "any" and tags can be tag1:tag2:tag3
13:24 batman and remove the "/index" part
13:25 sri what annoys me about your URL is date being optional
13:25 KindTwo joined #mojo
13:26 batman s/any/all/ maybe... or even require at least a year
13:27 sri tags seem more like a search criteria than a path part
13:27 sri doesn't feel like a REST endpoint
13:27 jberger_ joined #mojo
13:28 batman btw... crab: WHAT DOES THE RESOURCE ACTUALLY RETURN?
13:28 batman :/
13:29 crab a picture of a grumpy cat
13:29 crab (always the same grumpy cat)
13:29 batman are you stealing grumpify.com ?? ;)
13:29 * crab whistles innocently
13:29 batman crab: ah! but then you need a wildcard url. case closed.
13:30 batman i mean... you wouldn't want an url which did not result in a grumpy cat picture. that would be evil.
13:30 crab true, true.
13:31 sri the /index at the end is also uncool from a REST point of view
13:31 batman i totally agree!
13:31 batman looks it's an url from 1999.
13:31 batman ;)
13:32 batman *looks like
13:33 sri if it's an archive filtered by tags... i'd just go /archive/YYYY(/MM(/DD))?tag=foo&tag=bar
13:34 sri if it's search just /search?date=YYYYMMDD&tag=foo&tag=bar
13:34 sri context matters a lot
13:34 sri what actually *is* the resource
13:35 crab it's an archive filtered by tags or by date
13:35 two_tired joined #mojo
13:35 sri sounds to me like query parameters all the way
13:36 crab but, one part of the context was that the urls are meant for people to read/write/link to
13:36 crab anyway, all this is ancient history.
13:39 moltar joined #mojo
13:39 sri it usually helps to look at well designed apis for inspiration :) http://developer.github.com/v3/
13:44 batman is there anyway to add query params to link_to() without doing link_to((url_for()->query(foo => 123)) ?
13:49 crab link_to()."?foo=123" of course
13:49 * crab runs
13:49 batman :)
13:52 bluescreen joined #mojo
13:54 abra joined #mojo
14:00 marcus_ url_with ?
14:02 sh4 joined #mojo
14:02 batman nope
14:24 gryphon joined #mojo
14:27 btyler joined #mojo
14:27 marty perl -mojo -e 'my $json="{\"foo\":\"bar\x{2019}\"}"; print Mojo::JSON->decode($json)';    # prints nothing
14:29 marty I'm not sure if that is expected behavior or not.
14:31 jpn joined #mojo
14:50 batman marty: Mojo::Util::encode("UTF-8", $json)
14:50 batman perl -mojo -le 'my $json="{\"foo\":\"bar\x{2019}\"}"; print Mojo::JSON->encode(Mojo::JSON->de​code(Mojo::Util::encode("UTF-8", $json)))'
14:51 * batman gets something to eat
14:57 shmuel joined #mojo
15:02 marty batman:  thank you bro, that works swimmingly.
15:26 moltar joined #mojo
15:37 moltar joined #mojo
15:48 sri marty: only bytes can be JSON
15:49 sri $json->error should have told you so
15:51 * sri bonks marty on the noggin
15:51 sri ->encode is not a class method
15:59 kthakore joined #mojo
15:59 kthakore hello I am using hypnotoad behind nginx http://search.cpan.org/~sri/Mojolicious-4.1​8/lib/Mojolicious/Guides/Cookbook.pod#Nginx 1.4.1 https://aimedstat.com
16:00 kthakore but the initial https negotiation seems to be very slow with hypnotoad. Should there be a different configuration for https proxy in nginx to http://*:8080 in hypnotoad?
16:12 Britzel joined #mojo
16:14 crab how is hypnotoad involved in the https negotiation at all?
16:15 kthakore crab: well it isn't but when I switch to a static site, there is no slow response. I am just wondering if http://search.cpan.org/~sri/Mojolicious-4.1​8/lib/Mojolicious/Guides/Cookbook.pod#Nginx (which is currenntly on port 80) the same for port 443 with ssl?
16:16 crab yes, except then it makes sense to set X-Forwarded-HTTPS to 1 instead of 0.
16:17 crab are you running on a crappy vm with little or no entropy, perchance?
16:19 * marty does a palm faceplant.   sri++
16:19 kthakore crab: ok
16:37 delias joined #mojo
17:00 marty joined #mojo
17:11 denisboyun joined #mojo
17:20 denis_boyun_ joined #mojo
17:41 dod joined #mojo
17:43 trone joined #mojo
17:58 dod joined #mojo
18:06 mrphilov joined #mojo
18:08 phillipadsmith Am I correct in assuming that if I want <label> tags for %= form_for inputs that I need to define them with %= tag 'label' => 'Input label'  ?
18:19 tempire Bank Simple!
18:19 tempire finally.
18:27 bowtie_ joined #mojo
18:30 Mike-PerlRecruiter_ joined #mojo
18:38 phillipadsmith tempire: you got that e-mail too, eh?
18:47 denisboyun joined #mojo
18:57 bluescreen_ joined #mojo
19:10 BeDa joined #mojo
19:15 dotandimet joined #mojo
19:17 zackiv31 joined #mojo
19:47 Kovensky joined #mojo
20:02 rem_lex|pivo joined #mojo
20:09 maxhq1 joined #mojo
20:26 nickelroy joined #mojo
20:29 gryphon joined #mojo
20:37 punter joined #mojo
20:44 chansen joined #mojo
21:17 hesperaux joined #mojo
21:18 hesperaux_ joined #mojo
21:22 hesperaux__ joined #mojo
21:33 lukep joined #mojo
21:42 * sri wonders if $writer->write('foo' => sub {...}) should die right away if the file has already been closed or invoke the callback with an error message
21:47 dwierenga joined #mojo
22:05 sri ok, passing an error to the callback for ->write and letting ->close succeed multiple times
22:08 sri bit tedious, but i think it's better to make it hard to mess up gridfs files https://github.com/kraih/mango/commit/6​76a27e3e9fcbeb11173210c4f91df3cb9a3fc44
22:26 sri tempire: you still owe me a mango mojocast! :p
23:12 davido joined #mojo
23:13 diegok joined #mojo
23:14 Mikey joined #mojo
23:14 jberger_ joined #mojo
23:15 gautier joined #mojo
23:32 jast joined #mojo
23:49 russum joined #mojo
23:54 russum left #mojo

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