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

IRC log for #mojo, 2014-12-06

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

All times shown according to UTC.

Time Nick Message
00:00 franzkafka linagee, look at the code and you will see that it uses Mojo::UserAgent, etc... And I dunno, it's a plugin to Mojolicious, so I guess that's reason enough not to be 'just a perl module.'
00:01 franzkafka It adds routes, etc. If you look at the code it's pretty obvious why it's mojolicious specific.
00:01 jberger argh, I really wanted to use perltidy in the new project and I think I will have to abandon
00:02 jberger chained methods don't line up anymore!
00:02 jberger franzkafka: I don't understand what you want the plugin to do
00:03 jberger and no, plugin methods are not helpers automatically (if I read that correctly)
00:03 purl okay, jberger.
00:03 jberger purl: plugin methods
00:03 purl plugin methods are not helpers automatically (if I read that correctly)
00:03 franzkafka jberger, the plugin is for Orchestrate, and basically I want to be able to say $self->$collection->get, where collection is defined by the user (basically, think of collection as table names in a database).
00:03 jberger purl forget plugin methods
00:03 purl jberger: I forgot plugin methods
00:04 jberger franzkafka: I think you want an autoload on a class
00:04 franzkafka Like DBIx::Class does $tablename->create_related for example.
00:04 franzkafka OK, I will look into that then. Thank you jberger.
00:05 jberger all helpers are created with $app->helper( name => callback )
00:05 jberger so if you can introspect the app to find out what names you need, that should be easy
00:06 franzkafka Yeah, what I was going to do was loop over @{$config->{collections}} and create a helper for each element in there.
00:06 jberger but if they have to truly be dynamic (i.e. not defined when you load the plugin) then you need a class and autoload
00:06 jberger franzkafka: that's fine
00:08 franzkafka ok, then I was going to have it called like $self->collection(get => ...), and do a my $method = shift; in the plugin. Because really, get, put, delete, etc are the only methods, and they don't change per collection.
00:08 franzkafka err, s/in the plugin/in the helper
00:09 franzkafka sorry man, my head feels like a baloon right now just floating around
00:11 * jberger suspects that franzkafka shouldn't be designing apis in this state
00:11 * franzkafka thinks jberger is probably right
00:11 jberger and my suggestion is only so useful without really seeing things
00:18 franzkafka jberger, I am going to post for code review before putting on CPAN :D
00:19 jberger always remember that helpers a (by default) lumped into a global helper namespace
00:19 jberger so if you want to put it on cpan, don't make too many and don't have generic names (like get)
00:20 jberger there are "namespaces" for helpers in newer mojolicious versions
00:20 jberger more like nested helpers
00:22 linagee weird. github knows how to render .pod files? hah
00:22 franzkafka Oh man that's good to know before I got started. I was wondering if get would be legit.
00:27 jberger franzkafka: here is one of my more OO plugins: https://github.com/jberger/Mojolicious-Plugin-PPI/blob/master/lib/Mojolicious/Plugin/PPI.pm
00:28 jberger there are only two helpers, one of which when given no arguments returns the plugin instance
00:28 jberger in this way I can do $c->ppi->do_something
00:29 sri jberger: i think how to do that should also be clear from the growing guide
00:30 sri which does pretty much the same with $c->users->check(...)
00:31 jberger sri: that's close to the same thing
00:31 jberger I think most people don't think to close over the plugin instance itself though
00:32 jberger the users class there could be a plugin and then be essentially the same as I suggest, but since that is more of a model than a plugin I like it better how it is
00:33 jberger sri: how do you make perltidy align (and specifically not misalign) chained test methods?
00:33 akhasanov joined #mojo
00:33 sri jberger: look at the mojolicious tests
00:33 sri it just works
00:35 jberger not all the methods are aligned: https://github.com/kraih/mojo/blob/master/t/mojolicious/app.t#L236
00:35 jberger and I think it only does align because of the continuation indent being 2 chars and $t being 2
00:35 sri then our definitions differ
00:35 franzkafka jberger, wait, the helper is dynamic, so $self->game let's say, and the method on the helper would be get, put, etc... is taht still bad? I.e., $self->game->get
00:36 franzkafka get would not be a helper, thus no $self->get
00:36 franzkafka wait, I was doing it this way... $self->game( get => $json_object );
00:37 jberger franzkafka: either of those is fine
00:37 purl i already had it that way, jberger.
00:37 franzkafka then in the helper I was doing my $method = shift; $self->$method
00:38 franzkafka The only thing I could see being a problem is if helpers are global, and they happen to have a collection named PayPal for example, and they're using Mojolicious::Plugin::PayPal...
00:38 franzkafka problems!
00:38 purl i think problems is the prisoner's dilemma
00:38 jberger but $self is what, the controller? so then $method has to be a method on the controller or another helper
00:39 franzkafka jberger... true. I will have to think about how to best implement this without causing collisions with other plugins, etc
00:40 sri use $app, $c, $plugin... to make your examples less ambiguous
00:40 jberger I do too
00:40 jberger in fact I almost never use $self in a mojolicious app anymore
00:40 sri $self is total garbage without context
00:40 sri it has no meaning on its own
00:41 sri when you're inside the class, $self is perfectly fine
00:41 jberger even there, with the way that helpers can be called on different object, it might not be obvious what the invocant is
00:42 jberger objects
00:42 sri if you follow that simple rule $self is never ambiguous
00:43 sri it always belongs to the nearest package statement
00:43 jberger I suppose that's true
00:43 jberger but then I still would never use it in a plugin definition (or anything that might declare helpers)
00:44 sri soon we'll have a method keyword and capturing $self will be implicit
00:45 sri "soon"™
00:46 franzkafka sri, is "soon" the sole the trademark of Mojolicious?
00:46 franzkafka :)
00:46 sri perl6 has that one cornered
00:47 jberger sri: could be a __THIS__ token :D
00:47 franzkafka haha, this is true :D
00:48 linagee how do I set the log directory with mojolicious::lite? :-/
00:48 jberger app->log
00:48 linagee the docs say define the dir like this: my $log = Mojo::Log->new(path => '/var/log/mojo.log', level => 'warn');
00:48 linagee Do I make a new Mojo::Log object, or is this bad?
00:48 jberger linagee: that is the class api reference doc
00:49 linagee (goes app->log return an Mojo::Log object?)
00:49 jberger you don't need a new one there is already one there
00:49 linagee s/goes/does/
00:49 linagee wait wait, let me guess. :)
00:49 linagee app->log->path('/var/whatever');
00:50 jberger linagee: how else would app->log->debug('tada') work?
00:51 * jberger just read the source for Perl::Tidy
00:51 * jberger cannot unsee
00:52 jberger I also want it to stack consecutive open and close tokens but to stack the close tokens on a new line
00:53 jberger it can't seem to do that
00:53 jberger my OCD is screaming!
00:53 jberger the rest of me wants it to shut up, but it can be really loud
00:54 linagee jberger: was it Perl::Tidy very tidy? :)
00:54 linagee if you run perl tidy on perl tidy, does a black hole open?
00:56 jberger linagee: its not that its untidy per-se, its huge!
00:56 linagee http://cpansearch.perl.org/src/SHANCOCK/Perl-Tidy-20140711/lib/Perl/Tidy.pm
00:56 linagee yikes. it *is* huge!
00:57 linagee jberger: and_all_their_sub_names_are_sufficiently_long {...}
01:00 * linagee runs perltidy on perltidy. it worked! :-D
01:02 linagee jberger: perltidy is *only* 30,203 lines. :-D
01:02 sri haha
01:02 * linagee runs meld against Tidy.pm and Tidy.pm.tdy (the output)
01:02 linagee aha! it found some things!
01:03 jberger I bring that up because I was going to see if I could implement my OCD and submit a pr, but I don't think I want to try anymore :(
01:03 sri the thing i like most about Go is that it has a formatter built-in
01:03 sri jberger: try it! i want that too!
01:03 linagee Tidy.pm, line 462. They should have put $rexpansion on the next line!!!!
01:03 jberger sri: but what if it and my OCD don't agree?!?
01:03 sri jberger: YOU CAN DO IT!
01:04 jberger AAAAAaaAAAAAAAAAAAAAAAAAaaaAa
01:04 linagee perl tidy is saying to have equals for two consecutive variables lined up???
01:04 linagee my boss was like, "don't do that!"
01:05 woz joined #mojo
01:05 linagee its pretty weird though. did the developer of perltidy never think to run it against their own code???
01:06 linagee that would have been the first thing I'd do. :)
01:06 sri at the end of the day, the only big perl code bases i know that look clean use perltidy
01:06 linagee sri: but perltidy itself isn't even tidy. not eating their own dogfood. :)
01:07 sri linagee: the code is clean, just not well abstracted
01:10 franzkafka sri, if I get this right, I have a subroutine in my plugin, I should do sub foo { my ($plugin, $c, $args) = @_; }, right?
01:10 linagee ack. why is perltidy putting all sorts of spaces in my code. :( I know that ([]) makes logical sense. it does not need to be ( [] )
01:10 franzkafka I have $self where plugin is at now. But for best practices I should replace that with $plugin.
01:10 jberger sri: I agree, at least in a multi-developer world, which is why I wanted to use it at $work
01:10 sri linagee: you have to configure it
01:11 sri linagee: this is what we use https://github.com/kraih/mojo/blob/master/.perltidyrc
01:11 meredith ^ i like to look at other big projects' .perltidyrc for hints on what options to check out first
01:11 linagee sri: without configuring it, its like letting an OCD maniac loose on your code. lol.
01:11 * sri has been tweaking that .perltidyrc for years
01:11 franzkafka sri, thank you for sharing your perltidyrc!
01:11 linagee sri: we use 3 spaces, not 4 spaces for indentation. :)
01:12 sri Oo
01:12 linagee sri: do you have perltidy running every 2 seconds against the file you're working on or something? lol.
01:12 franzkafka out of curiousity, what made you land on 2 spaces rather than the standard 4?
01:12 sri i can understand 4... but 3... that's sick
01:12 jberger because 2 is correct and 4 is not
01:12 sri :D
01:12 jberger 3 is right out
01:12 linagee 3 is correct and 2 and 4 are not. :)
01:13 jberger actually I always used 2, so when I came to mojo that was comforting for me
01:13 linagee set shiftwidth=3  \n   set softtabstop=3
01:13 franzkafka jberger, I have always used 4, and most programmers I see also use 4 (looking at vim dotfiles anyway), and most code examples (even in Modern Perl book) use 4.
01:13 franzkafka 4 seems to be the standard.
01:13 sri i started out with 4, and switched to 2 after doing more and mroe ruby work
01:13 meredith heh, i was about to say the same
01:14 meredith ruby popular practice seems to be 2
01:14 franzkafka sri, ah, that makes sense. I use 2 now, just because I like it and it does look  better to me. I never used 2 until I stumbled upon Mojolicious, where everyone seems to use 2.
01:14 jberger franzkafka: when I started programming, I didn't use a fancy editor, I used gedit. I had to hit space twice to get two, one wasn't enough, four was too many keystrokes
01:14 linagee 3 is our standard. :)
01:14 linagee the water runeth uphill
01:14 sri yea, i think i would have liked 2 before too, but 4 was the convention...
01:15 franzkafka jberger, that is a really good reason (less keystrokes)
01:15 linagee (and the toilets flush backwards)
01:15 jberger but more than that, 2 is enough to see the indent, with 4 deeply nested structures are too far right
01:15 franzkafka linagee, I've never heard of anyone using 3 :DS
01:15 jberger 3 is an abomination
01:15 * jberger sets franzkafka on fire
01:15 linagee jberger: blasphemer!
01:16 jberger oh, it was linagee, right
01:16 * jberger sets linagee on fire too
01:16 sri 3 could be hipster
01:16 linagee there are people who use literal tabs? ackkkkkk.
01:16 * jberger lets franzkafka burn still, he probably earned it in the past couple weeks anyhow
01:16 linagee yuck
01:17 linagee jberger: what would you do to someone who used literal tabs?
01:17 * jberger looks for his flamethrower
01:17 sri i get tabs, it's saving a few bytes
01:17 jberger purl: mongolian cluster fuck
01:17 purl baise mongole de  faisceau
01:17 linagee sri: that's just dumb.
01:17 sri sure it's dumb, but i get it
01:17 linagee sri: let minification take care of saving bytes. code should be as readable as possible.
01:18 sri you can configure a modern editor to display tabs as whatever you like best
01:18 jberger sri: that is perhaps the best argument
01:18 sri i wouldn't do it, but i get it
01:19 meredith one of my jobs is working with one other guy who uses komodo, and i just tried to work within his style for a while, and after a few rounds of analyzing his diffs where they touched aligned columns i finally figured him out: hard tabs at 4-space stops
01:19 linagee sri: when you say modern editor, do you mean vi? :)
01:19 * sri has used vim, textmate, textmate2, sublime and atom
01:20 linagee sri: and which do you like best?
01:20 sri the original textmate i guess, but that one is dead
01:21 sri now it's atom for everyday editing and vim for quick hacks
01:21 * linagee brings out the languages where spaces are significant and there are no end of line semicolon.
01:21 * jberger has escaped python
01:21 jberger \o/
01:21 sri \o/
01:22 Grinnz can you escape python with a backslash?
01:22 linagee \o/;DROP TABLES;
01:23 jberger btw, I wrapped most of a rather giant HTML::Mason code base into Mojolicious in just this last week
01:23 linagee little bobby tables we call him
01:23 franzkafka btw, just wanted to let you know sri, I convinced this team to use Mojolicious instead of node.js :D
01:23 franzkafka Thank you everyone for your input on that one!!
01:23 sri \o/
01:23 jberger franzkafka++
01:23 jberger wow, what was the tipping point?
01:24 sri i think you mean io.js! ;p
01:24 linagee franzkafka: I have coded both. what were the pros/cons?
01:24 * jberger guesses the community fracture
01:24 franzkafka Thus the reason I am writing a Mojolicious plugin for Orchestrate now.
01:24 linagee you can still use sync a lot more often in perl than you can in node.js?
01:24 franzkafka jberger, you are correct. That was the biggest thing really.
01:24 franzkafka jberger, Plus I showed them Mojolicious and they were all like, "This is Perl? Really?"
01:25 tbushell joined #mojo
01:25 franzkafka They all pretty much figured I was trying to get them to work with CGI
01:25 jberger franzkafka: I still mean to write/give a talk entitled "Javascript: The Perl Parts"
01:25 franzkafka jberger, let me know when you do. I would be really interested in watching that.
01:25 jberger maybe for YAPC::NA
01:25 sri that sounds fun
01:26 jberger watch the Javascript: The Good Parts and try to keep yourself from screaming when he talks about putting up with all the crap because of Javascripts good closures
01:26 * Grinnz uses literal tabs, set to 4 spaces in the editor :P
01:27 jberger PERL HAS HAD THAT FOR DARN NEAR 20 YEARS
01:27 Grinnz heh
01:27 Grinnz to be fair, javascript is where closures became populr
01:27 jberger and we don't have to do this to create a scope: (function(){ ... code goes here })()
01:27 Grinnz :P
01:28 jberger Grinnz: I disagree
01:28 jberger javascript might be where the rest of the world found them
01:28 jberger and thus: Javascript: The Perl Parts
01:28 Grinnz thats what i meant by popular ;)
01:30 linagee if you use sync code in perl, will it just make everyone's requests wait?
01:30 * linagee inserts blocking code into IRC. everyone wait for 100 years while my read/write process has finished!
01:30 Grinnz unless its in a forked process
01:36 franzkafka I would imagine you don't want to return errors on register in a plugin. Is that accurate?
01:36 franzkafka The plugin requires an API key.
01:42 sri https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/Config.pm#L48
01:47 rem_lex|pivo joined #mojo
01:54 linagee wtf? io.js? sorry,I saw the above, but I just saw it on slashdot. people are forking? wtf?
01:54 Grinnz yeah, just die if you need to
01:54 * linagee dies. thank you for your permission. :)
01:54 Grinnz lol
01:56 linagee Uber is using node.js? (and now io.js?)
01:56 Grinnz yeah theres drama in node.js
01:56 Grinnz drama in docker
01:56 linagee Grinnz: ah. also, I have some news for you. using Java is almost unavoidable if you have an Android app. :(  (unless you use C#/xamarin or have a webview "app")
01:57 Grinnz yeah i can see where Java is a good choice for phone apps
01:57 linagee (or use javascript for cross mobile)
01:57 Grinnz web apps also can be made into pretty nice phone apps, but getting permissions is harder that way
01:58 linagee I learned how easy it is for management to say "we want Android AND iPhone please" right in the middle of development.
01:58 Grinnz yeah, we got that memo about a month ago.
01:58 linagee so freaking easy for them to say this. SOOOOOOOOOOOOOOO....(.......) much time involved if you don't have a framework that makes that easy
01:58 Grinnz "hey guys, so, we want you to build a phone app next year"
01:59 linagee (nearing 200%. maybe something less because you'd have an idea of what it is. but then that's also 200% development effort, 100% of the time for each revision.)
01:59 linagee Grinnz: there is a guys? lol.
01:59 Grinnz they're outsourcing the current phone app, since none of us have any mobile dev experience
01:59 linagee Grinnz: for me its just me
01:59 Grinnz and that
01:59 Grinnz that's probably going worse than if we wrote it
02:00 linagee like, "do fancy Perl stuff, SQL stuff, mobile stuff, Borland C++ stuff please. and have it on our desk tomorrow."
02:00 Grinnz http://xkcd.com/1425/
02:00 linagee (at a wage that's less than a california or new york programmer too, please.)
02:01 Grinnz well. california and new york are expensive :)
02:01 linagee Grinnz: fsck that.
02:01 purl hmmm... fsck that is NASTY.
02:01 Grinnz i'm luckily not quite IN new york
02:01 linagee Grinnz: those people's choices for living there.
02:01 Grinnz but close enough that it's expensive.
02:01 linagee Grinnz: I want the CA/NY wage and to work remotely.
02:01 Grinnz hah
02:01 Grinnz don't we all..
02:01 purl I don't!
02:01 Grinnz well why not
02:01 Grinnz tell us purl
02:02 linagee that xkcd is awesome btw. :)
02:03 linagee this is what I would be thinking: mechanical turk for the proof of concept. OpenCV for the long term penny pinching.
02:05 linagee btw, the "I want to know if the user is in a National Park" is only because of BILLIONS of dollars of investment in GPS satellites and GIS park maps.
02:05 linagee (and mobile phone design, and mobile phone networks, and internet networks, and server hardware engineering....)
02:14 jberger At $oldjob they have this weird framework
02:15 jberger and the older ba, who understands what things are easy or hard in a standard framework had no idea how to estimate how hard things were in this
02:15 jberger caused all kinds of trouble
02:15 jberger some things that should have been very hard would come almost for free
02:16 jberger then some things that should be easy were almost impossible
02:16 Grinnz jberger, so... this framework was PHP?
02:16 Grinnz :)
02:16 linagee I told the boss 40-60 hours to develop a REST API against our systems.
02:17 jberger a pricing platform for python, being used for lots more than just proving
02:17 linagee then I just developed something that can scoop out any data from our DB, filtered the inputs before it gets to there, and had it done in like 4 hours. lol.
02:17 jberger s/proving/pricing/
02:17 jberger linagee: so what did you do with your week off?
02:18 linagee everyone else "what about our insane DB naming, relations, etc?" me: "we'll just document the hell out of it for other programmers and let them figure it out" :)
02:18 linagee jberger: spent it in #mojo. lol.
02:18 linagee jberger: actually no. spent it on the other 4 or 5 projects queued up. :(
02:19 jberger as usual
02:19 jberger purl: botsnack
02:19 purl :)
02:21 linagee purl: eval: print "hello world"
02:21 purl linagee: i'm not following you...
02:22 linagee purl: supybot?
02:22 purl linagee: i don't know
02:22 linagee purl: version?
02:22 purl wish i knew, linagee
02:22 linagee lol
02:23 asarch joined #mojo
02:28 sri no playing with the bots
02:28 jberger purl: excuse
02:28 purl jberger: Feature not yet implemented
02:30 linagee purl: execute ^@q^H^@^@^@^@^@^@g^D^@^@z^F^@^@<82>^G^@^@^_^A^@^@2
02:30 purl linagee: what?
02:32 sri seriously, just /msg purl
02:50 wim joined #mojo
02:54 woz joined #mojo
02:57 klapperl joined #mojo
03:04 Adura joined #mojo
03:17 noganex_ joined #mojo
03:29 wim joined #mojo
03:44 sri still makes me laugh that weaken is actually a bottleneck in Mojo::DOM::HTML
03:45 sri takes 8s to parse the entire html5 spec, and 1.1s are spent in Scalar::Util::weaken
03:48 sri (this page https://html.spec.whatwg.org)
03:50 sri 324885 nodes and 143771 elements
03:51 akhasanov joined #mojo
04:06 Grinnz heh
04:17 franzkafka Is there any way in a plugin for a subroutine to know what helper called it?
04:20 good_news_everyon joined #mojo
04:20 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/SfoATw
04:20 good_news_everyon mojo/master 643865a Sebastian Riedel: no need to parse whitespace twice
04:20 good_news_everyon left #mojo
04:34 franzkafka Actually, can a helper tell what it's own name is somehow?
04:36 franzkafka i.e.,   $app->helper( test => sub {say 'my name is: ' } ); which would print 'my name is test'
04:38 franzkafka this is what I get from caller(0): Mojolicious::Plugin::Orchestrate::__ANON__
04:40 meredith don't you know the sub's name right there as you assign it?  if you're trying to make a wildcard helper, it doesn't seem like a good idea
04:40 franzkafka meredith, why does that not seem like a good idea? I am trying to make dynamic helpers.
04:41 meredith why not a single helper accepting an arg?
04:41 preaction franzkafka: make a helper that makes other helpers
04:42 preaction $app->helper( test => build_helper( test ) ); sub build_helper { my $name = shift; return sub { say "my $name" } }
04:42 preaction see also: the curry module
04:42 preaction <3 curry. it's so useful and simple it should be core
04:43 preaction maybe one of the Sub::Util stuff...
04:43 woz joined #mojo
04:43 meredith double-checking what orchestrate is here, heh
04:44 meredith is this something akin to having a list of tables and you want a helper for each table?  i'd do what preaction said, plus fetching the list at startup, instead of a "by what name am i being called?" sort of magic
04:46 franzkafka meredith, you instantiate the plugin like so: http://paste.scsys.co.uk/451178
04:47 meredith so you want a helper for each collection?
04:47 franzkafka meredith, after doing so, I would like get, put, del, etc methods on each collection... eg, $app->game->get
04:47 franzkafka Right now I have $app->game(method => { args} ); and it works, but I have no idea what collection it is in the subroutine that gets called.
04:47 franzkafka where method is get, put, etc
04:47 meredith you have the list, so as you pass over that list and install each helper, you do have its name.
04:48 meredith you use it inside the sub so it closes over the helper name
04:48 franzkafka Here's my register: http://paste.scsys.co.uk/451179
04:48 preaction why not just $app->db->game->get()?
04:49 franzkafka preaction, not a bad idea. What do you guys suggest on this as easiest/best to use?
04:49 preaction so then future archaeologists know that it's accessing the db
04:49 franzkafka Because I am sending this to the Orchestrate team so there's a Mojolicious plugin for Orchestrate.
04:49 preaction definitely $app->db->... then
04:50 franzkafka That they can throw on their site. Therefore, I don't want the code to be embarrassing.
04:50 preaction so, nested helpers
04:50 franzkafka ok, I am going with nested helpers then.
04:50 franzkafka not $app->game, but $app->db->game then?
04:50 franzkafka ok
04:50 preaction you might consider basically copying Mango's API
04:51 preaction i mean, since it's essentially a cloud-based MongoDB
04:52 franzkafka actually, perfect
04:52 franzkafka thank you preaction!
04:52 franzkafka though I think I could just do $app->collection('game')->get/put/whatever
04:52 preaction since Mango's basically in limbo, it could give users a quick and easy upgrade path
04:53 franzkafka With Orchestrate you don't have databases, just collections.
04:54 preaction right, and Mango has a "default db", which means you can just work with collections
04:55 meredith i definitely agree with something more like ->collection('game'), it's low-surprise
04:57 franzkafka Hm, I think you're right preaction. Maybe I should just base this on Mango and not write a Mojolicious::Plugin::Orchestrate
05:00 preaction humph. i'm building a pod->html thing for my static site app, but all my pod needs to be run through Pod::Weaver first...
05:01 good_news_everyon joined #mojo
05:01 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/h-lz8Q
05:01 good_news_everyon mojo/master 7b379d4 Sebastian Riedel: fixed whitespace bug in Mojo::DOM::HTML
05:01 good_news_everyon left #mojo
05:04 sri franzkafka: looks like you want to write an orchestrate client, and wrap it in a plugin afterwards
05:05 sri like preaction said, this is no different than Mango
05:05 sri or even minion
05:06 sri https://github.com/oliwer/mango
05:29 franzkafka The only selfie I have ever awkwardly taken: http://i.imgur.com/4tE4UTL.jpg
05:30 franzkafka Be jelly sri, the shirt is awesome
05:31 franzkafka I'm somewhat kicking myself in the ass for not getting the pink one though
05:36 sri :D
05:36 * sri is jelly
05:38 franzkafka sri, two things that would be awesome on spreadshirt: a sticker for my laptop, and a shirt small enough for a 5 year old.
05:39 franzkafka Most especially the laptop sticker though
05:42 sri yea, sucks that they don't have stickers atm
06:05 franzkafka Hey, are there any benchmarks Mojolicious vs. node.js?
06:06 sri benchmarks for what?
06:06 Adura Coolness.
06:06 purl coolness is an essential part of Perl programming.
06:06 preaction purl, botsnack
06:06 purl :)
06:07 franzkafka "Also have what is the speed difference with perl vs nodejs "
06:08 franzkafka Question from a team member. I see some benchmarks on TechEmpower, but I hear those benchmarks are BS
06:08 cfedde benchmarks are BS
06:08 cfedde mostly
06:09 franzkafka yeah, I hate this question
06:09 franzkafka I'm basically leaving him hanging
06:09 franzkafka I  don't know, nor do I really care man
06:10 preaction i thought joel was still working on those techempower benchmarks
06:10 cfedde normally All I get is "perl?  people still use that?"
06:10 sri i think they use Mango now, so pretty awful for benchmarking
06:11 franzkafka cfedde, that is exactly what I got at first.
06:11 franzkafka cfedde, they were really amazed when I showed them Mojolicious and DBIx::Class
06:12 franzkafka oh well, I'm ignoring the question
06:12 franzkafka haha
06:12 preaction i've easily managed thousands of rps on hypnotoad
06:12 meredith were they looking at a specific framework /on/ node.js?
06:13 sri haha, the express.js situation is funny too
06:14 cfedde of course I react almost exactly the same way when I see people using PHP.
06:14 sri author basically abandoned the project, new maintainer put quite a bit of work into it, old maintainer sells frmamework to some company
06:15 sri (some company = company rumored to be the driving force behind io.js)
06:16 * sri kinda gets the feeling joyent is going under
06:18 sri https://github.com/strongloop/express/issues/2264 # drama!
06:20 sri there's soooo much more actually :)
06:20 sri remember that one time nodejitsu tried to take over npm?
06:21 sri https://gist.github.com/mikeal/9242748
06:22 sri ok, enough drama for today ;p
06:25 sri or maybe just a little bit more
06:26 sri did you know node.js has hard memory limits?
06:26 sri default is like 1gb i believe, and you can raise it to 2gb
06:26 preaction as in, compiled-in?
06:26 sri yea
06:26 preaction or more like JVM's memory limits?
06:27 preaction just pass a flag to the jvm and it'll take as much memory as you want
06:27 sri or rather the V8 part of node.js
06:27 sri https://code.google.com/p/v8/issues/detail?id=847
06:27 sri when you're targeting browsers it makes sense
06:28 preaction wtf is with mark-and-sweep? i'd rather have it done fast than done right...
06:29 sri https://github.com/joyent/node/wiki/FAQ#what-is-the-memory-limit-on-a-node-process
06:29 sri "...but it is recommended that you split your single process into several workers if you are hitting memory limits."
06:29 preaction that's crazy...
06:29 sri WEBSCALE
06:29 purl hmmm... WEBSCALE is an anagram of claw bees
06:31 sri franzkafka: that one might be an argument to bring up :)
06:32 woz joined #mojo
06:33 cfedde https://www.youtube.com/watch?v=b2F-DItXtZs
06:33 sri nonono
06:33 sri https://www.youtube.com/watch?v=bzkRVzciAZg
06:34 sri "Node.js Is Bad Ass Rock Star Tech"
06:35 cfedde yup.
06:37 franzkafka sri, what would be the memory limit on Mojolicious? Hypnotoad lets say.
06:37 sri no limit
06:37 sri perl is a general purpose language
06:41 sri (side note, i don't hate node.js, every now and then i use it myself and they had a lot of good ideas i've stolen)
06:44 * sri still has a feeling hapi.js will become the dominant node web framework
06:49 franzkafka sri, the drama in node is what's convincing this team not to go with it :D
06:51 preaction yay! we're number 2! we're number 2!
06:58 amon joined #mojo
07:15 dotandimet joined #mojo
07:19 irq joined #mojo
08:08 Adura Oh Deborah Kagan... haha.
08:21 woz joined #mojo
08:27 basiliscos joined #mojo
08:39 Vandal joined #mojo
08:44 sugar joined #mojo
08:48 franzkafka Is this the correct way to append to a URLs path? $url->path($url->path.'/foo/bar');
08:51 tempire if $url has a trailing /, then $url->path("foo/bar")
08:55 dotandimet joined #mojo
09:00 wim joined #mojo
09:01 franzkafka Thanks tempire :)
09:01 franzkafka cleaner = better
09:01 franzkafka btw, tempire, your mojocasts are awesome. You're a natural at training.
09:02 franzkafka And I stole your dotfiles and everyone's always asking me for my dotfiles now.
09:05 sh4 joined #mojo
09:23 sugar_ joined #mojo
09:35 franzkafka OK, so with Mojo::Base you don't declare a new method, right? I guess I could use SUPER, but I'm just trying to figure out how to croak if a param is not specified.
09:35 franzkafka Do I need to use SUPER and have a validation subroutine?
09:53 wim joined #mojo
09:55 Eke- joined #mojo
10:02 wim joined #mojo
10:04 franzkafka I have this: has url  => sub { return Mojo::URL->new($_[0]->base_url)->userinfo($_[0]->secret) };
10:05 franzkafka nothing, forget it
10:09 franzkafka I notice that if I do this in a sub my $url = $orchestrate->url and then add to the path like so, $url->path('/foo/'), then call another sub which has my $url = $orchestrate->url; $url->path('/bar/'), $orchestrate->url's path is now /foo/bar
10:09 franzkafka I.e., it adds to the attribute of the object, not what I want.
10:10 woz joined #mojo
10:10 franzkafka I am now just doing a my $url = Mojo::URL->new($orchestrate->base_url)->userinfo($orchestrate->secret) in every sub.
10:11 franzkafka Is there any way to make attribute immutable? I don't want my method modifying it.
10:11 sugar_ joined #mojo
10:29 sugar__ joined #mojo
10:31 franzkafka A small gripe: Mojo::UserAgent says get returns 'resulting Mojo::Transaction::HTTP object'. In the example I see my $tx = $ua->post... and then $tx->success, yet I don't see success documented in Mojo::Transaction::HTTP.
10:32 franzkafka Ah, inherits methods from Mojo::Transaction. There we go, my bad.
10:36 inokenty joined #mojo
10:36 sugar joined #mojo
10:48 wim joined #mojo
10:50 popeshoe joined #mojo
10:51 franzkafka Agg, I want this accessor to be ro dammit
10:56 wim joined #mojo
11:17 woz joined #mojo
11:20 dotandimet joined #mojo
11:39 alnewkirk joined #mojo
11:40 wim joined #mojo
12:17 Eke- joined #mojo
12:53 jberger franzkafka: a couple things
12:54 jberger yes I have helped tech empower with the perl frameworks, but really only to the point of getting them working
12:54 jberger round 10 should be out soon
12:55 jberger I have been meaning Rio go back and add a pg backend test to it also
12:55 jberger s/Rio/to/ # sigh
12:56 jberger as far as ro accessors, go ahead and use Moo if Mojo::Base doesn't have what you need
12:56 jberger <3 Moo
13:00 franzkafka I too <3 Moo, but I think I will just stick with creating a new $url in each sub.
13:00 franzkafka I'm nearly done I think.
13:00 franzkafka And I heard somewhere that TechEmpower's benchmarks are not reliable, but I can't really recally why they're not.
13:04 jberger franzkafka: actually the node guys weren't happy about them because they stress test with wrk which runs the servers to capacity
13:04 jberger their argument is that JavaScript should not be run at red line because it needs to garbage collect,
13:05 jberger they argued that the TE test should be run at 50% cpu
13:06 jberger my reply on the irc channel was, sure we can limit you to 50%, and my tests will blow yours away
13:07 jberger the framework has to suffer with limitations of the platform
13:07 jberger the hardest thing about the TE benchmarks is that you can't optimize on their hardware
13:08 jberger though they have made great strides in the last year to make it easier to contribute
13:11 franzkafka jberger, do you consider their benchmarks useful? I notice node out-benchmarks Mojolicious.
13:18 irq joined #mojo
13:19 denis_boyun joined #mojo
13:20 jberger franzkafka: when I started helping them, none of the perl benchmarks ran!
13:21 jberger I don't especially think that benchmarks help anything tbh, but I sure didn't want to see Mojo at the bottom marked as did not pass
13:21 franzkafka yeah, I understand that!
13:21 franzkafka Especially since it seems people make their choices by these benchmarks.
13:22 jberger some seem to
13:23 jberger I would much rather choose a language I trust and a framework that makes things easy
13:37 woz joined #mojo
13:57 franzkafka If I do this: $t->tx(POST => 'http://example.com' => form => {a => 'b'});, does that actually do the POST? I just want to build the Mojo::UserAgent::Transactor object then do a $ua->($tx) or something to actually do the HTTP request.
14:01 franzkafka I.e., after I build my Mojo::UserAgent::Transactor object, how do I perform the request?
14:03 franzkafka Ah, start
14:03 franzkafka I gotta stop asking questions
14:36 ispyhumanfly joined #mojo
14:36 ispyhumanfly hi all
14:37 ispyhumanfly hi sri
14:46 lipizzan joined #mojo
14:57 mattastrophe joined #mojo
15:00 wim joined #mojo
15:01 jberger franzkafka: you shouldn't need a transactor, you need a transaction
15:02 jberger franzkafka: http://mojolicio.us/perldoc/Mojo/UserAgent#build_tx
15:14 zivester joined #mojo
15:14 yko joined #mojo
15:15 dod joined #mojo
15:26 akhasanov joined #mojo
15:58 wim joined #mojo
16:34 wim joined #mojo
16:36 woz joined #mojo
16:39 * jberger is making good progress on: https://github.com/jberger/Mojo-WebService-NoIP
16:40 jberger I wish there was some easy way to prevent repeated failing attempt (as the api docs request)
16:41 jberger but that would involve saving state somehow and I didn't want to go there :/
16:45 akhasanov joined #mojo
16:53 sugar_ joined #mojo
17:02 wim joined #mojo
17:05 basiliscos joined #mojo
17:14 autarch joined #mojo
17:15 autarch is there a good pattern for having controller subs abort execution? specifically, I'd like to exit subs early if a user isn't logged in. It'd be a lot easier to use an exception for this than to have every sub check the return value of $self->_is_logged_in and then return that value if it's true.
17:15 autarch in Catalyst I'd use abort() so I'm wondering if Mojo has something similar
17:16 sri that pattern is incompatible with non-blocking operations, so we don't have it in core
17:16 autarch ah, that makes sense
17:17 sri https://gist.github.com/kraih/6602913
17:17 sri it's possible though
17:17 sri if your app is limited to blocking operations
17:17 autarch aha, that hook thing is what I was looking for
17:17 autarch thanks
17:18 sri you might like this better though http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Under
17:19 autarch ah, that's like chained routes in Catalyst?
17:19 sri ye
17:19 autarch yeah, that's probably less gross
17:21 sugar_ joined #mojo
17:21 autarch thanks again
17:23 autarch if the first part of the route (what other things are under) returns the value of $c->redirect_to does that abort the rest of the routing?
17:23 autarch or do I call $c->redirect_to and then return false?
17:24 crab redirect and return false
17:31 good_news_everyon joined #mojo
17:31 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/Wbuwpg
17:31 good_news_everyon mojo/master 65f80cd Sebastian Riedel: more diverse examples for under
17:31 good_news_everyon left #mojo
17:35 good_news_everyon joined #mojo
17:35 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/LwTiFQ
17:35 good_news_everyon mojo/master ca8de7f Sebastian Riedel: less neutral names
17:35 good_news_everyon left #mojo
17:46 jamesaxl joined #mojo
17:48 johnnydepp joined #mojo
17:48 basiliscos joined #mojo
17:48 autarch left #mojo
17:58 tencendur joined #mojo
18:13 basiliscos1 joined #mojo
18:19 Eke- joined #mojo
18:25 woz joined #mojo
18:26 sugar_ joined #mojo
18:34 bowtie joined #mojo
18:34 jberger http://irclog.perlgeek.de/pdl/2014-12-06#i_9768031
18:35 good_news_everyon joined #mojo
18:35 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/ck9HIg
18:35 good_news_everyon mojo/master 9381472 Sebastian Riedel: more diverse examples
18:35 good_news_everyon left #mojo
18:39 sri heh
18:40 wim joined #mojo
18:45 jberger sri: so it seems that I cannot cause one useragent transaction to not redirect while all the others should, am I correct?
18:45 jberger if so is that functionality that anyone else might ever want?
18:48 sri you can just use two user agents
18:49 jberger sri: yeah, that's the simplest way
18:58 jberger https://github.com/jberger/Mojo-WebService-NoIP/blob/master/bin/mojo_noip#L19,L28
19:01 jberger ^^ the quick way
19:04 woz joined #mojo
19:16 neyasov__ joined #mojo
19:43 wim joined #mojo
19:50 sri jberger: that looks horrible
19:50 sri how do you make sure one user agent doesn't destroy the keep alive connection of another clone?
19:51 jberger hmmm, I suppose you're right
19:51 sri *if* it works correctly you're lucky or depending heavily on implementation details
19:51 jberger blast
19:52 wim joined #mojo
19:53 jberger is it safe to reuse the transactor? basically I want to keep the user agent name the same
19:53 jberger but make no redirects for this one transaction
19:55 sri the whole thing does not look particularly good
19:55 jberger :(
19:57 sri $tx->res->content->on(body => sub { shift->headers->remove('Location') })
19:57 sri if nothing else helps
19:58 jberger ?
19:58 sri to prevent a redirect
19:59 sri there's a million ways to prevent a redirect with events
19:59 sri if having two user agents is really too much for you
19:59 * jberger would be happy to learn
20:01 sri my $tx = $ua->max_redirects(10)->build_tx(...); $tx->res->content->on(body => sub { shift->headers->remove('Location') }); $ua->start($tx);
20:01 sri http://mojolicio.us/perldoc/Mojo/Content#body
20:02 jberger a Location header is always how a redirect is generated?
20:02 sri https://github.com/kraih/mojo/blob/master/lib/Mojo/UserAgent/Transactor.pm#L78
20:03 sri you can also change the status code
20:03 sri $tx->on(finish => sub { shift->res->headers->remove('Location') });
20:03 sri should work too
20:04 sri $tx->on(finish => sub { shift->res->code(200) });
20:05 jberger ^^ looks more understandable
20:05 sri $tx->->res->on(finish => sub { shift->headers->remove('Location') });
20:05 sri $tx->->res->on(finish => sub { $_[0]->code(200) if $_[0]->is_status_class(300) });
20:05 sri million ways
20:07 sri and tons of events to hook into
20:07 sri MOJO_EVENTEMITTER_DEBUG=1 mojo get -M HEAD mojolicio.us
20:12 wim joined #mojo
20:21 zivester joined #mojo
20:23 franzkafka Do you need to know the structure of a json object to parse it?
20:27 preaction no
20:27 preaction there's no ambiguity in strictly-spec-following json
20:27 preaction ... i think
20:28 good_news_everyon joined #mojo
20:28 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/4Et0XA
20:28 good_news_everyon mojo/master 84a9d0a Sebastian Riedel: removed obsolete version checks
20:28 good_news_everyon left #mojo
20:28 preaction heh, i was just wondering why that version check was in PODRenderer
20:30 sri it used to be an optional dep
20:30 sri then it got added to Makefile.PL as a hard dep, and i forgot the old check
20:30 akhasanov joined #mojo
20:32 sri maybe i thought it would serve documentation purposes now or so...
20:44 bwf joined #mojo
20:47 jamesaxl joined #mojo
20:49 irq joined #mojo
20:52 woz joined #mojo
20:58 sri oh, release date for postgres 9.4 is dec 18
21:01 wim joined #mojo
21:07 wim joined #mojo
21:16 wim joined #mojo
21:39 franzkafka How do you test if there's a link in the last td of a table? This doesn't work: $dom->at('div.PagingRow > table > tbody > tr:first-child > td:last-child > a[href]')
21:39 franzkafka There is only one child of tbody, but tbody > tr > td:last-child didn't work, so I tried td:first-child
21:39 franzkafka err tr:first-child
21:40 preaction why not div.PagingRow table tr:first-child td:last-child
21:40 preaction why all the >?
21:41 preaction if there is only one row, why a table at all?
21:41 franzkafka OK, why did that work and mine with the >
21:41 franzkafka 's did not
21:41 franzkafka damned enter key
21:41 preaction because > is "child" where as " " is descendant
21:41 franzkafka I like your way better anyway preaction
21:41 preaction > is very strict and usually never what you want unless you're doing nested things
21:42 preaction and table should _never_ _ever_ _ever_ be nested
21:42 franzkafka Ahh > only for nested, gotcha
21:42 franzkafka thanks preaction :)
21:42 preaction ul.top > li <- if you have <ul class="top"><li><ul><li>, this will match the outer li, not the inner li
21:43 preaction that kind of situation is the main use-case for >
21:43 preaction without the ">", it would match both li elements
21:43 preaction CSS selectors • Tutorial at http://css.maxdesign.com.au/selectutorial/ • Spec at http://www.w3.org/TR/css3-selectors/ • Try them out at http://gallery.theopalgroup.com/selectoracle/
21:44 preaction (from #css on freenode)
21:44 preaction sorry, better ones: Tutorials: http://css.maxdesign.com.au/selectutorial http://flukeout.github.io • Spec: http://www.w3.org/TR/css3-selectors • Try yours out: http://gallery.theopalgroup.com/selectoracle • Find yours: http://selectorgadget.com
21:45 preaction flukeout is fun
21:45 preaction and the selectorgadget is awesome if you have chrome
21:45 preaction (i've got a lot of cleanup to do on the #css bot...)
21:45 preaction flukeout is the best thing if you're just learning about css selectors, really
21:47 sri selectors are pretty easy to learn, just some pseudo classes are a bit tricky
21:53 wim joined #mojo
22:06 wim joined #mojo
22:13 franzkafka In the documentation for Mojo::URL query (http://mojolicio.us/perldoc/Mojo/URL#query) what exactly is the comment above each line supposed to represent?
22:14 franzkafka If it is supposed to represent what the resulting URL will look like, then there is an error here: Mojo::URL->new('http://example.com?a=1&b=2')->query({a => 2, c => 3});
22:14 franzkafka It says: # "http://example.com?a=1&b=2&a=2&c=3"
22:14 franzkafka nothing
22:18 denis_boyun joined #mojo
22:20 preaction works for me
22:34 KCL_ joined #mojo
22:38 franzkafka no, I mean nothing as in ignore me
22:39 franzkafka Can someone help me understand what is going on here: http://paste.scsys.co.uk/451270
22:39 franzkafka in the for ( 1 .. page ) { } when I say the URL, I get one http://allgame.com/platform.php?id=2&amp;tab=games&amp;sort=title_ASC&amp;page=230
22:40 BeDa joined #mojo
22:40 franzkafka however, when I push to @urls and then loop at the end, I get hundreds of duplicates
22:41 franzkafka I could push if !$seen{$url}, but I don't understand why the for ( 1 .. $page ) { } loop only shows the URL once, then the for loop at the bottom has it hundreds of times in @urls.
22:41 preaction the for loop munges the URL every time through. not new urls each time
22:41 woz joined #mojo
22:42 preaction you only ever have one url
22:42 franzkafka I thought I was just replacing the page param in the for loop.
22:42 franzkafka I want page=1, page=2, page=3 .. page=230
22:42 preaction it does, and then you push a reference to @urls, but not a different reference, the same reference
22:42 franzkafka all other aspects of the URL stays the same.
22:42 preaction push doesn't magically take a snapshot of the object when you add it to the array
22:43 preaction you edit $url every time through the array, and then, at the end, you have hundreds of the same edited $url object
22:43 preaction you perhaps want my $page_url = $url->clone->query( ... ); push @urls, $page_url;
22:45 franzkafka well, here's my silly workaround: http://paste.scsys.co.uk/451271
22:46 sri listen to preaction
22:47 franzkafka thanks preaction, that worked beautifully :D
22:47 franzkafka sri, why preactions method over mine? They both work?
22:47 preaction @urls = map { $url->clone->query({ page => $_ }) } 1..$page # map is your friend
22:47 franzkafka sri, I am only skin in an attempt to understand
22:47 wk joined #mojo
22:47 sri performance
22:47 purl performance is not a big deal
22:48 * sri shoves purl down the stairs
22:48 franzkafka haha
22:48 franzkafka ok, for performance. thank you guys, it's working wonderfully now.
22:50 atom joined #mojo
22:50 atom Is there a Mojo book coming out that will be as awesome as the Apress Catalyst book?
22:50 atom cuz non-Mojo::Lite is driving me CRAZY!
23:06 sri optimizing Mojo::DOM gets harder and harder
23:08 sri i have a feeling that there is something that can be done about the dual use of $ATTR_RE... but i just can't think of it
23:08 sri https://github.com/kraih/mojo/blob/master/lib/Mojo/DOM/HTML.pm#L10
23:20 atom If I just made a Mojo App .. not the Lite version
23:20 atom # Normal route to controller
23:20 atom $r->get('/')->to('example#welcome');
23:20 atom $r->get('/prototype')->to('prototype#index');
23:20 atom and just added that last line above
23:21 atom wouldn't that route to the Prototype.pm controller and the index action?
23:22 preaction it would route to MyApp::Controller::Prototype, i believe
23:25 denis_boyun joined #mojo
23:25 preaction want to add Pod::Weaver to the PODRenderer? here's what I had to do to weave just some random POD I had: https://github.com/preaction/Statocles/commit/e48ed613b7a23d0da199e49b6e2b03b4c0f45996 (short story: i recommend against this...)
23:26 preaction i think i might be able to get this down because i don't care about the code parts, but ... still...
23:26 atom here is my "MyApp.pm" script called DemandMapper: http://pastebin.com/b6kLGuPt
23:26 preaction and your controller is DemandMapper::Prototype or DemandMapper::Controller::Prototype?
23:27 atom uhh... here's my controller:  http://pastebin.com/mpe4nVUu .... DemandMapper::Controller::Prototype
23:28 atom the First one was DemandMapper.pm
23:28 atom and I have a ./templates/prototype/index.html.eb
23:29 atom index.html.eb  http://pastebin.com/GUcRvhWE
23:29 atom if I goto httpL://myapp.com:3000/prototype/index
23:30 atom shouldn't that print out what's in ./templates/prototype/index.html.eb ??
23:51 sri eb or ep?
23:52 sri uh, there is no route for /prototype/index
23:58 akhasanov joined #mojo
23:59 woz joined #mojo

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