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

IRC log for #mojo, 2017-02-11

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

All times shown according to UTC.

Time Nick Message
00:00 pink_mist if you say restarting morbo doesn't work, you cannot have saved
00:00 mrEriksson I have
00:00 pink_mist then restarting morbo would without a doubt have worked
00:00 mrEriksson The blue "unsaved" marker even goes away
00:00 pink_mist morbo doesn't save state between restarts
00:01 mrEriksson I'm aware of that
00:01 pink_mist it reads the file from disk
00:01 pink_mist so if the updates were actually saved to disk, that would definitely get theupdates
00:01 pink_mist *the updates
00:01 mrEriksson Agreed
00:01 mrEriksson But it doesn't
00:02 pink_mist only way that's possible is if you didn't save to disk
00:02 mrEriksson Well, if I saved it to disk and it is still happening, I guess the inpossible is happening
00:02 pink_mist cat the file to make sure
00:03 pink_mist or md5sum it
00:03 mrEriksson I've actually comitted it to vc at one time
00:03 pink_mist then perhaps you didn't actually restart morbo
00:04 mrEriksson Before I figured out that it was Atom-related, I thought I had broken my dev environment somehow
00:04 pink_mist (although that shouldn't be needed anyway)
00:04 mrEriksson Well, as you say, shouldn't be needed, but I can guarantee that I did
00:06 pink_mist please confirm by md5summing, and also restarting morbo
00:06 sri it's not atom, my atom works perfectly
00:06 pink_mist as in, md5sum the file, edit it, md5sum the file again and compare
00:07 mrEriksson So I've just added a console.log() to the end of my js
00:07 mrEriksson cat shows its presence
00:07 mrEriksson Will now reload in firefox
00:07 sri umm, browsers cache
00:07 pink_mist oh, you're using firefox ... are you sure that's not cache?
00:09 mrEriksson Well, I've been down that road before, but clearing cache does nothing. Also, that doesn't explan why I don't see this with vim
00:11 mrEriksson Doesn't seem to require full Atom shutdown
00:11 mrEriksson Just closing the tab that the file is open in makes it reload too
00:13 mrEriksson Going back to vim works just fine. I need to give this a try on another workstation I think.
00:15 mrEriksson Thanks guys for providing some input
01:02 aborazmeh joined #mojo
01:10 kiwiroy joined #mojo
02:08 kiwiroy joined #mojo
03:08 kiwiroy joined #mojo
03:41 noganex_ joined #mojo
03:42 kiwiroy joined #mojo
04:05 asarch joined #mojo
05:04 dboehmer_ joined #mojo
06:52 aborazmeh joined #mojo
07:31 Vandal joined #mojo
07:38 litwol hmm.
07:38 litwol So i'm back to forms again. (or rather, the issues i've been having with them).
07:39 litwol I'ver registered a route to which i submit certain form. next, my form has validation and user is most likely to triggerit at first.
07:39 litwol this places me in situation where user starts from homepage, submits unsuccessflly the form first time. ends up on a new route to where form submits...
07:40 litwol on that new route i validate the form..
07:40 litwol so far so good. but the problem part is now.. i am on *new page*. not the page where form was originally displayed.
07:41 litwol is it possible to preserve form validation while keeping user on original page  where form was submitted instead of redirecting user to form action route ?
08:08 coolo how would I access one model class from another in Mojo::Pg?
08:24 kiwiroy joined #mojo
08:31 * coolo now added the app to the model, but it feels dirty
08:43 sugar joined #mojo
09:20 sh14 joined #mojo
09:23 VVelox joined #mojo
09:46 irqq joined #mojo
09:55 sugar joined #mojo
10:25 rshadow joined #mojo
11:17 sugar joined #mojo
11:29 dod joined #mojo
11:33 dod joined #mojo
11:40 kes joined #mojo
11:42 FROGGS joined #mojo
11:42 FROGGS hi folks
11:44 FROGGS I'm going nuts... I've got an app foo that I run as "morbo foo" and "foo prefook"
11:44 FROGGS but how do I run that with hypnotoad?
11:44 pink_mist hypnotoad foo
11:45 FROGGS right, and how do I pass the "listen" configuration to it?
11:45 pink_mist I tend to have that as part of the config
11:46 FROGGS I've got a foo.json, that I load in lib/Foo.pm->startup, but that seems to late...
11:46 pink_mist hypnotoad => { listen => ['http://*:3000'] }
11:46 pink_mist oh, json, then that, but in json format
11:46 FROGGS yeah, but it does ignore  a foo.json it seems
11:47 pink_mist it's up to your app to load it
11:47 FROGGS yes, I do that in the startup method
11:47 FROGGS but it does not have an effect
11:47 pink_mist it does for me
11:48 FROGGS :S
11:48 FROGGS ohh wait
11:49 pink_mist only I use regular config plugin, not json config plugin
11:49 FROGGS \o/
11:50 FROGGS works now... my config handlig module that loads the json knows about environments and namespaces, and I ignored that fact and put the hypnotoad section in the wrong spot -.-
11:50 FROGGS pink_mist: thank you
11:50 pink_mist np
11:56 FROGGS hmmmm, where does it write the logfiles to?
12:01 pink_mist usually if you create a log directory, it'll create a log file in there
12:06 FROGGS ohh, awesome
12:07 FROGGS and so it does.... much awesome
12:09 kiwiroy joined #mojo
12:19 sri coolo: don't pass the app instance to the model, just pass the results from one model class to the other, or organize your models in a way that both methods are in the same class
12:20 sri if you want to reuse a block of code using multiple models, just make a helper
12:21 sri s/model class/model method/
12:22 cpan_mojo Mojo-IRC-Server-Chinese-1.7.9 by SJDY https://metacpan.org/release/SJDY/Mojo-IRC-Server-Chinese-1.7.9
12:23 sri if it's about data collection, don't be afraid to just join tables in one of the model classes
12:23 sri Mojo::Pg is about finding efficient queries first
12:23 sri and orgnaizing them into a set of model classes second
12:25 sri it should be rather rare that you need to combine queries, there's usually clever ways to make one bigger, much more efficient query
12:28 * sri will make a big change in Mojo::Pg today
12:35 px80 in my first code beginning of the week when my useragent gets weren't nonblocking I just reused $ua for subsequent queries to the same url/server. That way I could make use of the automagically attached cookie-session
12:35 px80 now with non-blocking I can't reuse it that way anymore
12:35 px80 any hints how you would do this?
12:36 px80 I have many GET to different URLs and servers, and with each subsequent query to the same server I need to have the appropriate cookie
12:37 px80 is it wise to attach the cookie in some data structure and then make a next step which uses the appropriate cookie for the next circulation of queries?
12:38 px80 (I'am sorry for not having more advanced question :-( )
12:45 sri i'm adding SQL::Abstract to Mojo::Pg
12:54 coolo sri: my use case is not a select but an import. but reviewing it from what you said, I guess I put the function calling into the wrong model
12:56 sri :)
12:58 sri just rename the model class if the name doesn't fit anymore, they don't have to correspond with class names at all
12:59 sri like, if you do authentication with a users and a roles table, feel free to name it MyApp::Model::Authentication
13:00 sri and then make the most efficient queries you can for the task at hand in that class
13:00 sri it's a bit different than DBIx::Class that way
13:02 sri (of course that's only how i recommend it to do)
13:03 sri ribasushi: what's the maintenance status of SQL::Abstract btw. recommended to use in new code?
13:08 kiwiroy joined #mojo
13:10 dod joined #mojo
13:13 px80 1
13:19 sri this is what the tests will look like https://gist.github.com/anonymous/1fcd02dc6945936fdb98ba05b6c6c1f5
13:21 sri so basic CRUD will get a bit easier
13:21 sri and Mojo::Pg becomes a better choice for quick prototyping
13:22 sri also for selects it will get a little less painful to have very dynamic where clauses
13:23 sri (if your query is otherwise simple)
13:23 sri or you just ignore those 4 new methods and keep using ->query() as before :)
13:23 batman sri: that looks very nice :)
13:25 batman will SQL::Abstract be held in an attribute so it can be modified or replaced?
13:25 sri yes, Mojo::Pg::abstract
13:26 batman cool
13:47 px80 got it!
13:47 px80 slowly I learn this stuff
13:49 * px80 freetime hobby programmer
13:50 sri and added https://github.com/kraih/mojo-pg/commit/f44ea4b161906b0e4539b938fb884d9ee4adea9d
13:51 sri Grinnz: should be very easy to add to Mojo::SQLite if you want to join in
13:59 batman interesting that you add SQL::Abstract as a hard dependency. It makes sense though.
14:01 sri yea, i wasn't entirely sure about it, but SQL::Abstract doesn't really pull in many dependencies
14:02 sri having DBD::Pg as a dependency already makes it not a very hard decision
14:03 good_news_everyon joined #mojo
14:03 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vDVx5
14:03 good_news_everyon mojo/master e1446f0 Sebastian Riedel: keep the @_ handling on one line
14:03 good_news_everyon left #mojo
14:05 batman do you need lc() here? https://github.com/kraih/mojo/commit/e1446f0fff3cad136f3245ef47a2f261018d090b#diff-955b07afef3c0b8632a50118b370262cR33
14:08 kiwiroy joined #mojo
14:27 mattp sri: might be worth adding DBI_TRACE=SQL to the DBI_TRACE=1 bit
14:34 stryx` joined #mojo
14:38 dod joined #mojo
14:40 sri mattp: good idea
14:43 mattp i only found about that a few weeks ago after years of perl
14:47 mattp also, I was asking for a way to limit the ammount of connections made to postgres with async mode for a connection pool
14:47 mattp turns out theres a thing called pgbouncer that does this elegantly and transparently
14:49 sri i think there are plans to have that natively in postgres
14:50 sugar joined #mojo
15:06 sri the blog example does get a bit nicer with the CRUD methods :) https://github.com/kraih/mojo-pg/commit/0111533853513d77b248d0e7df8f8c74f7caa327
15:07 sri https://github.com/kraih/mojo-pg/blob/master/examples/blog/lib/Blog/Model/Posts.pm
15:08 kiwiroy joined #mojo
15:12 sri i've been optimizing Mojo::Pg so much for Minion that i forgot a bit just how much CRUD there is in most apps
15:13 cpan_mojo Mojo-IRC-Server-Chinese-1.8.0 by SJDY https://metacpan.org/release/SJDY/Mojo-IRC-Server-Chinese-1.8.0
15:14 jberger Indeed
15:14 * sri needs to be a little more pragmatic again
15:19 sri coolo: think that will make Mojo::Pg a little more pleasant to use for you too :)
15:21 sh14 joined #mojo
15:22 jberger I think it has been interesting watching you become more pragmatic since starting your job
15:22 sri having to explain stuff at work to others certainly made me rethink a lot
15:23 sri (especially when multiple people ask the same question ;p)
15:26 coolo sri: good that you enjoy your weekend :)
15:26 * coolo has to relearn abalone tactics :)
15:29 sri never tried abalone but started playing blokus recently
15:38 * coolo is no longer in a position to pick the board games :)
15:47 px80 sri, is it enough to instantiate $delay->begin once and use it for all callbacks inside a step?
15:51 jberger no, each call to begin increments a counter
15:51 jberger and each callback is bound to that increment
15:59 sugar joined #mojo
16:08 kiwiroy joined #mojo
16:34 ma112 joined #mojo
16:35 ma112 How can I use plugin 'config' inside a module?
16:35 ma112 https://nopaste.linux-dev.org/?1120879
16:35 ma112 this won't work
16:37 dod joined #mojo
16:40 jberger ma112: you are mixing lite and full syntaxes
16:40 jberger in a plugin you have to use the OO (full) style
16:41 jberger so in your register method, do $app->plugin(...);
16:41 ma112 ok, thanks
16:41 px80 ah ok thanks
16:42 jberger the lite-style keywords only work in a single file app
16:42 jberger px80: np
16:42 ma112 but it won't be a problem when i include it in Mojolicious::Lite, right?
16:42 jberger nope
16:42 jberger Lite is just sugar
16:43 jberger people overthink the differences between lite and full until they see that Mojolicious/Lite.pm is like ~50 lines
16:43 jberger https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Lite.pm
16:43 jberger basically lite keywords are just shortcuts to OO methods
16:44 jberger the one exception is "group" which has no direct translation to full, but it doesn't need one
16:44 px80 the thing is that something like this: 'for (@urls) { $ua...($url => sub { $delay->begin } ); }' doesnt work, as $delay->begin must be used before the callback is run (to increment the counter)
16:44 ma112 ok, because i love the Lite (and also my apps have only around 300 lines of codes)
16:44 jberger px80, don't wrap the call in sub { ... }, it returns a subref
16:44 jberger $ua->...($url => $delay->begin)
16:45 px80 I need to put the data from $ua inside some data hash
16:45 jberger that's what the next step is for
16:46 px80 but what if I have 1000 GETs in that loop, I need to do another 1000 with the same unique $ua per URL and its returned data?
16:46 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Non-blocking
16:47 px80 I read that 10 times :D
16:47 jberger in the second step, the arguments passed are the delay and the results of the nb actions in the order that begin was called
16:48 px80 I dont know which order as this is running through an unorderer hash or array
16:48 jberger sub { my ($delay, $tx1, $tx2, $tx3, ..., $tx1000) = @_; }
16:48 px80 and I also need the $ua per URL, so that i can use the same per URL in the next step, because each one has different cookie
16:48 lluad joined #mojo
16:49 jberger ok, then go back to what you were doing before
16:49 jberger do: my $end = $delay->begin; $ua...($url, sub { ....; $end->());
16:49 px80 the next step is for the next round of requests, each request needs the cookie from the the session before
16:49 px80 hmm
16:49 px80 ok
16:50 jberger so, in your case, each of these 1000 req is the first in a chain of multiple requests?
16:51 px80 its about different servers, where each server requires login, subsequent requests do only work with the cookie
16:51 jberger so its different servers, but the cookies interfere?
16:52 px80 this works great with the useragent
16:52 px80 its automagically done by just using the $ua object
16:52 jberger I know
16:52 px80 but of course each server and subsequent requests need a unique one
16:52 pink_mist why?
16:52 pink_mist what do you mean "of course"?
16:52 px80 because the session is not synched between the server, so each server uses different cookie
16:53 pink_mist a single $ua can have any number of cookies
16:53 jberger px80, the useragent can have multiple cookies
16:53 jberger it only is a problem if the cookies are for the same domain
16:53 px80 but then I still need to do the magic in the callback in the first step somehow
16:53 pink_mist cookies are keyed by host and optionally path
16:53 px80 hmmm
16:53 px80 that sounds pretty neat
16:54 jberger same as your browser
16:54 px80 so I dont need to care about that?
16:54 pink_mist that's what I've been trying to get through to you
16:54 px80 then I dont need a separate structure to hold this data to the next step
16:54 px80 cooool
16:54 jberger like we said, not unless you are trying to login to the same service as multiple accounts
16:54 px80 currently not happening
16:55 px80 I thought I must build some hash
16:55 px80 i love mojo :)
16:55 px80 but that doesnt count much, as I'am novice
16:55 jberger if you have a chain of requests that needs to be made, first a login, the one or more requests to that resouce, I usually split that into a single non-blocking function
16:55 px80 hoppy scripter thats it
16:56 jberger that function makes its own delay and manages that one chain of requests
16:56 jberger then in an outer delay (yes they can be nested) you kick off all the chains
16:56 jberger (or some of them, in batches, if necessary)
16:57 px80 I tried that and then recognized that these nested callbacks trigger in me some blackouts
16:57 px80 I didn't understood anymore which $delay->begin now triggers which event loop
16:57 px80 so it was like 5 nested callbacks
16:57 px80 I mean that way the design would be faster
16:58 px80 as I wouldn't need to wait for all things in step 1 to start step 2
16:58 px80 not sure if I can handle this complexity
17:00 px80 I'll continue to experiment
17:00 px80 thanks for help
17:06 jberger the whole point of abstracting the individual chains of calls into another function is that it keeps the complexity isolated
17:06 jberger let it percolate through your brain for a bit
17:06 jberger this is the hard part of grokking nonblocking
17:06 jberger you can't rush it :P
17:09 irqq joined #mojo
17:18 ma112 $app->plugin goes from the main directory?
17:18 ma112 I added $app->plugin(Config => { file => 'config/config.conf' }); in my register
17:18 ma112 but $self->config('..'); doesn't work?
17:18 ma112 or must i assign a variable in this case to $app->plugin?
17:24 kiwiroy joined #mojo
17:26 pink_mist did you add a '..' setting to the config?
17:28 pink_mist what's $self there?
17:28 purl well, $self there is a resultset, so tweak to you situation
17:29 pink_mist no it isn't purl
17:32 ma112 https://nopaste.linux-dev.org/?1120880
17:32 ma112 Config and variable exists
17:33 pink_mist uhm
17:34 pink_mist your $self is undefined there
17:34 pink_mist wtf was that supposed to do?
17:34 ma112 Ok lol. = @_; was missing.
17:35 ma112 not sure who removed it, because when i typed this line im sure i added it
17:58 disputin joined #mojo
18:20 mtths joined #mojo
18:36 hartenfels joined #mojo
18:38 kiwiroy joined #mojo
18:42 Grinnz sri: neat, definitely will add to Mojo::SQLite too
19:20 kiwiroy joined #mojo
19:25 ribasushi sri: SQLA has its small share of problems, but the API is pretty stable
19:26 ribasushi sri: maintenance-wise: there's the problem of mst having the insistence of rewriting 95% of it replacing it with a 2nd-system kind of pluggable thing, which I have been opposed to for a while
19:27 ribasushi sri: as soon as work-stress eases up or DBIC starts moving somewhere ( whichever comes first ), I'm going to ship a "stays as-is" fork of SQLA so people have something reliable to work with going forward
19:28 ribasushi what happens to the existent namespace in the future - I can't tell for obvious reasons
19:28 pink_mist wow, such fearmongering
19:28 ribasushi ?
19:29 ribasushi pink_mist: I was asked a question, I am answering it. I 100% mean and stand behind every word I said
19:29 pink_mist you come with vague visions of the future development breaking everything
19:30 ribasushi shrug, dinner time for me &
19:32 sri pink_mist: i did ask for his opinion
19:34 pink_mist I missed that tbh, but ribasushi has a beef with mst, so anything mst touches becomes suspect by default it seems
19:34 Grinnz sri: you probably should specify quote_char => '"' in the SQL::Abstract constructor, as the default is not to quote identifiers
19:35 Grinnz " is the identifier quote in pg right?
19:38 genio yep
19:41 sri oh, i should prolly look up how DBIx::Class configures SQL::Abstract
19:43 Grinnz https://metacpan.org/pod/DBIx::Class::Storage::DBI#quote_names
19:44 genio SQL::Abstract++
19:51 asarch joined #mojo
19:51 sri ok, mst agrees that quote_char => '"' might be the one thing to set for Pg
19:52 sri generated sql looks a bit better
19:56 sri pink_mist: i had a beef with mst too... so...
19:56 sri pink_mist: but i asked both for opinions
19:57 sri and i think SQL::Abstract is still a reasonably safe choice
20:03 disputin joined #mojo
20:04 genio I've used it for quite some time without problems.  I think it's a good choice
20:08 pink_mist sri: yes, but you never let your beef colour your opinion on everything he touched
20:09 jberger genio: did we ever get around to discussing a simpler interface for Digest::Bcrypt?
20:09 pink_mist (at least not so far as I noticed)
20:10 sri pink_mist: many years ago there was a time when it most definitely did
20:12 pink_mist oh, must have been before my time - you don't do that anylonger though, do you?
20:14 sri it's basically like a bad breakup, getting over it takes time
20:14 jberger robots have relationships?!
20:14 jberger what a world we live in
20:14 jberger :-P
20:15 genio jberger: Nah. not really yet.  (or I've otherwise forgotten)
20:15 jberger genio: I like the ease of use of this module
20:15 jberger https://metacpan.org/source/MINIMAL/Mojolicious-Plugin-Bcrypt-0.14/lib/Mojolicious/Plugin/Bcrypt.pm
20:15 genio Again, I'd be happy to throw a commit bit and a comaint your way
20:15 jberger but I hate that it is done as a helper
20:16 jberger generating random salt etc
20:17 jberger genio: I'm not sure it is worth it honestly
20:17 jberger if I did, I'd probably just make a Bcrypt::Simple or some such
20:17 jberger but I'm afraid of doing that
20:17 jberger because then I'm on the hook if it isn't good enough
20:17 jberger :D
20:17 genio haha
20:19 jberger genio: honestly, if Digest::Bcrypt had a method that generated a random salt of appropriate length, it would probably be enough for me
20:19 sri jberger: has futurama taught you nothing?
20:19 jberger but maybe I should just copy the one from the plugin
20:19 genio I could certainly alter Digest::Bcrypt so that by default (ie, no salt is provided) it generates is own random salt (using the same algorithm as the Mojo plugin
20:19 jberger sri: well, Bender is more lifelike than most robots ;D
20:20 jberger genio: then the question is, is the plugin's algo good enough?
20:20 sri anyway, please review before i release https://github.com/kraih/mojo-pg/compare/v2.35...master
20:23 jberger sri: why @cb
20:23 jberger https://github.com/kraih/mojo-pg/compare/v2.35...master#diff-3ff1b9e1103956cba792fae2f31a2f46R18
20:24 jberger oh, nm
20:24 sri undef would be counted as a bind value
20:24 jberger yep
20:24 jberger I just got there
20:24 jberger list flattening
20:24 purl i heard list flattening was generally the right thing.  Sometimes its not, but you'll have to wait til Perl 6 for that.
20:24 jberger heh, purl, how wrong you have that now
20:25 sri lol
20:25 sri purl: keep dreaming
20:25 purl sri: what?
20:34 cpan_mojo Mojo-Pg-3.0 by SRI https://metacpan.org/release/SRI/Mojo-Pg-3.0
20:34 genio jberger: Data::Entropy::Algorithms::rand_bits(16*8);    seems like a sane-enough randomized salt to me
20:34 sri and too late ;p
20:35 jberger yeah
20:35 jberger genio: would it make sense to late-require D::E::A if you try to crypt something without setting a salt
20:35 jberger so effectively an optional dep?
20:36 Grinnz jberger: i don't like that random salt function, it depends too much on rand()
20:37 jberger Grinnz: and thus I think why genio is recommending this Data::Entropy::Algorithms module
20:37 Grinnz if you want to depend on that, yeah
20:38 jberger genio: or even the very least, after the recommendation in your doc, if you could give the example usage?
20:38 Grinnz otherwise, i tend to do some sort of hash of join '$', rand, $$, time
20:38 Grinnz that way you have time and process id entropy
20:38 Grinnz extra rands isnt going to help
20:39 sri Grinnz: your turn :)
20:39 Grinnz i also added a \my $dummy to that for WWW::OAuth, but i'm not sure whether that makes a difference (random memory address, sorta)
20:45 Grinnz jberger: https://metacpan.org/source/DBOOK/WWW-OAuth-0.006/lib/WWW/OAuth.pm#L85
20:46 Grinnz the \my $dummy idea was from what Net::Twitter had been using, since the author wanted a better nonce string than what i had before
20:47 Grinnz Time::HiRes::time is even better, also
20:48 jberger genio: wait, now I'm even more confused
20:49 jberger Digest::Bcrypt can't import the setting from a previously bcrypted string?
20:49 genio Data::Entropy goes pretty far to get randomness.  Otherwise   Math::Random::Secure?
20:49 jberger how do you use it to check equivalence?
20:50 Grinnz hmm
20:50 Grinnz it doesn't looko like you can, directly
20:50 Grinnz you'd have to extract the salt and cost yourself
20:51 Grinnz it would need a method to pass the formatted settings string directly
20:51 jberger a major reason I was liking the look of Digest::Bcrypt more than the lower level one was I didn't want to have to think about the strings ;-P
20:51 jberger oh well, guess I can just do that
20:51 Grinnz you have to sorta think about it one way or the other :P
20:51 Grinnz either on the way in or the way out
20:52 jberger surely a module must be able to do that for me, the plugin does (though not well it seems)
20:52 Grinnz $settings = join( '$', '$2a', $cost, _salt() );
20:52 Grinnz tahts basically all I do when using it manually
20:52 Grinnz it = Crypt::Eksblowfish::Bcrypt
20:54 jberger though it looks like CEB has a function to do that too
20:54 Grinnz the tricky part is that the salt must be encoded using Crypt::Eksblowfish::Bcrypt's en_base64 function
20:54 jberger I guess I should just be using that
20:54 Grinnz and must be exactly a certain size
20:55 sugar joined #mojo
20:55 Grinnz yeah, bcrypt_hash does that true
20:57 * sri wonders when a synopsis gets too big
20:57 sri http://mojolicious.org/perldoc/Mojo/UserAgent#SYNOPSIS
20:57 sri http://mojolicious.org/perldoc/Mojo/Pg#SYNOPSIS
20:58 jberger hehe
21:01 genio I was confused by that use case as well (once a call to digest has happened, all prior knowledge of the salt and cost are gone).  I thought it would make more sense to only clear the buffer, but I didn't want to break anything.
21:01 genio Digest is annoying that way
21:01 Grinnz genio: prior knowledge doesn't matter. The digest could have been made 3 years ago
21:01 Grinnz the point is, you need some way to pass it in, so it can use it as the settings string
21:03 Grinnz i.e. in the standard crypt method, my $digest = bcrypt($password, $settings); my $check = bcrypt($password, $digest); and those two lines could happen years apart
21:03 Grinnz then you check if $check eq $digest
21:04 jberger right
21:04 jberger and btw, no, bcrypt_hash doesn't build the $setting style stirng
21:04 jberger seriously
21:04 purl is that for real?
21:04 Grinnz oh right, that's why i don't use it
21:04 Grinnz heh
21:05 jberger good security only works when it is the easiest way to do things
21:05 jberger this so far is not meeting that test
21:07 jberger maybe this? https://metacpan.org/pod/Passwords
21:14 genio I could add a settings param easily enough.
21:15 jberger well, now that I see this module, I wonder if you should leave yours alone, leave it as the Digest:: interface to Bcrypt
21:17 genio if settings is passed in, the get the salt and cost from that, ignoring the salt and cost parameters.  the settings method could either build the current settings string or build cost/salt from the new settings.
21:17 jberger that's basically what the plugin does
21:18 genio and provide the Data::Entropy::Algorithms::rand_bits(16*8); example in the docs
21:18 genio then at least others don't have to go through the annoyance of the same troubleshooting that just took place
21:18 jberger sure
21:18 jberger that'd be nice
21:18 jberger for future readers
21:35 ribasushi pink_mist: my SQLA-under-mst concern is based on already existing code that I held off merging because of the effect on CPAN it had, and on mst's documented insistence that he do so anyway "when riba lets him"
21:35 ribasushi I can provide links if needed, but that's a bit offtopic for #mojo
21:46 Grinnz https://github.com/Grinnz/Mojo-SQLite/commit/01203bfc7123e02f162d064f1a21a5f04115603f
21:46 Grinnz test file works mostly as is, just ->last_insert_id instead of {returning => 'id'}
21:46 px80 jberger, when doing nested delay callbacks, can I just pass the same $delay object from callback to callback?
21:47 Grinnz the blog model looks so nice now :)
21:49 jberger px80: in theory you COULD but that isn't what you want to do
21:49 jberger you want a different delay object so that it is isolated from the other stuff that's going on
21:49 px80 hmmm
21:50 px80 can you explain why?
21:50 px80 I trust you, but I'am wondering :)
21:50 jberger because each inner delay is doing this chain of sequential http requests
21:50 jberger and the outer one is waiting for them all to finish
21:51 jberger if it was all the same delay then anything you started at first would have to finish together (ie all the login requests)
21:51 jberger the whole point of using separate delays is that the non-blocking sequences are preserved but don't affect each other
21:52 jberger I can link you to a presentation I gave on basically this topic
21:52 px80 that would be nice
21:52 jberger it had some technical difficulties and even some of the concepts are aging a little bit
21:52 jberger but the ideas are the same
21:52 jberger https://www.youtube.com/watch?v=UGufeknRHjQ
21:53 jberger some notes, you don't need "unless $x->ioloop->is_running" anymore
21:53 jberger and ->on(error => sub { ... }) is more easily said as ->catch(sub{ ... })
21:53 px80 when the first callback triggers the next nonblocking call, but the first one don't depend on the second, then it could be done also without a second delay object?
21:54 jberger my pattern now looks more like Mojo::IOLoop->delay(sub{ ... }, sub { ... }, ... )->catch(sub{ ... })->wait;
21:55 jberger px80 you can put as many nonblocking calls in the same step as you want, those are run in "parallel"
21:55 jberger and when everything begun in that step is done, then it moves on to the next step
21:55 PryMar56 joined #mojo
21:55 px80 yes, but I have in one step a call whichs callback has another call, just to overcome the sychronizing effect of another step
21:55 px80 which is not needed
21:56 jberger I can't parse that sentence
21:56 px80 hehe
21:56 jberger watch the talk
21:56 jberger hopefully it helps
21:56 px80 okay thanks
21:56 jberger just know that some of the syntax is slightly improved
21:56 jberger and I'm sorry for the places where the text gets too small
21:57 pink_mist jberger: I think he means that he doesn't want all the first steps to be done in parallel and then all the second steps to be done after all the first ones have completed - he wants each second step to happen right after its first step completed
21:58 jberger px80: here is the source of the talk: https://github.com/jberger/MojoConf
21:58 jberger I don't have it running live anywhere
21:58 sri Grinnz++
21:58 px80 yeah
21:58 jberger I've been meaning to give that talk again sometime in order to force myself to rewrite it into my current frameowkr
21:59 px80 looping through gets, where each get needs to trigger a subsequent one (with the information it needed from the first one)
21:59 jberger px80 (pink_mist): ok, well that's why you abstract the chains that do depend on the previous requests into a single chain of delay steps
21:59 px80 so to speed things up
21:59 jberger then have an outer controller
21:59 jberger like I said, watch the talk
21:59 jberger it should help
22:00 px80 i will
22:01 px80 when I sychronize first all gets before next step is started, this loses some performance, some gets might have already finished so that the subsequent one can start immediately (which does cares about other servers asked in parallel)
22:01 jberger (oh gah, it is using Mango too, I forgot about that)
22:01 jberger man time flies
22:01 px80 *does not
22:01 jberger px80 there are design patterns for all of these cases
22:02 jberger once you grok how steps work, it is just a matter of wiring them together
22:03 px80 pink_mail nailed my requirement down
22:03 px80 will watch your video show now
22:03 px80 pink_mist, sry :D
22:06 cpan_mojo Mojo-SQLite-2.000 by DBOOK https://metacpan.org/release/DBOOK/Mojo-SQLite-2.000
22:08 px80 jberger: what has happened to the resolution and quality of this video
22:08 px80 I can't recognize any code
22:08 px80 :D
22:13 jberger I haven't watched it in a while :(
22:14 jberger are the slides still taking half the screen?
22:14 jberger eventually I bump it to single column and it should be easier to read
22:15 jberger (this was the last time I used this presentation software)
22:15 ribasushi jberger: can confirm - maximum is 480p and the slide-text is nearly unreadable
22:15 ribasushi if you have a 720p handy: I'd re-upload
22:16 jberger batman would have it if anyone does
22:16 jberger I really just need to redo this talk
22:16 jberger too much went wrong
22:16 * jberger weeps
22:20 genio jberger: https://github.com/genio/digest-bcrypt/tree/genio/autosalt  something like that any more helpful?
22:22 jberger I see a few Digest::Becrypt in there
22:22 jberger typo
22:22 genio oops
22:23 genio resolved that. thanks
22:24 jberger genio: so even though the branch is called autosalt, it doesn't generate a salt still right?
22:24 jberger though you have documented how to
22:24 genio no, it doesn't do it automatically.  I just started the autosalt branch when I thought that was the route to go while we were first talking
22:24 jberger it is nice that it can take the settings string now
22:24 jberger yeah, I think that's a lot more helpful
22:25 jberger genio++
22:25 disputin joined #mojo
22:26 genio good. going to go through a few more reviews of the docs as I already found another typo and then publish.  YAY
22:26 Grinnz nice, only thing i would add is maybe a more complete generate-and-check workflow one might use the settings option for
22:26 Grinnz example, that is
22:26 jberger ah good point
22:27 jberger what Grinnz said :P
22:35 genio example added
22:36 jberger my app is coming along nicely
22:36 jberger https://github.com/jberger/CarPark/tree/model
22:37 jberger after recent discussions here I couldn't in good conscience put out an app that passed the app to the models
22:38 jberger so I finally came up with a pattern I like better that lets models invoke each other
22:38 jberger and still feel mojo-y from helpers
22:39 jberger basically implemented as this base model https://github.com/jberger/CarPark/blob/model/lib/CarPark/Model.pm and this plugin https://github.com/jberger/CarPark/blob/model/lib/CarPark/Plugin/Model.pm
22:40 jberger then specific model instances are subclasses of that base and thus can instantiate other models
22:40 Grinnz genio: hmm, its just returning the hash like bcrypt_hash and not the settings format hash, though, isn't it :/
22:40 Grinnz guess not much you can do about that
22:40 jberger ^^ that's kinda what I was worried about, its within the Digest:: framework
22:42 Grinnz the ideal is to store the whole settings format, because each hash should have a different salt (and possibly cost)
22:45 genio https://metacpan.org/pod/release/CAPOEIRAB/Digest-Bcrypt-1.207/lib/Digest/Bcrypt.pm  The settings hash string is built on the current cost and salt.  You'd have to store the resulting hash and the settings hash seperately
22:46 Grinnz right, that works in a way
22:46 genio my $bcrypt = Digest->new('Bcrypt', settings=>$some_known_settings);  if ($bcrypt->add($value_from_user)->digest eq $known_pass_hash) {}
22:47 Grinnz just gotta make it clear that the settings hash you're storing is specific to that password hash
22:47 Grinnz and not for general use
22:48 Grinnz s/hash/string/
22:48 genio I thought the example showed that without me needing to explicitly state it, but yea, I can see your point
22:52 Grinnz the bcrypt() interface just makes it more convenient by combining the two strings
22:52 Grinnz but it's no different otherwise
23:20 twm109 joined #mojo
23:26 twm109 i just noticed the release of Mojo-Pg 3.0 which introduces a dependency on SQL-Abstract which introduces more dependencies and subdependencies (Moo, for example).
23:28 twm109 is there any chance of the requirement on SQL-Abstract becoming optional in Mojo-Pg 3.01?
23:47 sri why?
23:48 genio Moo has pretty few dependencies
23:49 pink_mist as long as it's not Moose, it's fine
23:50 genio twm109: Is there any reason you object to those few outside dependencies?
23:51 genio The added functionality far outweighs the negatives of a slightly bigger dependency chain in my view
23:56 Grinnz unless your project's only dependency is Mojolicious, it's likely that Moo is brought in for something else anyway
23:56 Grinnz it has 1500 direct reverse dependencies on cpan

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