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

IRC log for #mojo, 2015-09-17

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

All times shown according to UTC.

Time Nick Message
00:21 bpmedley_ joined #mojo
00:33 bpmedley_ I showed Mojolicious to a coworker the other day and they were impressed.  Cool stuff.. they are an admitted perl hater..
00:35 Grinnz most perl hate is because the person does not know about modern perl :)
00:35 Grinnz and I don't just mean the book
00:59 kd or the phython inferiority complex
01:45 panshin joined #mojo
02:00 pink_mist next version: holy sri श्री ... if that even comes out right from this terminal :P
02:12 Adura joined #mojo
02:14 pink_mist ah, seems to display better on the irclog page than in my terminal :P
02:15 Zoffix :)
02:50 noganex_ joined #mojo
03:02 kaare joined #mojo
03:11 sri jberger: oh, re stack overflow, i wanted to tell him that the problem is much more complicated, with a reference to the spec
03:58 irqq joined #mojo
05:22 melo joined #mojo
05:28 inokenty-w joined #mojo
05:30 jberger joined #mojo
05:47 marcus re python https://twitter.com/danielpunkass/status/644267884387168256
05:58 dod joined #mojo
05:59 dod joined #mojo
05:59 absolut_todd joined #mojo
06:03 dod joined #mojo
06:04 panshin joined #mojo
06:29 melo joined #mojo
06:57 sue joined #mojo
07:03 AndrewIsh joined #mojo
07:03 eseyman joined #mojo
07:18 trone joined #mojo
07:45 gorfel joined #mojo
07:59 vanHoesel joined #mojo
08:03 vanHoesel1 joined #mojo
08:19 vanHoesel joined #mojo
08:19 berov left #mojo
08:47 Vandal joined #mojo
09:07 panshin_ joined #mojo
09:18 panshin joined #mojo
09:55 melo joined #mojo
11:07 irqq joined #mojo
11:11 gorfel I am storing document ids (base64 urlsafe strings) in a database. I want to build a route where this (stashed) base64 string is the destination. How would I best achieve this? Should I stash the base64 value and use it to build the route?
11:14 dvinciguerra joined #mojo
11:37 batman gorfel: why can't you use placeholders?
11:40 buu Yes, that
11:40 neilhwatson joined #mojo
11:40 buu gorfel: /route/user/:id
11:41 meshl joined #mojo
11:43 Quai a base64 string might contain '/', so maybe a *id
11:47 batman gorfel: i don't understand why you need base64... why not just use the "id" column or some other unique identifier?
11:49 gorfel Thanks for pointing me in the right direction guys. Read a bit more about placeholders and it makes sense.
11:58 gorfel batman: I thought that a base64 url_safe string was good enough as a unique identifier. It shouldn't contain characters like '/'.  I don't want to use a id column, because I am not really interested in people guessing document ids.
11:59 gorfel I'm using Data::UUID::Base64urlsafe
11:59 batman what's wrong with guessing document ids?
12:05 gorfel Well, if your application is facing the internet it could be a problem, in my case it's probably a result of an unneeded design decision. I'll think about it some more.
12:07 sri uuids are a terrible way to hide something from the internet
12:08 batman i agree with sri.
12:11 nicomen I halve always used basic incremental ids, but always been pondering less predictable id schemes, why are uuids bad?
12:13 mishanti1 I quite enjoy using uuids. So much simpler life with those VS incremental id's.
12:13 mishanti1 In any case: if people guessing id's is an issue the problem is _not_ what you are using as identifier.
12:14 mishanti1 More a case of a diseased application.
12:14 mishanti1 s/what/that/
12:15 mishanti1 ..or not.
12:15 sri security through obscurity
12:15 mishanti1 I think I need something to drink.
12:16 sri you're assuming uuids give you some sort of security, while in fact all your data is still public on the internet
12:16 mishanti1 Hehe. And yeah, back to the old "security by obscurity is not security"
12:16 mishanti1 When it comes to security I would _never_ let the id-scheme be a part of "security".
12:17 mishanti1 That is just begging for problems.
12:20 gorfel mishantil: yes, you are correct of course. Why is your life simpler with uuid than with incremental ids?
12:24 ZoffixWork joined #mojo
12:31 nicomen Ok, so, one could generalize to say never base security on URLs, no matter how clever scheme you think you have then. I thought there was something particularly bad with uuids.
12:43 ajr_ joined #mojo
12:48 mattastrophe joined #mojo
12:59 panshin joined #mojo
13:02 cpan_mojo BenchmarkAnything-Storage-Frontend-HTTP-0.004 by SCHWIGON https://metacpan.org/release/SCHWIGON/BenchmarkAnything-Storage-Frontend-HTTP-0.004
13:16 jberger joined #mojo
13:24 gryphon joined #mojo
13:27 hernanGOA joined #mojo
13:34 batman how crazy is this: each unit test creates a unique database and runs the tests against that database name in the same database server.
13:35 batman trying to follow up on the discussion i started yesterday ^
13:36 batman i wonder how that scales when i have several hundred test files and multiple users that want to run the same test suite...
13:37 Grinnz thats what i meant with the temp database name thing and locking, it's basically what the SQLite tests do except those databases aren't files
13:37 batman maybe i can DROP DATABASE at the end of the unit test...
13:39 bobkare At $work we have lots of test suites that autocreate databases with unique temporary names and drop them after they are done. Runs against a local db server though, so concurrent users isn't a thing, but I do often run prove with -j
13:39 batman bobkare: cool.
13:40 batman sounds like i will try to pursue this :)
13:42 bobkare with postgres I found I had some locking issues with concurrent CREATE DATABASE which I fixed by using template0 as the template, and it took a few tries to get the DROP to run no matter how the test failed or was aborted (to avoid leaving lots and lots and lots of temp databases around)
13:43 batman bobkare: yeah. how did you do that? END{} + DESTROY ?
13:44 bobkare that was the first try, but I ended up forking and detaching a process that then loops until the first pid is gone after I got tired of dropping hundreds of accumulated databases
13:44 bobkare kind of ugly, but it works :)
13:44 batman bobkare: wow. crazy :)
13:45 batman you could probably check getppid (not sure if that was what you meant)
13:46 bobkare I can pastebin the code if you want. Not directly usable since it's built around our in-house dbi wrapper, but you can see what I've done
13:46 batman no worries. thanks though :)
13:46 batman wonder if there's a cpan module for this...
13:46 batman if not: what should i call it? :)
13:47 bobkare Only one I found when I looked started a whole postmaster, which is even slower than CREATE DATABASE :)
13:48 batman yeah. i found a couple of those as well.
13:50 batman Test::TempDB ?
13:52 bobkare hm, not sure offhand what else I'd use it for, but it's not really testing specific
13:53 bobkare DBIx::TempDB?
13:53 batman :)
13:53 sri i wanted a solution for that problem in Mojo::Pg, together with support for fixtures, but never found a solution i really liked
13:54 batman sri: i'll show you what i've created later, and you can tell me what you think...
13:54 batman bobkare: hm... reason why i want to have "test" in the module name is to easier find the module
13:54 batman i mean, when i tried to find something that does this i searched for "test" on metacpan
13:55 berov joined #mojo
13:56 bobkare "test" could still be in the description or something which makes it visible to search engines
13:56 batman that's true
13:56 batman i'm still going with Test::TempDB, unless more people chip in on a better name / your suggestion
13:56 Grinnz_ if it's in the abstract, both metacpan and s.c.o will pick it up for searching
13:57 Grinnz_ i make my abstracts intentionally for this reason :)
13:57 batman oh. my name is awful :(
13:57 sri creating temp databases would limit the portability of Mojo::Pg quite a bit, normal users don't have the permission
13:57 sri not saying it's the wrong solution, but it seems tricky for beginners to get started
13:58 batman bobkare: stealing your name! thanks :)
13:58 sri starting a new postmaster actually seems more user friendly in that regard :S
13:59 Grinnz_ might be a good idea to have an option which uses a specific database name, and doesn't try to create it if it exists already
13:59 Grinnz_ so you can force things to work if you can't create databases...
14:00 batman sri: not sure about postmaster, but mysqld is very slow to start up.
14:01 sri fast tests mean nothing if nobody can use the system ;p
14:01 batman :D
14:01 batman haha. true that
14:04 sri for postgresql specifically i've been wondering if a schema would work better
14:04 sri create a temp schema, and change the search_path to that instead of public
14:06 panshin joined #mojo
14:06 sri of course that only works if your migrations don't use schemas...
14:08 sri http://www.postgresql.org/docs/9.4/static/ddl-schemas.html
14:10 mishanti1 gorfel: Has nothing to do with the id scheme, as security is implemented based on mechanisms access control. Eg limiting access to resources based on secrets (tokens, sessions etc) not on "knowledge about resources existence".
14:10 mishanti1 Oh. He left.
14:10 Lee joined #mojo
14:11 sri guess you could do app->pg->db->query('create schema foo'); app->pg->on(connection => sub { pop->do('set search_path to foo') }); ...tests here... app->pg->db->query('drop schema foo cascade');
14:12 sri and have a unique schema for every test
14:13 sri of course do the drop query in a DESTRY/END
14:14 mishanti1 I would rather create/drop the database, as schemas is a thing you might use as an architectural thing when designing a system.
14:14 mishanti1 We use schemas quite a lot.
14:14 sri well, then you don't get fast tests :)
14:15 sri i'm bringing it up because it's easy to add to most tests
14:15 sri schema hack doesn't require a special module, you add 3 lines of code and you can test parallel
14:16 sri as long as your migrations don't use schemas
14:17 mishanti1 We have migrations with schemas :)
14:17 sri yes, i understand that by now, this is not for you
14:18 sri i doubt there can be a one size fits all solution
14:18 mishanti1 The speed-consideration is mostly for dev-setups right? Avoiding irritation when developing?
14:19 batman bobkare, sri, Grinnz_: this is what i have now: https://github.com/jhthorsen/dbix-tempdb
14:20 batman (no code)
14:20 mishanti1 Because there are way to make database creation fast enought with postgres that you don't really notice it. I' have no idea how it is with mysql though.
14:22 sri i think we are talking past each other
14:22 sri database creation speed was never a concern
14:23 sri anyway, i don't like any of the solutions, so i'm out now ;p
14:28 mishanti1 Yeah, might have talked past each other. :)
14:41 bpmedley joined #mojo
15:00 PopeF joined #mojo
15:06 nicomen coincidentally I just finished doing several mysqldumps divided into definition and data files, then traverse the files in a dir structure and recreate sqlite3 dbs based on them to use for testing. one of the DBs unfortunately is so slow I will probably not recreate per test-file, but rather per objects default data earlier, it wil lnot allow concurrent tests locally though, should perhaps look into ...
15:06 nicomen ... that. Not sure if I could use a prove/perl instance parent process check or something
15:19 PryMar56 joined #mojo
15:30 disputin joined #mojo
15:31 yt7fms Hi, guys! I seem to be missing something.. How could I access 'Accept-Language' header with Mojo::Headers in my main 'lib/Mojo.pm' ?
15:32 Grinnz_ why do yo have a Mojo.pm?
15:32 yt7fms Accutaly it is 'Mobile.pm' but just used this as an example
15:33 Grinnz_ that module name already exists: https://metacpan.org/pod/Mojo
15:33 Grinnz_ oh ok
15:33 yt7fms sorry
15:33 Grinnz_ i would think you want to access a header in a request action, not in application startup when there's no requests yet
15:34 yt7fms Yes, and also not in controller. Since I have some simple routes that do not undergo a controller.
15:34 Grinnz_ that's fine, the action always gets the controller object regardless
15:35 Grinnz_ $c->req->headers->accept_language https://metacpan.org/pod/Mojo::Headers#accept_language
15:38 Oleg joined #mojo
15:42 yt7fms From what I understand, $c is a controller object? But, how do I create it or access it? I easily can access headers from a controller i.e. "lib/Mobile/Controller/Abc.pm" but not in "lib/Mobile.pm".
15:42 bpmedley yt7fms: It will be created for you and passed into your route.
15:43 Grinnz_ it is the invocant of every action method
15:43 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#Routes
15:43 Grinnz_ even inline ones
15:43 sri it's all in the tutorial
15:48 sh4 joined #mojo
15:53 PopeF joined #mojo
15:54 bpmedley yt7fms: Did you get an example working?
15:58 PopeFelix joined #mojo
15:59 yt7fms bpmedley, example yes. I do have a "Lite" app in which I have all working correctly. That is, accessing a controller object whitin a route. What I wanted is to access http header before routing in my full Mojo app..
15:59 bpmedley yt7fms: Have you seen the possible hooks?
16:00 berov left #mojo
16:01 * yt7fms slaps himself on a forehead
16:01 yt7fms That's what I was missing! :)
16:02 bpmedley yt7fms: Aweome.. :)
16:02 yt7fms I hate when that happens :) Thank You very much all!
16:04 batman i hate URI.pm
16:04 batman going to depend on Mojolicious, just to get Mojo::URL.
16:05 batman sri: i'm very glad you decided to support weird_scheme://
16:06 sue joined #mojo
16:12 sri thanks whatwg for he url spec :)
16:12 sri +t
16:12 sri -s
16:14 batman it probably takes less time to build mojo than uri.pm as well..... ;)
16:22 Grinnz_ no, URI is quite small
16:23 Grinnz_ i dislike the interface but it's nothing bad like LWP
16:25 batman Grinnz_: i was joking about the build time...
16:25 batman perl -MURI -e'URI->new("pg://example.com")->host' # Can't locate object method "host" via package "URI::_foreign"
16:26 Grinnz_ yes it doesn't apply many methods to arbitrary schemas
16:27 Grinnz_ i'm not sure if there are schemas that have no host?
16:27 Grinnz_ but i guess so
16:29 Grinnz_ huh: https://metacpan.org/pod/URI::db
16:32 sri the term URI is actually pretty much dead on the web
16:32 jberger I still never know which to call it
16:32 jberger so I usually use url
16:32 sri the working groups have mostly chosen URL
16:33 sri URI is to URL what XHTML is to HTML
16:33 jberger for my its mostly the symmertry of my $url = Mojo::URL->new(...), so its your fault :-P
16:33 Grinnz_ there is not any practical difference anymore that i can see
16:33 jberger sri: I like that analogy
16:37 batman URL->isa("URI") == true, URI->isa("URL") != true
16:37 batman URN->isa("URI") == true, URI->isa("URN") != true
16:39 sri https://url.spec.whatwg.org/#goals
16:40 sri the googlwfight link is funny
16:40 sri s/w/e/
16:44 Grinnz_ right, URNs, forgot about those
16:45 absolut_todd joined #mojo
16:46 KindOne joined #mojo
16:47 Kogurr joined #mojo
16:56 stephen joined #mojo
17:14 cpan_mojo DBIx-TempDB-0.01 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/DBIx-TempDB-0.01
17:15 batman \o/
17:15 mishanti1 Two cheers for going ahead and making something!
17:16 batman hehe. thanks :)
17:17 batman bobkare: i will take a pull requests with your fork stuff.
17:17 batman i got a pretty good idea on how to do it, but i won't implement it because it starts bugging me
17:18 mishanti1 batman: bobkare does a great job on that kind of stuff.
17:18 batman cool. also... i've marked the module as experimental, so any feedback might change the totally :)
17:18 batman the=it
17:22 mattastrophe joined #mojo
17:24 Eke joined #mojo
17:36 dod joined #mojo
17:38 mattastrophe joined #mojo
17:59 neilhwatson http://www.meetup.com/Toronto-Perl-Mongers/events/225031099/
18:03 batman Grinnz_: i would very much appreciate if you could help me make DBIx::TempDB depend on URI instead of Mojo::URL
18:03 Grinnz batman, i'll take a look later to see if it's doable
18:03 batman awesome! thanks :)
18:04 cpan_mojo DBIx-TempDB-0.02 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/DBIx-TempDB-0.02
18:05 irqq joined #mojo
18:07 batman jberger: got any feedback? ^^
18:08 panshin joined #mojo
18:08 * batman can go back to work after releasing the module to cpan
18:09 batman anything i make during work hours isn't my code :)
18:20 chansen batman: SQLite support in DBIx::TempDB could be convenient addition
18:20 batman chansen: i thought about it, and i don't see the point, since DBD::sqlite and friends support ":memory:"
18:20 batman ::SQLIte
18:23 Grinnz_ :memory: is not very useful in Mojo::SQLite, but that's why i have it use a tempdir by default
18:23 chansen batman: I'm aware that SQLite supports :memory, but from an API POV it would be nice if you could use the same module for more than MySQL or PostgreSQL.
18:23 Grinnz_ so yeah i dont really see a use case for SQLite needing this
18:24 batman chansen: i will probably take a pr, but i don't want to use time on this now myself
18:24 batman thanks for the input though
18:24 batman Grinnz_: why isn't :memory: useful?
18:25 chansen Think testing the same codebase with multiple DBD backends without needing to special case a specific one
18:25 Grinnz_ batman: because $sqlite->db will return a completely different database if the previous one hasn't queued up again yet
18:25 Grinnz_ migrations will most likely occur on a different database from the one you're using... etc
18:25 batman haha! of course :)
18:25 batman thanks
18:26 Grinnz_ thats why i have the example as my $tempdb = Mojo::SQLite->new(':memory:')->db
18:26 Grinnz_ or something like that :)
18:28 eitz joined #mojo
18:29 panshin joined #mojo
18:37 eitz joined #mojo
18:38 jberger batman: one easy comment is that you have to update your boilerplate :-P
18:38 batman 2014?
18:39 jberger 2015 is more than half over, means 2014 is long since past
18:39 batman already fixed :)
18:41 jberger otherwise, it looks fine I suppose
18:42 jberger I don't have a need for it at the moment
18:42 jberger so its hard to judge it that way
18:43 batman that's fine. thanks anyway :)
18:45 ajr_ joined #mojo
19:01 asarch joined #mojo
19:11 Oleg joined #mojo
19:20 HtbaaPi joined #mojo
19:27 jberger sri: are minion tasks guaranteed to run in insertion order?
19:30 vanHoesel joined #mojo
19:33 Ptolemarch joined #mojo
19:43 meshl joined #mojo
19:45 sri jberger: nope
19:48 jberger yeah, I don't think it would help me anyway :(
19:48 * sri thinks development with sqlite and production with postgres/mysql is an anti-pattern
19:49 sri re testing the same codebase with multiple DBDs
19:50 sri but we've had the topic here before :)
19:50 Grinnz_ yeah, and nevermind that SQLite doesn't even have a "create database" :)
19:50 batman sri: i starting to think you're right.
19:51 jnbek joined #mojo
19:51 batman *I'm
19:57 sri marcus: btw. if you like playing mech mage, you should also try casino mage with rhonin and spellslingers, it's hilarious, went from rank 9 to 5 in one winstreak
19:57 sri </hearthstone>
20:00 cpan_mojo DBIx-TempDB-0.03 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/DBIx-TempDB-0.03
20:01 batman bobkare: yeah... so i added drop from child process now :) ^^^^
20:06 marcus sri: Looks fun, but I don't have the cards :)
20:08 bc547 joined #mojo
20:11 batman marcus: "dag" on tv2 - are you going to watch it?
20:12 marcus batman: unlikely. We're watching the late show with colbert
20:12 batman oh.
20:12 batman Dag is the best :)
20:12 marcus I dunno. I'm not a huge fan of embarassing comedy.
20:13 marcus cringe comedy is the proper term apparently
20:13 batman oh. i would‘t say it's comedy.
20:13 batman it's way to "sad" for being a comedy imho
20:14 marcus batman: you wouldn't say it's a black comedy?
20:14 batman nope. i'm seriously missing out on something if it is, haha
20:14 batman (but i might)
20:15 batman i also consider "natural born killers" to be a love story, so.... :)
20:16 marcus batman: https://no.wikipedia.org/wiki/Dag_(TV-serie) defines it as Drama/Comedy
20:30 batman okidoki.
20:31 marcus wow, installed App::DDFlare from cpan. it has a huge graph
20:31 marcus I think I could implement it with Mojo::CloudFlare and 10 lines of perl...
20:35 ajmrch joined #mojo
20:37 marcusr https://stackoverflow.com/questions/32472986/doctype-sniffing-with-css3-and-specifically-with-mojodom
20:40 pink_mist yep, sri mentioned that question a while ago
20:41 pink_mist and how he couldn't provide an answer because he specifically wanted to avoid having to do doctype sniffing
20:41 pink_mist or something along those lines
20:43 batman does Mojo::Cloudflare still work?
20:54 mattastrophe joined #mojo
20:54 bc547_ joined #mojo
21:00 meshl joined #mojo
21:03 jabberwok joined #mojo
21:10 bc547 joined #mojo
21:17 sri pink_mist: the answer is that it's much more complicated than he thinks https://html.spec.whatwg.org/multipage/syntax.html#determining-the-character-encoding
21:18 pink_mist sri: I know ..
21:18 sri a regex to search for doctype and meta tags is not nearly enough
21:20 sri and i can't post on stack overflow because i don't have a solution
21:20 sri don't think i can comment yet, not enough karma
21:21 disputin joined #mojo
21:26 punter joined #mojo
21:35 sri well, i tried http://stackoverflow.com/a/32640333/2231922
21:36 jberger zomg that "algorithm"!
21:37 sri i bet it would require more code to implement than Mojo::DOM::HTML :)
21:38 neilhwatson joined #mojo
21:39 mishanti1 Peeking into the spec the SO-comment linked to reminded me yet again why I am very grateful that someone else is doing the awesome work of making frameworks for web.
21:39 mishanti1 all of you ++
21:39 Grinnz_ Mojo::EncodingSniffer::NotTiny
21:40 jberger "That this step happens before the next one honoring the HTTP Content-Type header is a willful violation of the HTTP specification, motivated by a desire to be maximally compatible with legacy content."
21:44 jberger I really should spend a little more time on SO again
21:45 sri i guess there might be cpan modules already
21:45 sri little old this one https://metacpan.org/pod/HTML::Encoding
21:45 jberger "The interface and implementation are guranteed to change before this module reaches version 1.00! "
21:45 jberger love seeing that
21:46 Grinnz_ of course, no HTML5 support :P
21:46 jberger and then 5 years without a release
21:46 sri this one looks better https://metacpan.org/pod/IO::HTML
21:47 Grinnz_ yea
21:47 sri code looks scary at first, but it's pretty minimalistic actually
21:50 Grinnz_ i was thinking it should be able to take the HTML as a string and not just a filehandle, but then, that would probably encourage people to screw up and pass it decoded strings :)
21:51 disputin joined #mojo
22:00 sri wait a minute
22:01 sri did i completely misunderstand the question?
22:01 sri what is doctype sniffing?
22:03 * sri shrugs
22:18 meshl joined #mojo
22:22 devroot joined #mojo
22:23 devroot I'm using Test::Mojo and put_ok(). Can I access the raw response content from the Test::Mojo object?
22:24 jberger devroot: $t->tx->res
22:24 jberger $t->tx is the $tx object you would expect from a useragent
22:24 devroot awsome thanks!
22:58 disputin joined #mojo
23:22 Ptolemarch joined #mojo
23:23 meshl joined #mojo
23:52 ajr_ joined #mojo

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