Camelia, the Perl 6 bug

IRC log for #mojo, 2013-01-21

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

All times shown according to UTC.

Time Nick Message
00:02 jzawodn joined #mojo
00:12 Molaf_ joined #mojo
01:00 Molaf__ joined #mojo
01:04 asarch joined #mojo
01:07 ka2u joined #mojo
01:08 Mike-PerlRecruiter_ joined #mojo
01:20 hlin joined #mojo
01:52 d4rkie joined #mojo
02:22 dabudabu joined #mojo
02:25 Miked joined #mojo
03:08 amirite joined #mojo
03:29 rem_lex joined #mojo
04:00 noganex_ joined #mojo
04:14 asarch joined #mojo
04:45 xaka joined #mojo
04:46 TitanOfOld joined #mojo
05:08 ka2u joined #mojo
05:10 yakudza joined #mojo
05:42 Averna1 joined #mojo
05:57 spleenjack joined #mojo
06:12 D4RK-PH0ENiX joined #mojo
06:55 dod joined #mojo
07:03 dpetrov_ joined #mojo
07:06 Vandal joined #mojo
07:11 ver joined #mojo
07:12 yakudza joined #mojo
07:13 dod joined #mojo
07:25 Miked joined #mojo
07:31 Adura joined #mojo
07:35 spleenjack1 joined #mojo
07:52 dod joined #mojo
07:54 dod joined #mojo
07:59 spleenjack joined #mojo
08:31 shmuel # Expiration date in seconds from now (persists between requests)
08:32 shmuel $c->session(expiration => 604800);
08:32 shmuel what does it means?
08:32 shmuel is the expiration being saved inside the session itself, and every request it will be automatically extend?
08:40 taryk joined #mojo
08:40 taryk left #mojo
09:21 ulric joined #mojo
09:21 fhelmber_ joined #mojo
09:27 crab yes.
09:33 jegade left #mojo
09:36 sivoais_ joined #mojo
09:54 Miked joined #mojo
10:27 SmokeMachine joined #mojo
10:52 ObseLeTe joined #mojo
11:47 ObseLeTe joined #mojo
11:47 ObseLeTe joined #mojo
12:27 vervain joined #mojo
12:40 tholen joined #mojo
13:04 spleenjack1 joined #mojo
13:10 Mike-PerlRecruiter_ joined #mojo
13:15 d4rkie joined #mojo
13:25 ryozi joined #mojo
13:27 mugenken joined #mojo
13:57 yakubori joined #mojo
13:57 yakubori buenos dias todos o/
13:57 yakubori err buenas :P
13:59 vervain \o
14:04 yakubori I ran into something I believe is an issue with Mojo::URL. The regex on line 85 of URL.pm, if I interpret it correctly, will not allow something like 'http://www.example.com/#/foo' as a valid url. Am I reading that right?
14:10 bluescreen joined #mojo
14:17 lppoix joined #mojo
14:19 lppoix left #mojo
14:19 lppoix joined #mojo
14:22 spleenjack joined #mojo
14:25 mattastrophe joined #mojo
14:32 bjoernfan yakubori: What are you using that triggers that error?
14:39 Miked joined #mojo
14:40 gtodd buenos
14:43 yakubori gtodd: yep, masculine. my bad :D
14:44 yakubori bjoernfan: I don't get an error. I just don't get any parts out of it. it *looks* like parse is not getting anywhere and I'm guessing it's due to the regex.
14:44 yakubori but i'm still testing to be sure
14:44 ObseLeTe joined #mojo
14:46 yakubori bjoernfan: In Dupmer() it looks like the host and scheme properties are set, but nothing else.
14:47 yakubori maybe it's something to do with Mojo::Path? still looking…
14:48 yakubori digging into the guts of the modules, it's not that Mojo::URL does not count it as a valid url (as I originally thought), but that it's not parsed as I expected.
14:56 nicomen $ perl -MTest::More=no_plan -MURI -MMojo::URL -wle 'my $u = Mojo::URL->new("http://foo.com/#/foo"); my $u1 = URI->new("http://foo.com/#/foo"); my $u2 = join "", $u->scheme . "://" . $u->host . $u->path . "#" . $u->fragment; is($u, $u1); is($u, $u2);'
14:56 nicomen ok 1
14:56 nicomen ok 2
14:56 nicomen 1..2
14:58 yakubori you're explicitly joining on the hash?
14:59 jnbek^dt joined #mojo
15:00 nicomen yes, to show that it has the correct parts
15:00 nicomen then comparing with the URI that comes out of URI and Mojo::URKL
15:04 gryphon joined #mojo
15:04 yakubori http://www.foobar.int/asdf/foo/bar <- this will give me parts: ['asdf', 'foo', 'bar']
15:04 yakubori http://www.foobar.int/#/foo/bar <- this gives me parts: []
15:06 d4rkie joined #mojo
15:07 yakubori if that's intended behavior, i'm wondering why that might be
15:07 sri yakubori: think about that for a moment, what does # in a URL mean? :)
15:09 yakubori not sure, sri. other than the case i'm seeing it's apparently for history functionality on ajaxy web apps
15:09 yakubori (shrug)
15:09 dminus hint: it never makes it to the server
15:09 sri yakubori: http://en.wikipedia.org/wiki/Fragment_identifier
15:10 yakubori ok. but are we only ever dealing with urls that are interpreted by a web server?
15:11 yakubori if this is an ajax hack (again, i'm a bit new to this so please bear with me), shouldn't it be considered valid and broken up, even if it's only interpreted by some client-side framework?
15:12 amirite joined #mojo
15:12 dminus the request that the client makes never includes the hash bit
15:13 dminus so visiting that url, all mojo ever sees is up to but not including the hash
15:13 nicomen it's evil to use such urls anyway
15:13 dminus unless you do an onload event or something to pass window.location
15:13 dminus which would be ajax hacky
15:15 vervain Is the real answer that mojo has chosen to 'clean up / ignore' these url parts if they do happen to make it through to the server?
15:15 yakubori ok, i see that. but i'm asking, if it's a valid url, taking mojo out of the equation from a service point of view, should a url class that's breaking the path up include it in the parts? or does that break some standard way of handling urls as compartmentalized strings?
15:16 nicomen no, the real asnwer is, the fragment part of a url ends up in the fragment method
15:16 yakubori vervain: as in, i want to take a url string and store the scheme, authority and path separately, in a 'urls' table for example.
15:16 Britzel joined #mojo
15:16 nicomen it's a valid url, but the server will never know anything about the fragment part if used in a request
15:17 yakubori nicomen: ok. that's cool.
15:18 yakubori learn something new every day :P
15:20 nicomen http://www.webmonkey.com/2011/02/gawker-lear​ns-the-hard-way-why-hash-bang-urls-are-evil/
15:23 yakubori heheh
15:28 yakubori so, it's the flipside of the coin i suppose. oldschool browser interpretations for things like target areas of a page are being (ab)used…
15:32 ulric left #mojo
15:32 yakubori so, i should be okay with reconstructing a url in that, if I have fragments, i can concatenate with 'q|#|.$url->path->fragment', correct?
15:33 dminus $url->fragment
15:33 dminus cause technically the path stops before the fragment
15:33 dminus in http parlance
15:33 yakubori ah, right. ok
15:34 * yakubori is going to become an expert using the 'Fail First' approach :D
15:34 yakubori anyway, thanks for shedding light on this.
15:34 dminus ./salute
15:38 TitanOfOld joined #mojo
15:39 nicomen so, on a server, you would really not have use for fragments, unless you are generating urls to a specific place in page
15:39 nicomen a browser doesn't send the fragment part when doing a request
15:42 yakubori nicomen: ya, the page target is the only case i've seen with # in a url, before running into this. and I didn't even make the connection when sri asked...
15:43 yakubori "much to learn you still have" :D
16:09 ka2u joined #mojo
16:10 gtodd my $self = shift;
16:12 inokenty joined #mojo
16:13 gtodd is that just convention? Aren't there other ways to instantiate methods? (and I guess by "method" I really just mean a subroutine)
16:14 dminus thats not to instantiate the method, thats to get the referent object
16:15 dminus you dont necessarily have to do that, unless you need to get at the object you called the method on and do stuff with it
16:15 vervain perldoc perlobj
16:15 gtodd hmm I guess a lot of my subroutines want the object that is being refered to (the self being the wole script?) to be used in the sub
16:16 gtodd hmm k
16:16 vervain before you read perlobj though I recommend that you are comfortable with perlref
16:16 gtodd my $self = shift;     is an excellent perl idiom for tshirts so I liked it  even without knowing it very well
16:16 gtodd vervain: thanks
16:17 jberger I recommend perlreftut actually
16:17 jberger http://p3rl.org/reftut
16:17 jberger its a softer (and I'm clearer) intro to references
16:18 jnbek^dt joined #mojo
16:18 gtodd my system installs everything as manual pages so I can RTFM
16:20 vervain Ah yes jberger; forgot about that one.
16:21 jberger gtodd, but its actually a good FM :-P
16:21 gtodd my desire with Mojo is to avoid using database backends and to as much as possible readin data from files .... so I can write dead simple little html5 "apps"
16:21 gtodd abd change the data in the files practically on the fly (hypnotoad is robust)
16:22 jberger ok, well using dumper and do help there
16:22 jberger but IMO (and I'm going to get flak for saying it) you might look at DBM::Deep
16:22 yakudza joined #mojo
16:23 jberger others will say its too slow, so yeah, don't build your billion-dollar site on it
16:23 sivoais joined #mojo
16:23 jberger but its not so slow that you will notice on a small to medium size webapp
16:24 gtodd Absolutely ... I use DataDumper for checks and eventually for tests  ... (I to figure out how to add it in to a sort of standard  ./t/dump_compare.t
16:24 jberger sri: thoughts on this: http://blogs.perl.org/users/ovid/2013/0​1/be-careful-with-state-variables.html
16:24 gtodd I'm trying  to figure out how to add to a sort standard test
16:24 gtodd oh wait I already typed that more or less
16:25 gtodd plus I'm using slurping ... not sure if this is a good idea or not
16:25 vervain gtodd: Are you aware of sqlite?
16:25 jberger no you can use dumper and do directly as a pair
16:25 jberger write out with print dumper
16:25 jberger then read in with do
16:26 jberger sqlite+dbix::class isn't too bad
16:26 jberger thats how Galileo is running and I haven't written a line of SQL for it
16:26 gtodd use File::Slurp
16:26 gtodd my $data read_file ('data_file') ;
16:26 gtodd ... etc.
16:26 gtodd vervain: yes
16:27 jberger what kind of structure is contained in 'data_file'
16:27 jberger ?
16:27 crab what is galileo?
16:27 gtodd I guess what I want is tiny templatish like apps that I repurpose mostly by changing data_file
16:27 jberger http://p3rl.org/do
16:27 jberger crab, my cms
16:27 jberger http://p3rl.org/Galileo
16:28 gtodd jberger: e.g. species and order
16:28 jberger as a hash?
16:29 jberger Galileo=Mojo+SQLite+DBIC+Bo​otstrap+WebSockets+PageDown
16:29 jberger so its a fully CPAN-installable CMS!
16:29 crab that is pretty cool.
16:29 jberger live in seconds, no IT professional needed
16:30 gtodd simple as in
16:30 gtodd Mustelidae:Gulo
16:30 gtodd Mustelidae:Putorius Furo
16:30 jberger gtodd, are you saving it in that form?
16:30 gtodd jberger: that sort of thing
16:30 jberger or is that form coming from somewhere else?
16:31 gtodd the are emailed uploaded etc
16:31 gtodd the data
16:31 gtodd are emailed uploaded etc.  *extremely* simple .... eventually will want to JSONify it
16:32 gtodd vervain: it's so simple I'm just thinking I can avoid *any* DB at all and stick with text
16:32 jberger JSON is good, but Dumper structures work well if the whole system is Perl
16:32 gtodd yeah
16:33 gtodd I was wondering if the data could go into _DATA_ somehow .... the templates go there ... could I include the content of data_file.txt uner _DATA_ somewhere and refer to it?
16:34 jnbek^dt joined #mojo
16:35 gtodd maybe then a Makefile could build the lite app from the data and a an "app template" ... and so some JSONification of the data before sticking under _DATA_
16:36 jberger gtodd: https://gist.github.com/4587287
16:36 gtodd I just need some kind of way of creating dead simple data structure like:
16:36 jnbek^dt joined #mojo
16:36 gtodd my $data = {
16:37 gtodd foo => 'bar',
16:37 gtodd baz => 'bat',}
16:37 gtodd and then refering to it etc etc ... (as someone pointed me at the other day)
16:38 jberger gtodd, it was me, and the gist I shared with you is meant for storing and retrieving such structures
16:39 jberger and if that structure seems at all magical, you really should read reftut
16:39 jberger it will make everything clearer
16:40 mussur joined #mojo
16:41 gtodd yeah :-)  twas you of course ...  I know that I want an array where hash values are lists so I get   Mustelidae: Gulo, Putorius Furo  ... but without having a lot of "perl" in the mojo lite app ... so it's easy to almost automatically build and then it grabs data from a file and/or _DATA_
16:41 gtodd jberger: ok thanks
16:42 jnbek^dt joined #mojo
16:42 jberger then again, if you are going to make a searchable database of "family" "genus" "species" etc you really might think about spending the time to get friendly with an ORM (object-relational mapper) like DBIx::Class
16:42 jberger you get to make "objects" representing your data, but they are stored in a database
16:43 jberger makes it very easy to say "find all the things in my database which have a family X"
16:45 gtodd it's more for just quick presentation now ... but yes eventually I will want classes to talk to postgres etc.
16:46 jberger as long as you are thinking in that direction, then there's not much wrong with what you are doing now for proof-of-concept
16:47 gtodd :)
16:47 rhaen_fork joined #mojo
16:49 gtodd we want to think of how to "normalize" sanitize the data and learn to write tests etc.  Most of what we would have under ./t/whatever.t would be tests to make sure the data was consistent ... though some of those would get run in postgresl too probably
16:49 crab i have never found a completely satisfying way to store a taxonomic tree in SQL *with revisions*
16:50 gtodd heh yeah
16:51 jberger with revisions?
16:52 gtodd sometimes species change :)
16:52 gtodd or evolve
16:53 jberger on the timescale of your webapp!?
16:53 jberger holy carp!
16:53 * jberger is a physicist, biology is scary
16:54 jberger :-P
16:54 gtodd heheh :)  somewhat OT but I was told django had some magic for schema migrations and the like but I am seeing the  Mojo::Lite  ... I like the idea of many small apps
16:54 jberger a species evolving wouldn't necessarily be a schema change
16:55 jberger just a "clone" of one of your entries with some changed fields, right?
16:55 jberger possibly with a pointer to the predecessor?
16:55 gtodd I'm thinking physics is likely involved in evolution ... probably causes it ... all that mutatng radiation from space :)
16:55 jberger indeed, but we let you guys deal with that!
16:56 jberger we actually have a really cool biophysics group down the hall from us
16:56 jberger doing conformal dynamics of DNA folding
16:56 jberger and dynamics of protein site search
16:56 jberger very cool stuff
16:57 vervain crab: Only sane trees in RDBMS I've seen involve triggers to manage the tree
16:57 sri jberger: what's so interesting about that post?
16:58 gtodd ... I'm not sure what crab means by revisions actually, but sometimes it's important to see the classification reclassification history ... and yes things change fast in the context of new information (think of the 1000s of bacteria, fungi. lichen being classfied) ... not everything is at the higher level of otters and wolverines :)
16:58 jberger sri: just that I know mojo uses state quite a bit, on multiple invocations of some class might there be some clash?
16:59 jberger I'm saying this as a fan of state, but now I remember to be more careful
16:59 gtodd apparently postgresl 9 has some interesting features that make maintainability and dynamic change etc  a bit better
16:59 sri jberger: please be more specific
16:59 sri jberger: do you have a test case?
16:59 crab jberger: species are renamed, reassigned from one genus to another, entire genera are moved to a different place in the tree, etc.
17:00 jberger storing state via 'state' in a helper or in a method
17:00 * sri doesn't follow
17:00 jberger sri, only what's mentioned in a the post
17:00 crab jberger: (all of these revisions can happen for different reasons: correcting errors, based on new information from DNA analysis, etc.)
17:00 sri jberger: what makes you think we have a problem?
17:01 jberger I don't know that we do, I just read it and remembered that its a common idiom in the codebase
17:01 crab vervain: adjacency list trees with recursive CTE queries (in postgres) make it quite nice to manage trees. i haven't needed triggers at all.
17:01 jberger we may not have any problem at all
17:02 jberger sri: I guess what I'm asking is, do all instances of a class which store their state via 'state' variables share their data
17:03 jberger or is this a quirk of using Roles as shown in the post?
17:03 sri jberger: you're welcome to investigate
17:03 jberger I may do that, I wont have time now, but perhaps later
17:04 jberger crab, in that case, a flat-file database store in version control might actually be best
17:04 crab depends best for what
17:05 jberger keeping history, but maintaining usability
17:09 vervain crab: Part of sane for me is a decent interface for application developers.  Almost non of which can be expected to deal with recursive queries. :-)
17:15 good_news_everyone joined #mojo
17:15 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/nowaLw
17:15 good_news_everyone mojo/master 8696a62 Sebastian Riedel: more helper tests with state variables
17:15 good_news_everyone left #mojo
17:16 sri jberger: perhaps that makes it more clear why we have nothing to worry about
17:16 xaka joined #mojo
17:23 sri (even in two instances of the same lite app they are different lexical scopes)
17:31 jberger sri: good to know
17:31 jberger I don't even think its the scope issue, its the copying on globref or not
17:31 jberger s/on/of/
17:35 gtodd crab: are you the developer of archiveopteryx?
17:35 gtodd or one of them?
17:35 sri jberger: it's a scope issue with roles
17:36 jberger sri: I see what you mean
17:37 jberger sri: then again, classes made of roles probably don't suffer from the fork-safety problems that are common in mojo
17:37 jberger therefore using state in Roles is a smell anyway
17:37 jberger those should be Role attributes
17:37 jberger I would think
17:37 sri what fork safety problems?
17:37 jberger designing for preforking
17:38 jberger or why using state and helpers are preferred
17:38 jberger or have I not understood anything :-P
17:38 sri ah, you mean lazy instantiation for fork safety, yea, that's correct
17:38 jberger love to talk more about design concerns later, but I'm meeting some friends for lunch
17:39 jberger sri: yep thats what I mean
17:39 jberger cheers
17:39 * sri won't be around as much in the next few weeks to talk design
17:39 sri gonna work full time on the mongodb client... so it finally gets finished
17:40 crab gtodd: yes
17:40 vervain mongodb client?
17:41 sri a non-blocking, pure perl mongodb client that's optimized for use in mojolicious
17:42 mussur joined #mojo
17:45 mattastrophe joined #mojo
17:45 crab gtodd: do you use archiveopteryx?
17:45 gtodd trying it
17:45 gtodd no longer employed where I was hoping to use it
17:45 gtodd crab: used loathsome for awhile too ;-)
17:46 vervain sri: Ah ok, so as yet not published in any form?
17:46 sri correct, i want to get it into a publishable state now
17:46 gtodd I think I am sort of gradually recreating something like loathsome using Mojo
17:46 vervain Ok... groovy, I look forward to it.  Not done much NoSQL yet outside of tinkering.
17:47 gtodd crab: archiveopteryx is still alive I take it ... do you work on it or use it for any projects?
17:49 ka2u joined #mojo
18:03 jontaylor joined #mojo
18:06 jontaylor I'm looking for advice about debugging a mojolicious application running under hypnotoad. After a certain amount of inactivity time has elapsed the app stops responding and nginx gives me a 502 Bad Gateway error. Each time I refresh (and hit a different worker process) I get Worker _pid_here_ has no heartbeat, restarting. After i've refreshed enough times to make every worker process time out the app becomes responsive again.
18:07 jontaylor I don't get this issue in development, or on our testing system, only in development
18:07 jontaylor At first I thought it might be mysql connections going over the mysql wait_timeout for the open connection
18:07 jontaylor so I added mysql_auto_reconnect to my DBI connection string
18:08 jontaylor but that had no impact, I don't get any errors coming through that something is timing out, but for a worker to have no heartbeat it must be locked up by something
18:09 jontaylor I am certain there isn't a bug in mojolicious, it must be something wrong in my application but its hard to hunt down and any debugging advice would be highly appreciated
18:12 Nom- joined #mojo
18:16 marty sri++ on the mongoDB driver.  Good luck.
18:16 marty jontaylor:  does this help...  http://mojolicio.us/perldoc/Mojolici​ous/Guides/FAQ#What_does_Worker_3184​2_has_no_heartbeat_restarting_mean
18:17 jontaylor yes marty that helped me identify that there is probably some sort of blocking operation in my app, but I can't work out what that block is
18:24 GabrielVieira Hey there, when I use hypnotoad ( listen => 'http://*:8080')it starts the service at 0.0.0.0:8080, how could I have it running at :::8080 just like apache what runs at :::80?
18:37 sri jontaylor: you should test it with the prefork server
18:37 sri ./myapp.pl prefork
18:38 jontaylor thanks sri i'll do that now
18:38 jontaylor i have two servers load balanced, so i'll do it on one of them for a comparison
18:38 sri it's the same code as hypnotoad, but keeps everything in the foreground for easier testing
18:39 sri it won't report anything different, but makes it easier to poke around
18:39 jontaylor ahh ok, so best run in a screen session then
18:40 dod joined #mojo
18:40 sri it's odd that the app won't block with the dev server
18:41 sri if anything, it's easier to block the dev server
18:41 sri it can't restart itself
18:52 rem_lex|pivo joined #mojo
19:04 yakubori joined #mojo
19:17 basic6 joined #mojo
19:30 * sri wonders what's a good fallback for pack('q<', $int) on 32bit machines
19:37 batman joined #mojo
20:06 janus depends if only local or not?
20:23 perlite_ joined #mojo
20:28 rem_lex| joined #mojo
20:32 bluescreen_ joined #mojo
20:33 tempire mon
20:33 tempire go
20:33 tempire db
20:33 tempire $set
20:33 tempire \o/
20:35 lukep joined #mojo
20:36 sri janus: local?
20:37 GabrielVieira Hey there, when I use hypnotoad ( listen => 'http://*:8080') it starts the service on 0.0.0.0:8080, how could I have it running on :::8080 just like apache what runs at :::80?
20:41 GabrielVieira Does hypnotoad just allows local connection or it is in the OS config? (firewall is disabled)
20:41 marty GabrielVieira: listen => ['http://*:8080']
20:42 GabrielVieira marty: it is *:8080
20:42 GabrielVieira with []
20:42 GabrielVieira =)
20:42 GabrielVieira sorry
20:42 marty :)
20:42 GabrielVieira it is [ 'http://*:8080' ]
20:42 GabrielVieira :)
20:43 rem_lex|pivo joined #mojo
20:43 GabrielVieira no idea why it doesnt listen
20:43 marty How are you invoking it?
20:44 marty I do this in my startup sub and it works.   $self->config(hypnotoad => {listen => ['http://*:3001']});
20:45 GabrielVieira locally I can reach the app
20:46 GabrielVieira but trying from its external ip I cant
20:46 GabrielVieira but apache I can, and I have firewall disabled
20:46 GabrielVieira netstat returns me 0.0.0.0:8080 and for apache :::80
20:46 bobkare GabrielVieira: do you have io::socket::ip installed? but it shouldn't matter if you are trying to reach it on an ipv4 address
20:47 bluescreen__ joined #mojo
20:48 GabrielVieira bobkare: installed
20:50 chromatic joined #mojo
20:51 chromatic I'm interested in having Mojolicious normalize all incoming data (Unicode::Normalize). Where's the best place to put that code?
20:54 marty chromatic.  My guess would  be around_dispatch hook.  But there might be better solutions or hooks...  http://search.cpan.org/~sri/Mojoli​cious-3.82/lib/Mojolicious.pm#hook
20:54 mussur joined #mojo
20:58 xaka joined #mojo
21:02 sri hmm, guess i'll require a 64bit perl for now
21:03 chromatic It'd be nice to handle it in Mojo::Parameters somehow, to avoid walking the parameter list multiple times, but I could put it in a helper.
21:14 sri if you can, put it in a helper
21:15 chromatic Out of curiosity, why there and not in Mojo::Message or Mojo::Parameters? Not something everyone will want?
21:17 sri you're the first in my 7 years of making web frameworks asking for that feature :)
21:17 chromatic I'm the first person to look at this client's code and say "You have a Unicode problem lurking here."
21:18 chromatic Long story short: I don't want to have to deal with bugs by saying "Sure, you think you searched for the right string, but you typed it wrong."
21:19 chromatic So I want to enforce the policy that all searchable data is in Unicode NFD and enforce that all incoming parameters are in NFD.
21:19 chromatic I like that Mojo automatically decodes parameters, even though I know enough to do that myself. It would be just that much more useful if it normalized for me too.
21:19 sri then make a plugin that deals with it in a hook
21:20 chromatic What hook would you use?
21:21 sri before_dispatch
21:21 jberger could you subclass Mojo::Message and Mojo::Parameters? or is that too far down the rabbit hole?
21:21 dminus that actually sounds like it would solve a huge headache for me chromatic, thanks in advance :D
21:21 sri jberger: what's the advantage?
21:22 jberger chromatic > "It'd be nice to handle it in Mojo::Parameters somehow, to avoid walking the parameter list multiple times, but I could put it in a helper."
21:22 sri yea, i don't understand that problem
21:22 jberger well I don't either, but then again, I think I learned what unicode is about a week ago :-P
21:23 jberger from youu
21:23 dminus <sri> unicode is hard
21:23 dminus true story :{
21:24 * jberger goes shopping
21:25 chromatic I can accept "Mojo doesn't want to enforce normalization on everyone" as a response to "Would you consider this feature?" but I figure that Mojo::Parameters and Mojo::Message are already walking over the query string and body data when decoding the data, so if I were maintaining the whole stack myself, that's where I put it.
21:25 sri filter @{$self->req->params->params} however you like, should be trivial
21:26 chromatic Alright, I'll write the hook.
21:26 sri chromatic: Mojo doesn't want to enforce normalization on everyone
21:26 jberger chromatic, sounds like a CPAN worthy plugin though
21:26 sri it does
21:27 jberger and a blog post so I can learn more about these things
21:27 jnbek joined #mojo
21:27 * jberger likes chromatic's blog quite a bit
21:28 chromatic It should be possible to do both, with a really good example that will turn your hair white.
21:28 chromatic You have to read between the lines a little bit, but: http://www.perl.com/pub/2012/05/perlu​nicookbook-unicode-normalization.html
21:29 sri personally i think i would prefer a helper though, $self->normalized_param('foo') or so
21:29 sri depending on how expensive normalization is
21:30 chromatic I thought about that, but I want the client's code to look as much like normal Mojolicious code as possible.
21:30 sri fair enough
21:31 chromatic We never don't want people to get normalized params. That's not the right answer for everyone, but it's the right answer for this code.
21:31 GabrielVieira joined #mojo
21:32 jberger This is the gist then right: "Without this normalization, you can imagine the difficulty of determining whether one string is logically equivalent to another."
21:33 jberger sounds like something I should learn
21:33 sri the fun never ends with unicode
21:34 * jberger might just stick with science
21:39 * sri would be interested in how expensive it actually is though
21:49 sri there sure is a cost, but it doesn't seem that bad
21:50 chromatic It's not too bad if you use the XS.
21:51 sri hacking NFKC() normalization into Mojo::Util::decode (which reaches all layers) changes test results from 50.95 to 51.10
21:53 sri (CPU)
21:54 sri would be hard to decide where exactly it should go if we decide to add it to core though
21:55 chromatic What does NFD do to the test results?
21:56 sri breaks 20 tests
21:58 chromatic I'll get my hat.
21:59 sri the more i think about it the more i like the idea of supporting normalization somehow in core, but doing it right will be very hard
22:05 sri rails seems to go pretty far there
22:11 sri kinda... they have String subclass that provides .normalize you can call on demand
22:11 sri *+a
22:14 rbmntjs_ what is unicode normalization ?
22:14 sri and django seems to have nothing built in
22:15 batman joined #mojo
22:15 batman joined #mojo
22:16 batman marcus: i think we have a bug in wirc... or you have been messing around with my nick in the redis database :P
22:16 sri batman: http://www.unicode.org/reports/tr15/
22:18 sri no framework seems to do it automatically
22:20 batman sri: does it have the same usage as soundex?
22:24 sri i guess you could say that
22:27 chromatic soundex?
22:27 batman ok.
22:28 batman chromatic: when you search for ó in the a string, it might match o, O, ò and friends iirc
22:29 chromatic Oh. Then no, it's not like soundex.
22:29 batman or soundex is used to "search for words that sound like this" i think
22:29 chromatic It's about finding a canonical form such that "na\x{ef}ve" and "na\x{69}\x{308}ve" are the same.
22:30 batman does it have something to do with utf8, utf16, ...?
22:30 chromatic You have multiple ways to represent the same glyphs.
22:31 batman i think you should give up explaining it to me... next questions: why? how?
22:32 chromatic \x{ef} is "LATIN LOWERCASE I WITH DIARESES"
22:32 chromatic \x{69} is "LATIN LOWERCASE I"
22:32 chromatic \x{308} is "COMBINING DIARESIS"
22:32 chromatic They both look like ï when rendered.
22:33 chromatic Because they have different underlying bytes, you can't search for one with the other and vice versa.
22:33 batman oh.
22:33 batman weird :)
22:33 chromatic That's not even the most complicated part of it.
22:33 batman but i think i get it now
22:33 chromatic The solution is "Wouldn't it be nice if we had a single, canonical representation we could use for sorting and searching?"
22:34 batman :)
22:36 mattastrophe joined #mojo
23:08 jnbek joined #mojo
23:18 Averna joined #mojo
23:41 anaio joined #mojo
23:46 jnbek joined #mojo

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