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

IRC log for #mojo, 2015-06-13

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

All times shown according to UTC.

Time Nick Message
00:06 mattastrophe joined #mojo
00:44 asarch joined #mojo
01:23 klapperl_ joined #mojo
01:24 mattastrophe joined #mojo
01:25 bin_005 joined #mojo
01:52 woz joined #mojo
02:20 * jberger tinkers with a second layer of routing and a JSON over websocket structure like [METHOD, /path, body]
02:21 jberger http://pastie.org/10238174
02:22 jberger so routing can work, just need to think up dispatching
02:22 cpan_mojo Mojolicious-Command-snoodoc-0.01 by CURTIS https://metacpan.org/release/CURTIS/Mojolicious-Command-snoodoc-0.01
02:23 jberger aggrolite++
02:23 aggrolite :-)
02:24 aggrolite the donuts one is still WIP
02:25 * jberger wants donuts!!!
02:25 * aggrolite always wants donuts
02:26 aggrolite din din time
02:27 noganex joined #mojo
02:27 * dave misses donuts
02:54 Kogurr joined #mojo
02:57 woz joined #mojo
03:10 kaare joined #mojo
03:10 frudas joined #mojo
03:10 frudas hello
03:10 purl hey, frudas.
03:10 frudas i have a designe question
03:13 frudas how can i do a cache answer with mojo
03:13 frudas from  a json answer from mojo that query   sqlite that dont change a lot
03:13 frudas ?
03:14 frudas just concept
03:14 frudas thankx :)
03:16 frudas i over query the webservice with https://loader.io to see performance
03:16 frudas without any nginx or apache
03:22 preaction frudas: just hold onto the response in memory. but, i mean, sqlite isn't exactly slow
03:22 preaction if you want, there's a module called CHI that has useful features
03:25 frudas thankx
03:25 frudas i will see
03:28 frudas with this module you can do something like : dont query sqlite if sqlite.db if the same that the last time you query , use last query info
03:28 frudas :)
03:30 preaction maybe? that sounds like a custom kind of expiration module. it's kind of just simpler to expire the cache yourself if you're doing that
03:31 preaction so, i mean, if that's the behavior you want, i'd probably just do it manually
03:31 preaction check the If-Modified-Since header you get, compare with the timestamp on the sqlite.db, and decide whether to send a 304 Not Modified response (you don't need to even send a body in that case)
03:32 preaction or you could use a sqlite db in memory
03:32 frudas mmm in memory
03:33 frudas just:   my   open("$sqlite" ,"/wherereberpath/sqlite.db"); ?
03:35 frudas and compare if sqlite size change or checksum
03:36 preaction no. connect to a SQLite database in memory
03:36 frudas how?
03:36 preaction my $memdb = DBI->connect( 'dbi:SQLite:dbname=memory' );
03:37 preaction then you can load your existing database into that memory database, and now you don't have to worry about disk i/o
03:37 preaction but, i mean, usually when one needs performance, like concurrency, one needs to use a different database
03:39 frudas :) thankx for the tips
03:40 damaya_ joined #mojo
03:40 frudas my $dbh = DBI->connect("dbi:SQLite:MASTER/HOPE.db","","") or die "Could not connect";
03:40 frudas helper db => sub { $dbh };
03:40 frudas something like that will work?
03:40 frudas helper select => sub {
03:40 frudas my $self = shift;
03:41 frudas my $sth = eval { $self->db->prepare('SELECT * FROM PERSONS') } || return undef;
03:41 frudas $sth->execute;
03:41 frudas etc
03:41 frudas ...
03:41 frudas }
03:42 preaction i might do: helper db => sub { state $dbh = DBI->connect( ... ) or die; return $dbh };
03:42 preaction i would not do the same for select, because that needs to return a different sth every time
03:43 preaction perldoc -f state explains what state does
03:43 frudas thankx ;)
03:43 frudas go back to code
03:49 absolut_todd joined #mojo
04:01 woz joined #mojo
04:10 _dave_ joined #mojo
04:26 perllogic joined #mojo
04:26 aggrolite joined #mojo
04:35 absolut_todd joined #mojo
04:38 perllogic I am new to Mojolicious an have to say I like it a lot. I was following along with the mojocasts Episode 5 Mojo::UserAgent and experienced a problem while trying to dom walk to get the title. I know I can use ->res->dom->at('title') but I would like to know why the previous way doesn't work. Here is the details of my error: http://pastebin.com/YJhxmetx
04:38 Repaster Repasted text from perllogic: http://fpaste.org/231702/41702991/
04:39 preaction my guess is that the AUTOLOAD stuff that allowed you to do that was removed
04:40 perllogic preaction: so your saying the webcast is outdated?
04:40 preaction they are pretty old, yes
04:40 preaction they work as an intro, and there's an errata page somewhere, let me find it
04:40 perllogic preaction: gotcha, thanks. Is there a simular way to dom walk?
04:40 perllogic similar*
04:41 preaction https://github.com/kraih/mojo/wiki <- looks like the errata are here
04:41 perllogic thanks.
04:41 preaction i don't know. i wouldn't walk the dom in that way, personally
04:45 preaction i mean, you could probably do: $dom->at( 'html' )->at( 'head' )->at( 'title' ); but at that point, why not just: $dom->at( 'html head title' );
04:45 preaction though perhaps more accurately it would be: 'html > head > title'
05:03 irq joined #mojo
05:03 woz joined #mojo
05:05 damaya_ joined #mojo
05:13 damaya_ joined #mojo
06:08 woz joined #mojo
06:13 dod joined #mojo
06:18 dod joined #mojo
06:42 damaya__ joined #mojo
06:43 damaya__ Hey all, is there any way with Mojo::DOM to add to the href attr for a link?
06:43 damaya__ href="/post/new" and I want to add blah so it's href="/post/new/blah"
06:46 damaya__ I am doing it like this: $dom->at('a:nth-child(1)')-attr({href => $dom->at('a:nth-child(1)')-attr('href').'/blah'});
06:46 damaya__ that works, but just wondering if there's a better way
06:49 preaction my $link = $dom->at( 'a:nth-child(1)' ); $link->attr( href => $link->attr( 'href' ) . '/blah' );
06:51 damaya__ ok, so I was on the right track
06:51 damaya__ agreed that looks better though
06:53 preaction DRY - Don't Repeat Yourself
07:02 jberger preaction++ # answer all the things!
07:04 irq_ joined #mojo
07:15 woz joined #mojo
07:36 damaya__ Hi all
07:36 damaya__ just out of curiousity, how do you format long SQL statements in your code?
07:53 trone joined #mojo
08:14 Vandal joined #mojo
08:20 woz joined #mojo
08:21 amon joined #mojo
08:24 xtetsuji___ joined #mojo
09:00 berov joined #mojo
09:24 woz joined #mojo
09:26 kaare joined #mojo
09:55 kaare_ joined #mojo
10:03 mattastrophe joined #mojo
10:06 panshin joined #mojo
10:11 batman jberger, marcus, sri: https://github.com/jhthorsen/swagger2/commit/3b2054d0274519bb3b2ba9beb1f132f049858648
10:29 woz joined #mojo
10:43 zivester joined #mojo
10:54 damaya__ Is there a way to clone an element with Mojo::DOM?
10:54 damaya__ I.e., my $new = Mojo::DOM->new($el->at('a:nth-child(3)')->to_string);
10:55 mattastrophe joined #mojo
10:55 pink_mist did you try it?
10:56 damaya__ Yeah, doesn't work :/
11:02 pink_mist what do you mean doesn't work? it surely does /something/. what? and in what way was it /different/ from what you expected?
11:07 damaya__ ok, one second
11:07 purl i guess one second is second is the duration of 9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom.
11:07 damaya__ testing
11:12 ToApolytoXaos joined #mojo
11:15 mattastrophe joined #mojo
11:16 damaya__ Here are the tests I did: http://paste.scsys.co.uk/paste
11:18 damaya__ All I want is a new DOM object from an existing DOM object (basically pick on element out, create new Mojo::DOM object from it), so that I can modify that single element without modifying the original.
11:19 damaya__ For example, Mojo::URL has the clone method, which allows me to create a new Mojo::URL object that I can modify without modifying the original. I was wanting to do that with Mojo::DOM. I don't need a method, but I need some way of doing it.
11:21 pink_mist I'm not sure what you think you pasted, but it wasn't a paste
11:21 damaya__ http://paste.scsys.co.uk/488244
11:21 damaya__ thank you :)
11:22 damaya__ When I say '$next is now just foo', I mean it is literally the string foo.
11:32 pink_mist after you create your $next from a Mojo::DOM->new() of the old element
11:32 pink_mist you need to call ->at() on it
11:32 pink_mist ->at('a')
11:33 pink_mist my $next = Mojo::DOM->new($dom->at('a:nth-child(1)')->to_string)->at('a')->attr(class => 'active-link')->content('next');
11:34 woz joined #mojo
11:37 damaya__ Awesome! Thanks pink_mist :D
11:38 damaya__ I had something so close to that earlier, but I was then calling to_string on it and then my attr change later was failing
11:38 damaya__ now later attr call works!
11:38 damaya__ :)
11:40 damaya__ Hunf! Now off to bed.
11:55 oetiker joined #mojo
12:09 oetiker joined #mojo
12:16 lluad joined #mojo
12:17 oetiker joined #mojo
12:27 mattastrophe joined #mojo
12:36 sri reading up on rails action cable... it's quite terrible
12:37 sri mostly due to rack i guess, same reason all the psgi frameworks are terrible at this stuff
12:38 sri phoenix and play framework do a pretty good job though
12:41 sri really impressed by phoenix, whole framework is really well done
12:41 sri cool routing concepts https://github.com/chrismccord/phoenix_chat_example/blob/master/web/router.ex
12:42 sri sockets, with multiple channels tied to different controllers
12:42 sri pipelines with plugs (which are basically reusable hooks)
12:45 sri template helpers are a bit weak (due to everything being functional and the need to pass around state information)
12:49 batman sri: did you look at my swagger2 patch?
12:49 batman it's not channels. but it allow the already defined REST API to be transported over ws
12:49 sri no
12:50 sri and like i said before, i'm against REST over websockets
12:53 batman i think channels are too low level, but i might be missing out on the big picture
12:58 sri you might
12:58 sri the point is that it multiplexes multiple channels over one websocket
12:59 sri it does not change semantics, you're still dealing with bi-directional streams
13:00 sri json encoding/decoding is handled transparently... but that's not important
13:04 sri a possible mojolicious implementation of the feature could look like my $ws = $r->websocket('/ws'); $ws->channel('foo')->to('foo#'); $ws->channel('bar')->to('bar#');
13:05 sri and then you have MyApp::Controller::Foo and MyApp::Controller::Bar
13:05 sri or even MyApp::Channel::Foo
13:06 sri which define a few methods like sub join {} sub leave {} sub message {}
13:06 xtetsuji___ joined #mojo
13:07 sri or some other pub/sub terminology
13:08 AndrewIsh joined #mojo
13:09 sri $ws->channel('foo:*') would be a namespace of channels
13:09 mattastrophe joined #mojo
13:11 sri actually, i think i don't just hate REST over websockets, i want to punch people who do it
13:11 sri it's just so wrong
13:12 klapperl joined #mojo
13:15 sri btw. in phoenix every message has a topic like "foo:bar", an event name like "join", and a JSON payload
13:18 sri it also does some pretty cool stuff with elixir multi subs
13:20 sri translated to perl (if perl had multi methods).... package MyApp::Channel::Foo; sub join ($self, 'foo:bar', $message) {} sub join ($self, 'foo:baz', $message) {}
13:20 purl babelfish cannot translate from en to en.  Try translating through English.
13:20 sri elixir can dispatch that based on the second function argument
13:20 batman what i like about the swagger patch is that it (will) allow something like this: https://gist.github.com/jhthorsen/f4966ed4abac348701af
13:21 batman and API will then fallback to normal REST or use websockets if available.
13:27 batman i think i could be using "REST" wrong... not sure
13:28 xtetsuji___ joined #mojo
13:30 sri it certainly is my opinion that you do
13:30 sri REST is cool *because* it is HTTP, mapping it on a layer that removes all the advantages is silly
13:30 klapperl_ joined #mojo
13:30 sri websockets are stateful, you're giving up caching and stuff...
13:31 batman i'll be back with a better example in the new convos codebase (hopefully)
13:31 sri it's all wrong
13:31 batman or i will understand that i'm all wrong, hehe
13:31 sri if you want a fallback, you map websocket semantics on HTTP
13:31 sri not the other way around
13:32 batman i think i'm using swagger as a generic api descriptor and not for rest specifically.
13:33 batman *food*
13:37 asarch joined #mojo
13:41 kaare joined #mojo
13:44 woz joined #mojo
14:04 mattastrophe joined #mojo
14:22 jberger sri: so in that elixir-like example, the channel and topic are the same thing?
14:23 jberger Or topics are like sub channels?
14:30 marmez left #mojo
14:41 marmez joined #mojo
14:42 marmez left #mojo
14:50 woz joined #mojo
15:02 disputin joined #mojo
15:10 aggrolite joined #mojo
15:27 sri jberger: topics are the channel
15:28 sri the router matches on the topic and routes the message to a channel module
15:37 sri btw. this is the js client of phoenix https://github.com/phoenixframework/phoenix/blob/master/web/static/js/phoenix.js
15:38 sri not sure we would want to support something like that in core
15:40 sri anyway, i found it interesting that me and batman disagree so drastically on the topic
15:40 sri prolly a good argument against having channels yet
15:40 sri the concept still needs to evolve
15:52 trone_ joined #mojo
15:54 woz joined #mojo
15:57 batman sri: i'm not sure if we disagree. i think it's more "i have no idea what i'm talking about"
15:57 batman i think i also was against having Mojolicious::Validator in core, but now i love it...
16:00 batman i might not have any idea what i'm talking about, but have a vague feeling i'm trying to scratch another itch than what channels are supposed to.
16:07 PryMar56 joined #mojo
16:07 batman calling things "new_msg" reminds be of not having autocomplete... *phoenix.js*
16:11 jberger I will read more about it soon, but I'm getting geared up for jeeping/hiking atm
16:11 woz joined #mojo
16:13 batman jberger: have an awesome trip!
16:14 * jberger needs a hiking emoji
16:14 Grinnz i like the channel ideas, it's very similar to what i already have been doing manually over websockets
16:15 batman Grinnz: can you present the usecase for what you're solving?
16:15 Grinnz updating the client about things that happen from other clients, and update the server about things the user does
16:16 Grinnz i had an "action" in both directions, and depending on that it would dispatch to a certain method
16:16 Grinnz in both js and the server
16:16 batman ok.
16:17 batman i think i need to read the channels documentation for pheonix again tomorrow, when i'm not hung over :P
16:17 Grinnz hehe
16:22 ajr_ joined #mojo
16:23 cpan_mojo Mojolicious-Command-snoodoc-0.02 by CURTIS https://metacpan.org/release/CURTIS/Mojolicious-Command-snoodoc-0.02
16:25 berov joined #mojo
16:33 mattastrophe joined #mojo
16:51 Kogurr joined #mojo
16:57 dod joined #mojo
17:02 sri like i've said before, channels is about multiplexing
17:02 sri imagine you're doing not just one but two things over websockets
17:02 D4RK-PH0ENiX joined #mojo
17:02 sri say, updating a chat and a worldmap with dots above the chat
17:03 disputin joined #mojo
17:03 sri two completely separate things, how do you handle those without a second websocket connection?
17:11 Grinnz exactly
17:16 batman sri: i handle them with client side generated tokens
17:17 batman but i guess we're still not talking about the same thing, so i will step aside.
17:31 * sri will step aside too, since he doesn't actually have a need for this feature currently
17:38 sri if there's a real need i'm sure we'll see plugins on cpan, and they'll figure out the details
17:39 batman +1
17:39 purl 1
17:42 jberger Grinnz: perhaps we should collaborate on such a plugin
17:42 jberger We have need of such a thing at work
17:42 jberger Monitoring system for phone queues
18:11 preaction are there any notes on how to test apps that use Mojo::Pg? do i go through the motions of initializing a new database, spinning up a pg server, creating tables, and etc...?
18:12 * pink_mist would check reverse deps on Mojo::Pg and see what tests they do
18:12 pink_mist oh, only reverse dep was Test::Mojo::pg
18:12 pink_mist heh
18:12 pink_mist but that seems a good place to start :P
18:13 pink_mist *Test::Mojo::Pg
18:14 batman preaction: maybe mct can help... https://github.com/mojoconf/MCT/tree/master/lib/MCT/Model
18:14 preaction Test::Mojo::Pg looks perfect, thanks
18:17 preaction ... except it's GPL3... which makes my thing using it GPL3...
18:18 pink_mist hmm? it says "This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself"
18:18 pink_mist so you can choose either gpl or artistic license
18:19 preaction http://cpansearch.perl.org/src/RICHE/Test-Mojo-Pg-0.3/LICENSE
18:19 preaction oh ffs there're two licenses
18:19 pink_mist yes, the license file is the gpl3 license because the gpl3 license requires the license text to be distributed with the tarball, dunno if the artistic license requires that, but in this case it clearly isn't
18:21 preaction "Same terms as Perl itself" is GPL1+Artistic, not GPL3
18:22 pink_mist tell that to the module author
18:22 preaction yep, doing that now
18:22 pink_mist pretty sure gpl1 says 'or any later version of gpl'
18:22 pink_mist so he'd be free to use gpl3 then
18:23 preaction no, you have to opt-in to that. it's not in the license. it's in the explanation. and that's still not "same terms as perl itself"
18:24 pink_mist http://dev.perl.org/licenses/ <-- this says "or any later version"
18:24 preaction it is in the same terms as perl itself, but that just means that the user, i.e. me, am allowed to use the GPL3 license if I want
18:25 preaction but that clause isn't in the GPL license. you don't have to say "or any later version"
18:26 preaction clause 9 of the GPLv2 explains that bit
18:26 preaction point being that there's confusion here, and that's the worst possible thing for software licensing
18:27 pink_mist to be honest, he probably just grabbed the latest version of the LICENSE file because he thought the latest version was "the best"
18:28 pink_mist I see the license file being there as mostly just a convenience; the actual license is specified as being the same terms as perl itself; the LICENSE file is just to have the text of the latest gpl version in there
18:29 Grinnz you can't assume that with software licenses
18:29 preaction but it's not though, because it introduces ambiguity. and ambiguity is why lawyers make money
18:29 Grinnz only the author can clarify
18:30 preaction ambiguity is how people get sued
18:30 preaction (well, how people get sued and it doesn't immediately get thrown out of court)
18:31 Grinnz this is why all my code is explicit Artistic v2 and only that
18:32 Grinnz even the two-license thing of "perl itself" is a bit confusing
18:32 mst I like 'same as perl' because it makes the GPL fanboys shut up and leave me alone and then everybody else can use it under the AL
18:32 preaction yeah, but it makes clear the ability to bundle the module with perl, since there's no license incompatibility
18:32 Grinnz that's clear already since artistic is compatible with artistic+gpl
18:34 preaction anyone who is using perl under perl's terms can use my stuff because they're the same terms. they don't have to go and re-evaluate the terms (lawyers cost money because they're worth it, because the alternative is unknowable)
18:34 mst right, that as well
18:34 avenj licensing conversations give me distro-dev-related ptsd manifestations, can't a guy get a trigger warning? :(
18:34 Grinnz perl's terms include artistic v2 already, there's no difference
18:34 Grinnz lol
18:35 mst avenj: Mojo doesn't support triggers, maybe you wanted Moo? :)
18:35 Grinnz now if you go from some artistic v2 module to perl's terms, then you need to re-evaluate
18:35 avenj mst++
18:35 Grinnz but i guess thats not something that would happen, you can't really use a perl module without perl
18:36 preaction perl 5's terms don't contain artistic 2 though.
18:37 preaction it's just "b) the "Artistic License"". which, heh, fun, ambiguity
18:37 Grinnz lol
18:37 Grinnz thats true...
18:37 pink_mist well, that does link to the specific license text
18:37 preaction the GPL planned for this, they've got a clause that says "if the software is just 'GPL' and not a specific version, you can use any version"
18:38 pink_mist at least on the link I gave earlier
18:39 preaction yeah, it links to v1, and afaict it's generally agreed that perl 5 is artistic 1. artistic 2 only exists because OSI (i think) refused to certify artistic 1
18:39 preaction oh, nope, it was the FSF
18:44 mattastrophe joined #mojo
18:47 kaare joined #mojo
19:40 davido___ joined #mojo
19:52 lluad joined #mojo
20:04 Adura joined #mojo
20:33 aggrolite joined #mojo
20:41 disputin joined #mojo
21:31 damaya_ joined #mojo
21:32 damaya__ joined #mojo
22:11 mattastrophe joined #mojo
23:44 aggrolite joined #mojo
23:45 bpmedley http://bmedley.org/mojo.pdf <— I’ve done some more work on this.  I think it looks less fugly; however, still some ways to go.
23:56 woz joined #mojo

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