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

IRC log for #mojo, 2017-07-20

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

All times shown according to UTC.

Time Nick Message
00:50 brunoramos joined #mojo
00:57 genio Grinnz: Can you test Mojo::Reactor::UV against https://github.com/genio/p5-UV now please?
00:58 genio I still have quite a few handles to implement, but Poll and Timer seem to be working as expected.  I added a   UV::Poll->new_socket() constructor as well
00:59 genio sorry in advance. you will have to make some changes
01:28 zivester joined #mojo
02:28 ashimema joined #mojo
02:29 noganex joined #mojo
02:37 Grinnz lol, that's kind of expected
02:46 genio I guess I should get UV::TCP and UV::UDP working next
02:47 genio it takes forever to convert the tests and test equivalently and document things
02:48 genio I spend more time on those parts than on writing the code
02:53 Grinnz genio: i assume the return values of things are similar to what i got from UV.pm?
02:53 Grinnz er, from the current version that is
02:57 genio Well, you'll no longer have to whatever_init() as that's baked into the constructors which will die on error.  However the others should return proper UV_E* values like before
02:58 genio ->new() croaks.  other methods return whatever value libuv would return
02:58 Grinnz cool
03:00 Grinnz is there an equivalent to UV::last_error somewhere or should i do that differently?
03:01 genio nope.  http://docs.libuv.org/en/v1.x/migration_010_100.html#error-handling
03:01 Grinnz aha, nice
03:07 tchaves joined #mojo
03:10 Grinnz well good news is the timers work fine
03:10 Grinnz bad news is the handle tests fail and then segfault
03:11 genio o.O
03:11 Grinnz https://github.com/Grinnz/Mojo-Reactor-UV/tree/uv_1
03:13 Grinnz https://perlbot.pl/p/wkzqlj
03:15 Grinnz looks like it never gets marked readable or writable
03:16 Grinnz it's testing with an IO::Socket::INET server and client btw
03:20 Grinnz actually the segfault appears to happen when a recurring timer is set
03:25 genio hrm. I'll go through it tomorrow.
03:26 genio I'm too tired to think straight tonight
03:26 Grinnz i also forgot there's a debug flag
03:26 Grinnz https://perlbot.pl/p/twz5pn
03:30 Grinnz so it isn't when the recurring timer is added but whatever happens after that
04:14 schelcj joined #mojo
06:02 karjala_ joined #mojo
06:22 skycarl joined #mojo
06:24 skycarl joined #mojo
06:29 prajith joined #mojo
06:31 dod joined #mojo
06:32 inokenty-w joined #mojo
06:38 dod joined #mojo
06:46 AndrewIsh joined #mojo
07:14 Armen joined #mojo
07:19 Vandal joined #mojo
07:23 bwf joined #mojo
07:24 trone joined #mojo
07:27 bwf joined #mojo
07:55 foursixnine joined #mojo
07:59 CandyAngel Oh yeah, I'd just like to point out that Minion "is eventually consistent" but the million-pound system we use at work for essentially the same thing (but with human workers) is not
08:01 dod joined #mojo
08:05 pink_mist Minions also don't tend to get paid, so unsure how legal that would be for human workers :P
08:12 CandyAngel Unpaid internships are a thing
08:21 pink_mist oh yeah, I've heard of those kinds of things
08:38 rshadow joined #mojo
08:44 rshadow joined #mojo
08:47 prg joined #mojo
08:54 rshadow joined #mojo
09:08 rshadow joined #mojo
09:16 kes joined #mojo
09:25 foursixnine joined #mojo
09:26 foursixnine joined #mojo
09:32 stryx` joined #mojo
10:03 stryx` joined #mojo
10:03 stryx` joined #mojo
11:00 yukikimoto joined #mojo
11:11 tchaves joined #mojo
11:49 noganex_ joined #mojo
12:44 gizmomathboy joined #mojo
13:03 jabberwok hmm. would a race condition in Minion, be called "Banana" ?
13:15 Pyritic joined #mojo
13:21 CandyAngel No, but it would be despicable
13:34 gryphon joined #mojo
13:53 mudler joined #mojo
13:56 sri mudler: o/
14:05 mudler sri: \o :)
14:28 dod1 joined #mojo
14:39 marty joined #mojo
14:44 Grinnz sri: updated Mojo::SQLite and the minion backend
14:44 sri yay
14:45 sri btw. i think max_connections(1) should be the default after testing it a bit at work
14:46 Grinnz for Mojo::SQLite there is no reason to use anything else, definitely
14:46 sri it's easy to overlook places where you accidentally create a second connection
14:47 PryMar56 joined #mojo
15:14 genio Grinnz: I'm looking through your test and the callback here doesn't seem to get fired at all.  Trying to figure out why https://github.com/Grinnz/Mojo-Reactor-UV/blob/master/t/reactor_uv.t#L31
15:17 genio gah. meant to link to the other branch, but same code
15:19 genio https://github.com/Grinnz/Mojo-Reactor-UV/blob/uv_1/lib/Mojo/Reactor/UV.pm#L109 should have the invocant as the first arg. let me try to fix that
15:20 genio yea,   my ($h, $status, $events) = @_;    gets the other CB in the test to fire properly.
15:21 genio doesn't fix things completely
15:22 genio That's another change in 1.000.  All callbacks for all handles/loop events will have the invocant as the first parameter.
15:22 Grinnz ahh
15:23 sri hmm, looks like there is nothing left for me to do, that's how i like it :)
15:24 sri do wonder what the EV/UV detection logic should be though
15:25 sri we'll support both for some time
15:25 genio UV apparently needs a lot more ironing out :)
15:25 genio my attempt at a Perl implementation, that is
15:29 dod joined #mojo
15:29 bianca joined #mojo
15:30 bianca joined #mojo
15:33 karjala_ Who's DBOOK here?
15:33 karjala_ what's his nickname, I mean?
15:33 haarg Grinnz
15:35 karjala_ Grinnz, if I open a connection with my $db = Mojo::SQLite->new(...)->db, and fork the process 10 times, can the 10 children continue to write safely on the same file from the $db object with correct locks and without conflicts?
15:36 Grinnz no, $db handles can't be used in a different process from where they were created
15:36 karjala_ ok thanks
15:36 Grinnz the Mojo::SQLite object should be shared instead
15:36 karjala_ ok!
15:36 karjala_ That's the same with all databases, right?
15:36 Grinnz yes
15:38 karjala_ So a minion job (the subroutine) should create a $db object inside it, correct?
15:38 karjala_ Probably
15:38 karjala_ Because jobs are executed in forks, I think?
15:38 karjala_ forked processes I mean
15:39 Grinnz yes
15:39 Grinnz db objects should be created in as small a scope as they are needed
15:39 karjala_ k thanks
15:39 karjala_ are they pooled and recycled whenever possible?
15:40 Grinnz up to max_connections at a time
15:40 Grinnz which defaults to 1, usually all you need
15:41 karjala_ So if I do: my @s = ($sql->db, $sql->db), how many unique elements does this array have?
15:41 Grinnz those are two connections, since the first one is still referenced
15:43 karjala_ could you please give me an example where if max_connections was set to 2, things would be different than if it were set to 1?
15:43 karjala_ (I'm slightly confused)
15:43 Grinnz my $db = $sql->db; undef $db; $db = $sql->db;
15:43 Grinnz actually it makes no difference in SQLite
15:44 Grinnz after my @s = ($sql->db, $sql->db); if you empty @s, then both will be cached if max_connections is 2
15:44 Grinnz but without async queries, it is of no practical significance
15:45 karjala_ ok, i'm curious to understand because it applies on other dbs also
15:45 karjala_ i see now
15:46 karjala_ so the option could be named max_cached_connections
15:46 karjala_ ok
15:47 karjala_ Thanks!
15:58 PopeF joined #mojo
16:15 dod joined #mojo
16:21 kaare_ joined #mojo
16:22 pink_mist joined #mojo
16:23 tyldis joined #mojo
16:23 kes joined #mojo
16:37 * sri is getting annoyed with the vscode perltidy extension
16:37 arcanez is this the first negative you've found?
16:38 sri think so
16:38 sri no wait, the perl intellisense extension is also bad
16:39 sri if someone put a little work into a good perl intellisense extension vscode could be pretty awesome for perl
16:41 sri this one goes in the right direction, but the code just so sloppy and full of bugs https://marketplace.visualstudio.com/items?itemName=henriiik.vscode-perl
16:43 sri but that's just the very advanced features of vscode
16:43 sri basics are really good, and i like it a lot as an editor
16:44 arcanez I don't work locally enough *sigh*
16:46 sri for bigger projects i use rsync for local editing
16:47 sri keybinds to sync the whole project in both directions, and an on save trigger to sync the saved file
16:48 sri been thinking about building a little tool with fswatch and rsync to keep a folder synced between two machines automatically
16:54 Grinnz i use sshfs for that
16:54 sri too slow
16:56 sri with rsync i just don't care, i sync the whole git repo
16:56 arcanez anyone have thoughts on a tsdb? influxdb, opentsdb? es?
16:56 sri only take milliseconds anyway
16:57 Grinnz its slow but it works well enough that i barely notice its there
16:57 sri arcanez: there's some new postgres time series extension getting hype atm
16:58 arcanez I have a feeling anything is better than rrd at this point, in terms of storage. visualizing though..
16:58 sri was it this? https://www.timescale.com/
16:58 arcanez kibana works well with es.. not a huge fan of grafana
17:01 arcanez sri: looks interesting, thanks. I like pg
17:02 bianca joined #mojo
17:10 dod joined #mojo
17:10 Pyritic joined #mojo
17:14 genio sshfs can be frustrating at times with the slowness
17:29 wouter does mojolicious have some slugify method?
17:30 wouter (that is, take user input with potentially dangerous metacharacters and turn it into something that can safely be used as part of a URL)
17:36 rshadow joined #mojo
17:38 genio I'm not sure what you're after and that sounds... eww.  but, https://metacpan.org/pod/MIME::Base64#decode_base64url(-$str-)
17:38 genio err. meant to link encode... takes you to the same place though
17:38 marty wouter:  Not exactly sure what you are looking for but this may help.  http://mojolicious.org/perldoc/Mojo/Util   (look for url_escape)
17:39 arcanez isn't a slug generally somewhat human readable?
17:39 Grinnz yes that's the usual intent
17:40 Grinnz and seo
17:40 arcanez makes me think of django
17:40 sirhalos joined #mojo
17:40 trone joined #mojo
17:41 Grinnz if you're using a proper url module to construct your url, there are no dangerous meta characters
17:41 sirhalos Is it possible to have a stash in a form_for in a html.ep?
17:41 sirhalos Example: $systemBovid->post(':id/upload')->to('#upload'); and I want to use id in my html.ep post
17:43 Grinnz it's not always a good idea to use user input directly without your controller doing some parsing but $c->param('id')
17:43 Grinnz works the same as in a controller method
17:44 dod joined #mojo
17:44 sirhalos I have $systemBovid->get('/:id/upload')->to('#upload'); and $systemBovid->post('/:id/upload')->to('#upload'); The get works fine, but the post doesn't, if I remove :id then both work fine, but of course I lose id
17:45 sirhalos https://pastebin.com/BTsTKbT7
17:46 sirhalos This is my controller sub it should make more sense
17:48 sirhalos The problem is within my html.ep I can't do something like <%= form_for '/:id/upload' => ( method => 'post', enctype => 'multipart/form-data') => begin %>
17:49 sirhalos and I don't know how to send it any other way than straight form_for upload, but then I need to remove :id and I don't know what is being uploaded
18:01 sri use the name of the route in the form_for
18:02 Grinnz oh, yes what sri said
18:02 sri name => {id => 123}...
18:02 Grinnz and you can assign a name to the route if the autogen one isnt useful
18:05 sirhalos the autocreated one showing on the page not found is idupload for both post and get, using ipupload for form_for still doesn't work
18:10 wouter marty: no, that's not really what I need
18:10 wouter marty: the result should be letters, numbers, and -
18:10 wouter spaces should be turned into -, metacharacters too, etc
18:10 wouter and it should be cut short if it's getting too long
18:11 wouter most other modern web frameworks have that
18:11 Grinnz wouter: https://metacpan.org/pod/Text::Slugify is a naive implementation
18:12 wouter Grinnz: thanks
18:12 arcanez https://docs.djangoproject.com/en/1.11/_modules/django/utils/text/#slugify is what django does
18:12 wouter unfortunately it's not packaged, but hey
18:12 wouter arcanez: right :-)
18:12 wouter ("packaged", as in, "packaged for Debian")
18:12 Grinnz wouter: https://metacpan.org/pod/Text::Unidecode can be used beforehand so high-bit characters are translated instead of replaced
18:12 sri wouter: you're the first to ever ask for it
18:13 wouter sri: possibly :)
18:13 sri no, definitely, i've been here from the start :p
18:14 Grinnz wouter: i can write a perl implementation of that django function if you like, it would be rather simple
18:15 Grinnz unforunately using some modules that would make it annoying to put in mojo core
18:15 wouter Grinnz: well, I can too, if needed, but I wanted to ask if it exists first :-)
18:15 wouter sri: heh, okay :)
18:16 wouter sri: the idea is that a "slug" is used as part of the URL, but contains the title (or something that looks like the title) in it
18:16 wouter and it can also be used as a filename
18:16 wouter (or part of it)
18:16 wouter without much problems
18:22 arcanez seems like a nice helper
18:25 sri most frameworks also have this helper, but we never got the votes to have it in core https://github.com/kraih/mojo/compare/time_in_words
18:26 sri tough to get votes for helpers with more of a frontend focus
18:28 Grinnz wouter: https://perlbot.pl/p/mumnzb
18:28 Grinnz oops, return $value at the end :)
18:29 Grinnz https://perlbot.pl/p/e7egm2
18:29 sirhalos okay the one thing I noticed is that the post works using form_for idupload but I noticed that $self->req->upload('pdf') no longer works checking $self->req->upload I notice it isn't there, but now I can do $self->req->uploads
18:30 Grinnz Unicode::Normalize is actually core in 5.8+, so it's possible to put a function like this in core
18:30 Grinnz i don't know if in perl you'd want the same semantics though
18:30 wouter Grinnz: the exact semantics are usually not that important
18:31 wouter what you really want is a URL that resembles the title in ways that a user will say "ah, yes, that makes sense"
18:31 Grinnz the /u and /a flags i used there are 5.14+ only though
18:32 wouter Grinnz: well, who's really using a perl older than 5.14 today anymore?
18:32 Grinnz mojo still supports back to 5.10
18:32 Grinnz at least, supports running on it
18:32 wouter well, yeah
18:32 Grinnz but those flags aren't really needed anyway
18:33 Grinnz just the ascii regex would have to be more explicit
18:34 sri Grinnz: well, put it up for a vote
18:35 sri Mojo::Util::trim would make it shorter
18:35 Grinnz yeah and some lines could be combined, i was just making a mostly direct translation
18:36 sirhalos Okay I got it to work now the only problem I have is my $mime = $self->req->headers->content_type(); no longer can see the mime of the file correctly
18:36 sirhalos It now says multipart/form-data; boundary=----WebKitFormBoundarykvArWT3WDvKputWw
18:37 sirhalos it should be saying 'application/pdf'
18:38 Pyritic joined #mojo
18:40 arcanez wouter: shh, or you'll summon ribasushi
18:44 sirhalos Okay I see the correct content_type in content->parts->headers->content-type how do I get at that correctly. $self->parts->headers->content_type() doesn't work.
18:45 jberger I like the image of standing in a dark room in front of a mirror and whispering "I'm dropping Perl 5.6 support" three times and having ribasushi appear behind you :-P
18:46 jberger all in good fun of course
18:47 ribasushi it doesn't have to be dark, and you won't make it to 3 times anyway
18:47 * ribasushi knows a guy who knows a very effective guy...
18:48 jberger hahahaha
18:48 purl LOLCON 4 reached.
19:07 Pyritic joined #mojo
19:10 marty joined #mojo
19:15 sirhalos left #mojo
19:34 Grinnz sri: which of these looks preferable for expanding the ascii version of [^\w\s-]? https://perlbot.pl/p/3haw1h
19:35 Grinnz oops, PosixWord didn't exist until 5.14 so i guess that part's settled at least
19:35 genio I don't know that there's a need to expand \s, is there?  I understand \w, but \s?
19:35 Grinnz there's plenty of unicode space characters
19:36 Grinnz so the question is \p{PosixSpace} or \t\n\x0B\f\r
19:37 Grinnz both work on 5.10
19:44 Grinnz in my mind PosixSpace is clearer, but the other one is probably more familiar, so i'm undecided
20:00 sri Grinnz: dunno
20:02 sri wouter: are you a django user?
20:03 sri i'm quite curious what a django user would miss in mojolicious
20:03 sri if you come across more things please mention it here
20:05 vicash joined #mojo
20:10 Grinnz https://github.com/kraih/mojo/pull/1108
20:12 arcanez is there something like djangos admin?
20:13 sri no, we don't even ship a model layer
20:15 sri Grinnz: Mojo::ByteStream::slugify
20:15 Grinnz right
20:15 arcanez I like (liked?) the django models.. I bet it could be done with sugar around DBIC or whatever
20:16 sri <%= b('lalala')->slugify %>
20:16 marty joined #mojo
20:17 arcanez Grinnz: did you steal djangos tests too?
20:17 preaction a basic database content management thing might be interesting with jberger's model thing...
20:17 Grinnz yep
20:17 Grinnz their test inputs/outputs at least :P
20:17 arcanez :)
20:18 jberger I know sri isn't sold on my model thing
20:19 arcanez I messed with django when it was < 1 (probably couldn't pluralize ocotopus then), but it was enjoyable and quick. but then I hit the wall and it was hard to get outside their box
20:19 jberger and even for me, its just the CPANification of the pattern I hate the least for it
20:19 preaction sure, but imho mojolicious shouldn't come with something like this anyway. people rebel enough at what's already in there :p
20:20 jberger wait, maybe I misunderstand your point
20:21 Grinnz sri: added
20:21 preaction jberger: making some kind of layer on top of mojolicious that adds some very basic content management like django
20:22 sri Grinnz++
20:23 arcanez preaction: you think that should be a plugin? (I'd agree)
20:23 preaction plugin would work, yes
20:23 sri well, the implementation of slugify looks reasonable, it gets my ok if the community wants it
20:23 sri so, everyone vote on https://github.com/kraih/mojo/pull/1108
20:26 sri or argue for it here with use cases
20:26 rshadow joined #mojo
20:28 arcanez ++
20:28 sri not here *cough*
20:28 arcanez I +1'd on gh
20:28 sri ah, carry on then
20:32 preaction https://metacpan.org/pod/Mojolicious::Plugin::Tables <- this looks like something that's kind of started, but it uses DBIx::Class in a weird way
20:33 Grinnz added some examples in the pod like other functions have
20:34 sri Grinnz: results are quoted for the others though
20:34 Grinnz fixed
20:34 sri and "my $slug = slugify $string, $bool;" might be more consistent with the rest too
20:35 Grinnz k
20:35 sri the comment is interesting, but not something we've done before
20:36 sri inline comments in the code use 3 spaces
20:36 sri (i might remove the comment anyway though)
20:37 Grinnz i removed it if you mean the one in the docs
20:37 sri not sure if we want to pick it up as a convention... it's interesting but needs more discussion imo
20:37 sri ye
20:38 Grinnz the examples make the usage clear i think
20:38 sri yes
20:55 CandyAngel A friend of mine would use it for suggesting slugs for a literature site they are making soon
20:57 CandyAngel Though they were intending on underscore, rather than dash, in their examples?
20:57 Grinnz it would be pretty easy to s/-/_/g after slugify
20:59 Grinnz well s/[-_]+/_/g would be better in case the source had underscores
20:59 brunoramos joined #mojo
21:00 * CandyAngel nods
21:04 karjala_ joined #mojo
21:05 sri CandyAngel: VOTE!
21:06 sri we might need those "i voted" stickers
21:07 Grinnz http://news.hiphopearly.com/wp-content/uploads/2015/10/Vote-or-Die-puff-daddy.png
21:07 * jberger creates a black market for "I voted" stickers
21:07 Grinnz nobody liked either candidate enough to bring back Vote or Die for the past election I guess :P
21:08 preaction it was "vote and die" apparently
21:08 sri was about to say
21:16 CandyAngel https://i.imgflip.com/1sthnn.jpg
21:16 CandyAngel :P
21:17 Grinnz by the way jberger will be happy i didn't use the django example text, "Joel is a slug"
21:18 sri https://img.memecdn.com/cookie-monster-and-his-computer_o_1147388.jpg
21:18 * sri actually googled for monster memes and that one seemed kinda on topic :P
21:40 sri Grinnz: https://github.com/kraih/mojo/pull/1108/files#r128637708
21:40 Grinnz ????
21:42 jberger so this would be a breaking change, but I have another possible use-case for slugify
21:42 Grinnz btw this is a really nice read about how the Unicode normalization stuff is working https://en.wikipedia.org/wiki/Unicode_equivalence
21:42 jberger route name generation
21:43 Grinnz jberger: a separating slash wouldn't be turned into a space so it probably wouldn't work out nicely
21:43 jberger oh, I thought it would
21:44 jberger nm then
21:44 Grinnz its really meant for phrases with spaces
21:44 jberger sure
21:44 jberger I get its purpose
21:44 jberger I was just looking at the output of routes and it struck me
21:44 jberger but you don't actually want the generated routes to be friendly, you should name them if you want that
21:44 sri would be a nice use case
21:45 sri tricky breaking change though
21:48 jberger that's the other thing
21:49 jberger and since it only would encourage people to use the default generated route name (which isn't really encouraged anyway) then I don't think it is a good idea overall
21:51 Grinnz https://github.com/kraih/mojo/pull/1108/files#diff-f794a3437aab8543fdc53904e356a38fR741
22:01 jberger interestingly, "Joel is a slug" is also the demo case for django's strip_tags
22:04 jberger what did their Joel do to them?!
22:06 Grinnz maybe they have a pet slug named Joel
22:08 jberger well argued
23:11 HtbaaPi joined #mojo
23:19 arcanez https://code.djangoproject.com/ticket/6351
23:19 arcanez wonder if that guy added it
23:19 itaipu joined #mojo
23:20 arcanez s/guy/person/

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