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

IRC log for #mojo, 2017-12-18

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

All times shown according to UTC.

Time Nick Message
00:14 Leffe joined #mojo
01:13 Afristar_ joined #mojo
02:05 mohawk Leffe, that kind of thing is already available in perl in the call stack, like sri referred to: Carp::croak
02:09 mohawk i have yet to see a use for cancellation
02:09 mohawk Grinnz, nice! your SYNOPSIS foreach could be just a map?
02:09 mohawk (the Futurify, that is)
02:09 Grinnz SURE
02:09 Grinnz oops caps
02:10 Grinnz it's easier to see the use for cancellation once you use it
02:10 mohawk my @futures = map $ua->get_p($_)->with_roles('+Futurify')->futurify, @urls;
02:11 mohawk Grinnz, can you example me?
02:13 Grinnz in my bot i create futures wrapping useragent requests, and have them cancel when the bot sends a 'stop' event, i.e. when i tell the bot to stop https://github.com/Grinnz/maverick/blob/master/lib/Bot/Maverick.pm#L440-L452
02:13 Grinnz that leads to neither success nor failure events occurring
02:14 mohawk fair
02:15 Grinnz it also cancels the rest of the chain
02:15 Grinnz which i may attach on_cancel handlers to (I don't in this case)
02:17 Grinnz it's also used in Future::Mojo's new_timer and new_timeout future constructors, so that you can call $f->cancel and the timer will be removed from the loop https://metacpan.org/source/DBOOK/Future-Mojo-0.004/lib/Future/Mojo.pm#L50
02:18 Grinnz it's usually used the opposite way from done and fail handlers; the API sets up what happens on cancellation, and the user decides to cancel; whereas the user sets up what happens on success or failure, and the API makes that happen
02:22 mohawk i feel like i would handle that (basically a recurring) by just checking before initiating the actual thing
02:22 mohawk so not a "cancel" but a "do_i_keep_going"
02:22 Grinnz you could, but that leads to repetition of boilerplate, just like error handling in delays
02:23 Grinnz it means you have to be aware of that case at every step in the process
02:23 mohawk truthfully, i have yet to deal with a situation where i even have recurring
02:23 Grinnz rather than just handling it in one place
02:23 mohawk but a self-re-initiating promise module could just have the checking thing as part of it
02:24 mohawk no boilerplate on user side
02:24 Grinnz the user would need to check in each promise they attach
02:24 Grinnz that's rather the point of promises, that the user can add on whatever they want and it just works
02:24 mohawk by "promise" i assume you actually mean "then"
02:24 Grinnz yes
02:25 mohawk the promise is the inciting event
02:25 mohawk everything after that is consequences
02:25 mohawk referring to those as a "promise" causes confusion for those of us with small brains
02:25 Grinnz the consequences can and usually are further promises
02:25 Grinnz otherwise why attach a new then
02:26 mohawk then-s don't have to return promises
02:27 mohawk the only time i'd have them do so is for single-stream sequential stuff like in my bulkget
02:28 Grinnz maybe it would help to look at a real chain like i'm talking about, https://github.com/Grinnz/maverick/blob/master/lib/Bot/Maverick/Plugin/Translate.pm#L87-L98
02:28 Grinnz note that _retrieve_access_token returns a future chain itself
02:28 Grinnz each of the followup ->thens run a new useragent request and return a future
02:30 mohawk yes, that was plainly visible but thanks for the top tips
02:31 mohawk i don't see why it's on_done not another then?
02:31 Grinnz personal preference, since it doesn't need to wait on anything else after that
02:31 Grinnz so there's no need for antoher future
02:32 Grinnz using Mojo::Promise i would of course use a then
02:33 Grinnz what i'm trying to say is, chains like this are the big reason to use promises at all, if you arent ever going to need to put together a chain or convergence of promises you're not gaining much over callbacks and doing error handling once inside them
02:41 mohawk sri, have you checked out Syntax::Keyword::Try ?
03:25 jberger mohawk I did point that out earlier
03:25 jberger that one doesn't allow checking for exceptions by type
03:26 jberger Syntax::Feature::Try does
03:26 jberger however ::Keyword looks like it does other things better
03:32 Grinnz SFT also apparently suffers from speed issues
04:30 Leffe joined #mojo
04:37 mohawk truth be told, i'm wondering how much people really use dispatched exception-handling
04:49 Grinnz probably more people in languages that support it automatically :P
05:25 itaipu joined #mojo
06:31 jberger More Wishlist, this time with more model! https://twitter.com/joelaberger/status/942643336158105600
06:32 jberger If I don't come up with more ideas, it might end up having tests and be released to CPAN before I'm done
06:33 Grinnz jberger: while sqlite doesn't have a boolean type, you can still write 'boolean' as the type as it's just an alias for numeric affinity
06:45 aborazmeh joined #mojo
06:48 Vandal joined #mojo
06:56 Afristar joined #mojo
07:08 Leffe joined #mojo
07:23 jkp joined #mojo
07:25 jkp_ joined #mojo
07:30 karjala_ joined #mojo
07:36 inokenty-w joined #mojo
08:01 McA joined #mojo
08:02 dod joined #mojo
08:07 dod joined #mojo
08:15 zach joined #mojo
08:19 trone joined #mojo
08:23 cosimo joined #mojo
08:29 Leffe joined #mojo
08:33 AndrewIsh joined #mojo
08:49 ashimema joined #mojo
08:59 karjala_ sri, regarding my bug on github, I seem to have gotten the impression that maybe if before closing the connection, a socket shutdown is done, and then a little while passes, then maybe (just maybe) the browser will behave better... does that make any sense?
08:59 karjala_ that's the impression i got by going through a few webpages about this issue
09:00 karjala_ something like this: https://perldoc.perl.org/functions/shutdown.html
09:00 karjala_ but i couldn't understand very much from those pages
09:01 karjala_ so i'm not sure about anything (that's why I say maybe)
09:03 karjala_ my search started from this page, where "graceful close" is mentioned: https://www.safaribooksonline.com/library/view/http-the-definitive/1565925092/ch04s07.html
09:03 karjala_ i saw elsewhere the suggestion that graceful close means socket shutdown among other things
09:06 karjala_ I really don't know what I'm talking about, sorry
09:08 karjala_ maybe in case of exceeding max_request_size, a shutdown of the reading of the socket could happen, then the response can be sent (after all data has been received), then close those connection
09:08 karjala_ maybe
09:09 karjala_ because i read that chrome will read the response only after finished sending data
09:09 karjala_ its
09:09 karjala_ dat
09:53 sri karjala_: you're welcome to try and implement it
09:53 sri but half-close has a reputation for not working well, and nobody implements it
09:54 sri in fact, the websocket protocol has a closing handshake because half-close doesn't work
09:54 sri it doesn't propagate through intermediaries and shit
09:55 gregf_ joined #mojo
09:56 karjala_ intermediaries = reverse proxies and stuff?
09:57 sri and connect proxies and so on
09:57 sri socks...
09:57 purl socks is binary or (: ssh -D) or http://gsrescue.org/bios04/dbsocks.htm or at http://x1.develooper.com/~robert/socks1/ (start at 4748)
09:57 karjala_ ok, in that case I'd better not try to implement it, it sounds like it would be a waste of time
10:05 rcz I'm having some trouble with Mojo not evaluating my templates properly. It thinks HTML tags are <> operators: https://i.imgur.com/KsKEGaJ.png
10:06 rcz Debugger expanded: https://i.imgur.com/CJJVCkx.png
10:07 rcz omg I've been looking for this error for like an hour and I just saw the missing "...
10:14 CandyAngel rcz: Either "quack quack" or the universe is determined to make you look silly :)
10:17 sri as usual rubber duck debugging works
10:19 rcz In my defense, my .ep vim plugin messed up, confusing me: https://i.imgur.com/q2YZH9B.png
10:36 dod1 joined #mojo
11:02 ghenry joined #mojo
11:18 itaipu joined #mojo
12:33 mib_j6g29j joined #mojo
13:03 mohawk_pts joined #mojo
13:27 itaipu joined #mojo
13:32 gizmomathboy joined #mojo
13:41 dotan_convos joined #mojo
13:55 marty joined #mojo
14:09 Pyritic joined #mojo
14:14 jacoby joined #mojo
14:19 jberger This blog post I stumbled on on twitter is interesting
14:19 jberger http://woz.posthaven.com/what-orms-have-taught-me-just-learn-sql
14:20 jberger it advocates ideas that very much fall in line with the Mojo-Flavored DBI modules we have
14:20 sri hehe, i've seen tahat linked like 5 times today
14:20 jberger I wonder if I should link to it in my blog post from yesterday
14:20 sri s/a//
14:20 sri <3 Mojo::Pg
14:20 sri just wish SQL::Abstract had a few more features
14:20 * jberger can confirm, <3
14:21 sri like limit offset
14:21 jberger I don't actually use SQL::Abstract that much (yet)
14:21 jberger but actually after using it in the blog post, I might for simple stuff now
14:22 sri i always do for simple crud stuff
14:22 jberger I hate to admit how many tries it took me to get that json select working in SQLite
14:22 jberger it is just different enough from postgres to need to do it differently
14:23 sri json in sqlite is no fun
14:23 mishanti1 Totally unrelated: is there any way of getting hold of mojo-stickers without paying a soul and a leg to stickermule for shipping?
14:23 sri mishanti1: go to perl events
14:25 bwf joined #mojo
14:25 mishanti1 Heh. Ok, so no. :) I'll make sure to pick some up when I get to a perl-event that has any,
14:26 sri jberger: which reminds me, do you still have enough or do i need to send you another thousand?
14:26 mishanti1 I was honestly quite surprised to see that stickermule didn't offer some kind of shipping that was a tier cheaper than the absurdity of UPS/DHL.
14:26 jberger I have lots
14:26 sri or meet me or jberger in person
14:26 CandyAngel That's not an invitation to turn up at their house at 3am, by the way
14:26 CandyAngel Lessons learned
14:26 * sri has been handing out stickers wherever he goes
14:26 jberger me too
14:27 sri CandyAngel: !
14:28 * sri should als liz if she needs more stickers
14:28 sri s/als/ask/
14:30 karjala_ joined #mojo
14:35 CandyAngel mishanti1: Do you put stickers on your laptop?
14:44 jberger STICKER ALL THE THINGS!!!!
14:44 jberger oh speaking of sql, I found some cruft in that query I was mentioning
14:45 jberger I'm glad I linked to a tag rather than a commit hash, now I can fix it and move the tag and the blog post links are unchanged
14:47 gizmomathboy joined #mojo
14:48 sri what i hate the most about sqlite json is having to use joins to do anything remotely serious
14:48 gryphon joined #mojo
14:48 mohawk_pts CandyAngel, ha ha!
14:49 CandyAngel jberger: I have a sticker book, then I only put duplicates of those on my laptop
14:49 CandyAngel So I have 2 stickers on my laptop :P
14:50 sri this stuff sucks https://github.com/openSUSE/build-check-statistics/blob/master/lib/SUSE/BuildCheckStatistics/Model/Packages.pm#L99
14:51 jberger I haven't used the table valued functions
14:52 jberger mostly for me it was that there is not easy aggregation
14:52 sri an array type would help sqlite a lot
14:53 sri postgres gets data structures so right
15:00 mishanti1 CandyAngel: Not really. Oftentime I have to contribute in situations where showing absolutely no technological bias is required. So laptop needs to stay "anonymous".
15:00 mishanti1 I put stickers on other stuff though.
15:02 mishanti1 But my question earlier was just because I wanted to have mojo-stickers to give away. Might order some "swag" instead, as postage for that wasn't outrageous.
15:08 CandyAngel Huh? How much is Stickermule charging you for delivery?
15:10 sri stickermule is really expensive if you don't buy huge quantities
15:13 CandyAngel Well, mishanti1 said for shipping, but when I go there, the shipping is free..?
15:15 * sri bookmarks http://ohshitgit.com
15:20 mishanti1 CandyAngel: I was just about to order 100 stickers for (I believe) $79, but then I noticed that they wanted to charge $49 for shipping.
15:21 mishanti1 And sure, $49 is not a lot of money in an of itself, but compared to the quantity that is delivered it is an unreasonably large portion of the total.
15:22 CandyAngel OKay, that's a bit crazy. Changed mine to 100, still says shipping is $0.00
15:28 mishanti1 You in the US?
15:29 CandyAngel No, the UK
15:35 mohawk_pts where's the company located?
15:36 CandyAngel New York..?
15:36 purl o/` a helluva town o/`
15:37 CandyAngel Well
15:38 CandyAngel I think that is where their HQ is, they are spread out personnel-wise
15:39 mohawk_pts but US
15:39 mohawk_pts weird they would ship free to UK but not to their own country
15:39 mohawk_pts maybe their printer is in UK?
15:39 CandyAngel Maybe
15:41 sri oh, i think shipping costs changed recently since they now produce stickers in the eu too
15:41 mohawk_pts https://www.stickermule.com/uk/support/ship-to-uk
15:42 mohawk_pts "shipping is free for all orders to the UK"
15:42 mohawk_pts i'm certain it'll be they're printing on this side of the pond
15:42 mohawk_pts as for why they're frankly overcharging for US shipping, well...
15:42 sri free in germany too now :)
15:43 mohawk_pts mishanti1, this says order >$40, 2-day shipping = free: https://www.stickermule.com/uk/support/how-much-does-shipping-cost
15:44 mohawk_pts and <$40 usps shipping is free too
15:45 mishanti1 https://www.stickermule.com/support/international-shipping-cost <-- Norway $49
15:46 mohawk_pts well if you're going to live in norway...
15:46 mohawk_pts this is clearly a sign you should move to the UK
15:46 mohawk_pts looks to me like it will basically pay for itself
15:47 mishanti1 Hehe. Have you had a look at british politics lately? ;)
15:48 mohawk_pts i have not
15:48 mohawk_pts what have they done today?
15:50 mishanti1 mohasri: I might just take you up on the offer of meeting up in person to convert money to stickers. At least if you're not terribly far from Berlin by train or other sensible transportation.
15:51 mishanti1 ^-- should say 'sri'
15:51 sri other side of the country
15:51 mishanti1 Doh.
15:52 mishanti1 Well, I'll keep it in mind anyway. :)
15:52 mohawk_pts mohasri - a new composite entity
15:56 CandyAngel Roles! They are taking over!
15:56 mohawk_pts i'm imagining the action-movie version
15:57 mohawk_pts arnie in the climactic scene says:
15:57 mohawk_pts "compose THIS"
15:57 CandyAngel Here, let me.. helper you with that *throws $x through window*
16:00 mib_95zjyt joined #mojo
16:03 mohawk_pts nice callback to the exceptions chat from yesterday
16:04 sh14 joined #mojo
16:12 kes joined #mojo
16:13 CandyAngel :D
16:51 ghenry joined #mojo
17:08 jberger speaking of git, I did a fair amount of history surgery to make it so that the commits in the Wishlist repo were useful
17:08 jberger since I specifically site them as examples of growing
17:08 jberger was kinda fun actually
17:11 Grinnz just dont ever do that on a repo other people are pulling from :P
17:18 jberger certainly not
17:18 jberger but, this wasn't really announced by then
17:18 jberger ie wasn't announced at all
17:19 jberger also, I always reserve 100% right to do it to my feature/topic branches, even pushed to the main repo
17:22 Grinnz sure, same for PR branches
17:22 Grinnz those are generally understood to be owned by one person
17:42 jamesaxl joined #mojo
17:44 dod joined #mojo
17:52 ChmEarl joined #mojo
17:57 itaipu joined #mojo
18:01 geospeck joined #mojo
18:23 trone joined #mojo
18:29 disputin joined #mojo
18:40 Grinnz https://www.theverge.com/2017/12/16/16784628/mozilla-mr-robot-arg-plugin-firefox-looking-glass
18:47 lilybet joined #mojo
18:49 lilybet Hi. I used to use Mojo::SQLite and had code like `$self->pg->db->insert('reviews', $review)->last_insert_id`. Now I switched to Mojo::Pg and looks like Mojo::Pg::Results doesn't have a ->last_insert_id method. Is there a way to get the value of the `id SERIAL PRIMARY KEY` column of the insert that was just done with Mojo::Pg?
18:49 Grinnz lilybet: with Pg you can do RETURNING id
18:50 Grinnz there is a way to specify that in SQL::Abstract as well
18:50 lilybet Thanks. I'll give it a shot.
18:50 Grinnz {returning => 'id'} as one of the params i believe
18:51 lilybet Now I see an example in SYNOPSIS docs: https://metacpan.org/pod/Mojo::Pg#SYNOPSIS
18:52 jabberwok I recently discovered sqlite is strange in that you get a last_insert_id value, even if your table is not declared as having any integer id values at all.
18:53 Grinnz yes, all rows in sqlite have a rowid
18:53 Grinnz if you have an integer primary key autoincrement, it will just use that for the rowid
18:53 Grinnz + not null
18:54 lilybet Grinnz++ # worked like a charm. Thanks!
18:55 Grinnz jabberwok: http://sqlite.org/lang_createtable.html#rowid
19:00 itaipu joined #mojo
19:00 Grinnz you can get last_insert_id from postgres but it's complicated, so returning id is easier https://metacpan.org/pod/DBD::Pg#last_insert_id
19:02 jabberwok Ahhhh... thanks Grinnz
19:03 Grinnz always make sure you declare your primary keys as 'integer' not 'int' or anything else ;)
19:05 Grinnz also, 'integer primary key' gets 'not null' implicitly, but only if it happened to get mapped to the rowid, otherwise it's nullable by default, because backcompat
20:01 jberger Grinnz: that is something I wondered as I did my post
20:01 jberger is it encouraged to use the rowid rather than making your own?
20:01 jberger seems like cheating or something
20:01 Grinnz yes, it's an optimization
20:01 Grinnz you'd never use it directly of course
20:02 jberger those two statements seem like a contradiction
20:02 Grinnz oh you mean, use it instead of declaring a primary key? no
20:02 jberger ok, that's what I thought
20:02 Grinnz use it by declaring an integer primary key and using that
20:05 bwf joined #mojo
20:16 perlpilot joined #mojo
20:24 itaipu joined #mojo
20:40 stokachu_ joined #mojo
20:44 stokachu joined #mojo
20:52 stokachu joined #mojo
21:00 stokachu joined #mojo
21:11 dylan joined #mojo
21:17 berov joined #mojo
21:18 berov Hello
21:19 berov I am trying to generate Mojo templates with Mojo::Template
21:20 berov %% is replaced with %, but %%= is not replaced with %=
21:20 berov How can I solve this problem?
21:21 berov See http://mojolicious.org/perldoc/Mojo/Template#SYNTAX
21:21 sri umm, it is
21:21 sri %%= is a form of %% of course
21:21 berov I would like %%= to not be evaluated. Same like %%
21:22 sri you're inventing a problem
21:22 berov may be I am doing something wrong. I will double check
21:22 berov my case is <%%=
21:23 preaction that works fine for me
21:24 berov preaction: can you show source code somewhere on github or something so I can look and compare?
21:26 preaction i don't understand what you mean. you want the template? https://raw.githubusercontent.com/jberger/mojolicious.io/master/blog/2017/12/15/day-15-start-a-new-yancy-app/index.markdown or do you want how i call the template renderer?
21:29 preaction it might be better to show what you're doing. then the people here can try to figure out why it isn't working
21:29 berov how do you call the template renderer? I implemented in a command http://paste.ubuntu.com/26211199/
21:29 berov and %% seems to not get replaced properly
21:30 berov my idea was to use templates from files in my command and from the __DATA__ section
21:33 berov I am trying to make a resourses (in REST parlance) generator or CRUD
21:34 berov https://github.com/kberov/Mojolicious-Command-generate-resources/blob/master/lib/Mojolicious/Command/generate/resources.pm
21:35 perlpilot_ joined #mojo
21:35 berov After Mojo::PG,Mojo::mysql , Mojo::SQLite
21:36 berov in short: gete tables from the databse and generate routes,actions,Controllers and Models
21:37 berov When I used __DATA__templates it worked fine.
21:40 berov I want to use templates for the templates from files so programmers can replace them with their own templates.
21:58 berov Oh I have a bug: variables naming hell
22:08 berov I get the following output in the generated template: http://paste.ubuntu.com/26211387/
22:09 berov seems like there was attempt to process the template  despite %%
22:13 berov please disregard. sorry for the inconvenience. I had one line %= and not %%=
22:16 karjala_ joined #mojo
22:17 jabberwok "Any problem (once solved) is simple"
22:18 berov yeah :)
22:19 Grinnz XML has yet to be simple, and it's been solved for a long time :P
22:47 jabberwok and let's hear it for the "Lightweight" Directory Access Protocol.
22:48 mohawk SOAP: The S Stands For Simple
22:49 mohawk part 17 of "History's Greatest Lies"
22:52 jberger SMTP was the Simple Mail Transfer Protocol
22:53 jberger I hate to think what the non-simple options were
22:53 sri smtp is not a bad protocol though
22:58 mohawk it's stood the test of time
23:04 jberger I didn't say bad, but it isn't simple (as I understand it)
23:08 mohawk as i understand it (having written a client for it back in 1992) it's pretty simple?
23:23 jberger ok I'll rescind!
23:23 jberger oh, right
23:24 jberger on a google, I realize I was thinking of MIME not SMTP
23:24 genio we all hate email.
23:24 CandyAngel Nu, email is amazing
23:25 genio pfft. email hates the living. rjbs told me so
23:29 preaction everything they've tried to replace e-mail with has been worse. so, so much worse
23:32 mohawk mime is ok too
23:32 sri no, it really isn't
23:32 sri look up encoding nightmares
23:37 mohawk nothing mime-related seen
23:41 sri https://stackoverflow.com/a/34929800
23:46 sri it's so much fun that browser vendors just said fuck it... we'll utf-8 encode our multipart/form-data headers https://github.com/kraih/mojo/blob/master/t/mojo/request.t#L1846

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