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

IRC log for #mojo, 2014-02-16

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

All times shown according to UTC.

Time Nick Message
00:00 bpmedley jberger_: What are you using to run the server?  daemon, prefork, hypnotoad?
00:00 jberger_ hypnotoad
00:00 purl ALL GLORY TO THE HYPNOTOAD!!!
00:01 jberger_ why wouldn't I use .. ALL GLORY TO THE HYPNOTOAD!!!
00:02 jberger_ hypnotoad: I'll try it
00:04 bpmedley 795 requests in 30.03s, 0.86MB read  <-- dual core box ... how many core do you have?
00:05 hypnotoad maybe ssd
00:07 bpmedley My hosting is ssd
00:07 jberger_ hypnotoad: actually slower
00:07 jberger_ not by much
00:07 bpmedley How many requests do you get?
00:08 jberger_ I think since the row is so tiny, telling it to filter is slower than just requesting everything over the wire
00:08 jberger_ but I did remove the _id hash lookup, since I don't need it
00:08 jberger_ ran several times, with the filter, the median was http://pastie.org/8737571
00:09 jberger_ sorry
00:09 jberger_ the median was 14510
00:09 bpmedley Very cool.  How many cores is your box?
00:09 jberger_ oh, that was the slower one, using the filter
00:09 jberger_ my best run is 15386
00:09 Stefan joined #mojo
00:10 jberger_ bpmedley: http://pastie.org/8737591
00:10 jberger_ 8 cores
00:10 jberger_ 2.6GHz
00:10 bpmedley Are you saturating your CPUs?
00:10 jberger_ core i7
00:10 hypnotoad node.js benchmark look similar https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/nodejs/hello.js#L105
00:10 bpmedley Nice
00:10 jberger_ 32GB ram
00:11 jberger_ I should watch to see
00:12 hypnotoad this fun, but need go, bye
00:12 jberger_ watching using htop, it looks like its about 60% of each core
00:12 jberger_ but it bounces around
00:13 jberger_ hypnotoad o/
00:13 bpmedley Nice.  We need to get them to update the mojo code.
00:14 jberger_ I wonder if it gets faster if I don't check err
00:15 bpmedley It would, not sure by how much.
00:16 jberger_ minor improvement
00:16 Gedge joined #mojo
00:18 bpmedley What do you get for /json?
00:20 jberger_ 51275
00:20 jberger_ though I somehow got 140 timeout errors
00:20 jberger_ don't know how that happened
00:21 bpmedley I get 30k json's ... I bet you can up your workers.
00:21 jberger_ bpmedley: what should I tweak?
00:22 bpmedley $ perl jberger_bench.pl prefork -w 4 -l 'http://*:8080'   <-- Baseline
00:22 bpmedley ./wrk -t 10 -c 10 -d 30s 'http://127.0.0.1:8080/json'   OR   ./wrk -t 20 -c 20 -d 30s 'http://127.0.0.1:8080/json'
00:22 jberger_ oh I'm just using stock hypnotoad
00:23 bpmedley prefork is easier to tweak from the cmd line, i think
00:23 jberger_ how many workers should I try?
00:23 bpmedley 12 - 16
00:23 purl -4
00:24 bpmedley Also, do you have a log directory or is the log going to STDOUT?
00:24 jberger_ haha prefork doesn't suppress logging
00:24 bpmedley That would make it faster still..
00:25 jberger_ hypnotoad just dumps it if it doesn't have a directory, right?
00:25 bpmedley export MOJO_MODE=production
00:26 bpmedley I believe so; as will prefork with that ENV var set, I believe.
00:26 bpmedley I get 37k json's
00:26 jberger_ 154k
00:26 jberger_ on json
00:26 bpmedley That's swank
00:26 bpmedley How many workers?  Are you sing "wrk"?
00:27 jberger_ that was 16 workers
00:27 jberger_ 20/20 on wrk
00:28 bpmedley How does top look?
00:28 jberger_ 163k in production mode, 154k was piping to /dev/null
00:28 bpmedley 163 / 34
00:28 purl 4.79411764705882
00:28 jberger_ when I ran htop it cut performance by about 10%
00:29 bpmedley I'm getting around 34k json
00:29 * jberger_ is retrying queries=30 with 16 workers
00:30 jberger_ 20k requests in 30s for queries
00:30 bpmedley Nice
00:30 jberger_ yeah, I like my box :-)
00:30 bpmedley Hosted or a feet warmer?
00:30 jberger_ laptop :D
00:31 bpmedley That's cool
00:33 drift joined #mojo
00:34 bpmedley http://pastie.org/8737619  <-- You should try this
00:36 Gedge joined #mojo
00:36 jberger_ I added a mojo_json route
00:37 bpmedley I see almost no difference in JSON::XS and Mojo::JSON.  What about you?
00:37 jberger_ me neither
00:38 jberger_ I wonder if it's the helper though
00:38 bpmedley Dunno
00:38 jberger_ helpers are AUTOLOAD
00:38 jberger_ I could try a microoptimization branch
00:39 bpmedley get '/jsonXS' => sub { shift->render(data => encode_json({message => 'Hello, World!'}), format => 'json') };  <-- About the same
00:40 jberger_ ok, well that was the question
00:40 bpmedley Have you usd apache much?
00:42 bpmedley Mojo::JSON is quite impressive.. :)
00:43 jberger_ Mojo::JSON is the fastest PP JSON
00:44 jberger_ microoptimization branch show no noticable gain
00:44 jberger_ I have used apache back in my joomla/drupal days
00:44 jberger_ never for anything serious
00:44 bpmedley I see.  Mojo just feels better than apache.
00:44 jberger_ no kidding
00:47 bpmedley How many json are you up to?
00:47 bpmedley I'm right at ~35k
00:47 jberger_ best is 169k
00:47 jberger_ hehe
00:48 bpmedley If I'm reading things right, that would scoot Mojo up quite a bit in the benchmarks.
00:48 jberger_ is their hardware similar
00:48 jberger_ its on the site somewhere
00:48 bpmedley As of Round 7, three Intel Sandy Bridge Core i7-2600K workstations with 8 GB memory each (early 2011 vintage) for the i7 tests
00:49 jberger_ so it is similar to what I'm using
00:49 bpmedley It would seem as such
00:49 jberger_ I'd be ok trying to submit something
00:49 jberger_ I haven't looked at the other challenges yet
00:50 jberger_ test 6 is easy enough :p
00:53 jberger_ 170k for plaintext
00:54 bpmedley They use Starman as the server and it's slower.
00:55 bpmedley Or, I could have it configured wrong, not sure.
01:05 bpmedley I had 8 workers on Starman, which is a bit much for my hardware.  With 4 works I'm getting good numbers.
01:05 jberger_ Starman doesn't use Mojo::IOLoop
01:06 bpmedley I was just doing json with Starman.   I guess Starman is right out for the Mongo stuff.
01:11 jberger_ so we should update this too: https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/mojolicious/setup.py
01:12 bpmedley Which server should we use?  prefork, hypnotoad, something else?
01:15 jberger_ prefork at least
01:18 jberger_ we could also make a proper configuration file with the connection details etc
01:20 bpmedley Do you see the Fortunes dataset anywhere?
01:22 jberger_ I pushed my updated fortunes builder
01:22 jberger_ see the populate helper
01:22 jberger_ sudo apt-get install fortune-mod
01:24 jberger_ bpmedley: you know how to use a helper from the command line?
01:24 jberger_ (just checking, ignore me if you do)
01:24 bpmedley Actually, no
01:24 jberger_ ./app.pl eval 'app->populate'
01:25 jberger_ actually I should move the collection object builders to helpers too
01:30 jberger_ updated
01:30 GabrielVieira joined #mojo
01:32 jberger_ bpmedley: having fun yet? :-)
01:32 bpmedley Yes, in fact
01:34 jberger_ I wonder if I should cache (state) the collections?
01:34 zM joined #mojo
01:34 jberger_ probably pretty lite, Mojo::Base objects are miniscule
01:36 bpmedley http://pastie.org/8737720
01:41 bpmedley MongoDB is pretty cool.  First day I've used it.
01:41 bpmedley jberger_: What do you think of the command?
01:43 jberger_ https://groups.google.com/d/msg/framework-benchmarks/-D6mXi9N5qw/EcFtiXWWPssJ
01:43 bpmedley Awesome!
01:44 jberger_ bpmedley: yes that is how a command would work, not so useful for a Lite app thouhg
01:44 jberger_ I guess it is, as long as you have your PERL5LIB setup correctly
01:44 jberger_ <3 commands
01:44 bpmedley Right; however, you can init the db with "./app.pl populate"
01:45 bpmedley It's less confusing than the eval thing with a helper, in my opinion.
01:45 jberger_ true, but you could just have the command call the helper too
01:45 jberger_ eval is super useful, you should try it more
01:46 jberger_ especially once you have lots of helpers in use, then you can just poke in and see how your app would handle X
01:46 jberger_ or run a one-off database query
01:46 bpmedley http://pastie.org/8737746
01:46 jberger_ etc
01:47 bpmedley I'm thinking of other people looking at the code and wondering how to use it..
01:47 jberger_ well that's true I suppose
01:47 bpmedley I use DB::single a lot and the debugger
01:48 jberger_ I don't think I would put the populate helper in a submission anyway though
01:48 bpmedley I see
01:49 bpmedley Then the command is probably a moot point.
01:49 bpmedley I think we should drop JSON::XS, what do you think?
01:51 jamesw joined #mojo
01:58 jamesw joined #mojo
02:10 jberger__ joined #mojo
02:11 klapperl_ joined #mojo
02:12 jberger__ I'm out for a little bit
02:12 bpmedley Ok
02:12 jberger__ I don't see any harm in keeping it though
02:12 bpmedley Not really any harm; however, what does it add?
02:12 * jberger__ is that geek with irc on his smart phone
02:13 jberger__ Go do a little benchmark of just mojo json vs xs
02:13 jberger__ cmp these
02:13 jberger__ It is faster
02:14 jberger__ I wouldn't care for real world, but this is a micro benchmark
02:15 jberger Ok well I'll be back in an hour or so
02:39 jberger__ joined #mojo
02:45 jack joined #mojo
03:10 rem_lex|pivo joined #mojo
03:25 rem_lex|pivo joined #mojo
03:26 zM joined #mojo
03:26 cleverfox joined #mojo
03:30 abra joined #mojo
03:40 Lee joined #mojo
03:51 jberger_ man cloning into this stupid benchmark takes forevar!
04:04 jberger_ sri: is there any reason not to store a collection in a state helper?
04:14 ryozi joined #mojo
04:54 d4rkie joined #mojo
05:11 Stefan joined #mojo
05:29 mattastrophe joined #mojo
05:31 gnephiak joined #mojo
05:32 jberger_ bpmedley: btw, this is the actual mongo setup script it would seem
05:32 jberger_ https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/config/create.js
05:32 jberger_ except that it doesn't actually work :-/
05:33 jberger_ this works: http://pastie.org/8738193
05:33 jberger_ the 'use' directives don't work in scripts
05:34 jberger_ anyway, here is my current form, https://github.com/jberger/FrameworkBenchmarks/blob/master/mojolicious/app.pl
05:34 jberger_ does all tests except 5
05:51 jberger_ btw if anyone can think of a clever non-blocking way to do #5 efficiently, let me know, http://www.techempower.com/benchmarks/#section=code&amp;hw=i7&amp;test=json
05:51 jberger_ also I will have to update the setup scripts before I can submit
05:51 jberger_ but for now, nn
06:00 d4rkie joined #mojo
07:01 jack_ joined #mojo
07:05 gnephiak Hmm..I should put my business logic code in subclass of Mojolicious::Controller, right?
07:13 damaya joined #mojo
07:14 damaya Hi all
07:14 damaya Hm, give me a second, need to think about how I should word my question.
07:15 damaya Actually, need to try to figure out if I can figure it out on my own first.
07:38 lucs Formulating the question properly will help you get closer to a solution :)
07:43 moritz for every question I've asked on perlonks, there are about three more that I meant to asked, but to which I found the solution while properly formulating and researching the question
07:45 abra_ joined #mojo
07:45 lucs I often join channels on IRC and never even say a word before leaving, mainly for the same reasons :)
07:46 Vandal joined #mojo
07:48 malikai joined #mojo
07:49 malikai howdy
08:27 bpmedley jberger_: I mean to pastie what I had before I went so sleep.. :-0
08:27 bpmedley *meant
08:28 bpmedley malikai: Morning
08:31 bpmedley jberger_: http://pastie.org/8738488  <-- For updates; possibly a faster way with {multi => 1}.
08:41 basiliscos joined #mojo
08:50 cfedde joined #mojo
09:02 d4rkie joined #mojo
09:07 jnbek^dt joined #mojo
09:22 d4rkie joined #mojo
09:27 mire_ joined #mojo
09:27 bpmedley jberger_: http://pastie.org/8738575
09:36 tempire joined #mojo
09:36 damaya Hrm, so I have my template, and I am using content_for to include some js in my default layout. I have content, then above </body> I have all my javascript. Unfortunately, what seems to be happening is that because some of my JS modifies the DOM, the scripts are above the modified DOM, which is above the </body> tag.
09:36 damaya Does that make sense?
09:37 bpmedley I think so; do you have a smallish example?
09:38 damaya Yeah, let me cut this down a bit so I can give you something decently readable.
09:49 sdfasdf joined #mojo
09:50 damaya OK, so Firebug doesn't copy the HTML very well, so I will do my best to explain this
09:50 damaya http://pastie.org/8738602
09:50 bpmedley Can you put all that in a ::Lite script?
09:51 damaya Basically, what EditableTable.init(); does is create a bunch of rows in the <tbody></tbody> section.
09:51 damaya Sure...
09:51 ladnaV joined #mojo
09:52 denis_boyun joined #mojo
09:54 GabrielVieira joined #mojo
09:58 Vandal joined #mojo
09:59 sh4 joined #mojo
10:10 Stefan joined #mojo
10:11 damaya ok, well, put together an example and it's not doing it
10:11 damaya haha
10:11 bpmedley gaw
10:11 damaya yeah, well, at least it tells me that it is something else :)
10:14 malikai oh how i wish it was morning..
10:17 malikai yay for 4 year old kids and the headaches they can cause
10:18 * malikai drinks a lot before anyone says "just wait until yea X"
10:22 skullbocks joined #mojo
10:30 damaya I have a 5 year old
10:30 damaya I know the feeling
10:30 Andy2 joined #mojo
10:30 Andy2 Hi
10:30 damaya Hi!
10:31 Andy2 Is there a way to "share" an object between two routes in an Mojolicious::Lite app?
10:31 Andy2 ABre in mind i just started around playing with Mojo in general :)
10:32 Andy2 *Bear
10:32 malikai ok.. so i'm pretty sure this is expected behavior, but i just need to verify.. and see if there's any alternatives..
10:33 malikai using morbo, i have an event, run a ->syslog method, and i get one syslog message
10:33 malikai using hypnotoad, same things happen, but i get 5+ messages
10:34 damaya For me I have been using helpers. For example, helper schema => sub { return Schema->connect('dbi:SQLite:' . ($ENV{TEST_DB} || 'test.db')); };
10:34 damaya I can then use my $schema = $self->schema.
10:34 ladnaV joined #mojo
10:36 bedivere joined #mojo
10:36 bedivere hi
10:36 damaya I've also used has in some plugins, but I can't comment on whether that is a good way to do things.
10:36 Andy2 damaya: thx, i will try that
10:37 damaya bedivere, hi!
10:38 damaya Andy2, you're welcome. If I know exactly what you're trying to accomplish I may be able to help more.
10:38 bedivere any hints why "$c->render_static($path)" could fail? this gives me a 404 telling me that the route was not found. "$path" exists and is accessible
10:40 bedivere something like "$c->render(json => $path)" instead of "$c->render_static($path)" works like expected without 404
10:41 Andy2 damaya: damaya basically i create an object when a page is called in a route and then the user clicks a link and therefor is redirected to the next route. I need access to the previously created object in that route.
10:42 damaya Andy2, sorry if this is not what you're looking for, but could you store it in the flash?
10:43 damaya http://mojolicio.us/perldoc/Mojolicious/Controller#flash
10:43 Andy2 Just to show you how new i am to this stuff (i have to check out what the flash is) ;) Just a sec
10:43 Andy2 ah great
10:44 Andy2 let me try that, thx again
10:47 damaya ok, well sleep well then
10:47 damaya woops, sorry, wrong window
10:48 Andy2 :)
10:50 Andy2 damaya: Could i store the whole object in my session?
10:51 Andy2 I already saved a string there but it never occured to my to try it with the object
10:51 damaya Let me give it a try :)
10:52 Andy2 i already did but i throught an error but i probably did something wrong ..
10:53 damaya Any chance you can paste your code somewhere?
10:56 Andy2 well i just create an object and do: $self->session(name => $myobject);
10:56 Andy2 and tehn i do: my $myobject = $self->session("name")
10:56 Andy2 in the other route
10:56 damaya Hm, it would help me greatly if you could post your code. If not I can try to create something to test the idea.
10:57 Andy2 well it's just a very small part of the whole app but i can try to abstract a small example
10:58 damaya How about this
10:58 damaya The object that you're instantiating, is it from a CPAN module?
10:58 damaya Something you've created?
10:59 Andy2 It's mine
10:59 Andy2 i try to put as much logic as possible in modules
11:00 Andy2 but i'm trying the same with a cpan object now
11:00 Andy2 to see if that makes a difference
11:07 ka2u joined #mojo
11:08 zM joined #mojo
11:11 damaya one second, testing
11:11 Andy2 Awesome, me too :)
11:13 rem_lex joined #mojo
11:20 bowtie_ joined #mojo
11:28 skullbocks joined #mojo
11:36 dvinciguerra joined #mojo
11:37 damaya Well
11:37 damaya I don't think you can pass objects via the flash/stash.
11:37 Andy2 yep me too
11:38 Andy2 at least not that simple..
11:38 damaya I've tried passing it as a reference, etc... I don't think the flash is meant for that.
11:38 marcus joined #mojo
11:39 Andy2 So probably what you said in the first place is the way to go
11:39 Andy2 the helper
11:39 purl the helper is for the case where you -don't- have two different tables
11:40 moritz purl: forget the tables
11:40 purl moritz: I forgot tables
11:45 damaya has
11:45 damaya the has
11:45 damaya purl: has
11:45 purl well, has is done with suffering fools gladly this day.
11:45 damaya ok
11:49 GabrielV_ joined #mojo
11:56 marcus I suffer glad fools every day :-/
12:00 punter joined #mojo
12:03 bedivere left #mojo
12:19 GabrielV_ joined #mojo
12:24 GabrielVieira joined #mojo
13:02 basiliscos joined #mojo
13:23 skullbocks joined #mojo
13:27 mire_ joined #mojo
13:33 jberger__ Using helpers as a persistent storage (directly) is limiting
13:35 skullbocks joined #mojo
13:50 Vandal joined #mojo
13:57 jack joined #mojo
14:06 damaya jberger, how would you suggest to pass objects? Say for example I have a Net::OpenSSH object, and rather than reconnecting each time I want to use it, I'd like to keep the connection open, reconnect only if disconnected, and be able to use methods (e.g., capture) in any of my routes.
14:07 damaya I've been looking at the flash for passing it when needed, but I doubt that is the intent of the flash (because I can't get it to work :))
14:09 damaya Actually, I was looking at the flash in response to Andy2's question.
14:09 eugen_ joined #mojo
14:09 Andy2 ah yes and thx damaya btw :)
14:10 damaya No problem. I don't mind being no help at all :D
14:10 Andy2 hehe, you had the helper idea ;)
14:10 Andy2 thats better than nothing ^^
14:10 damaya It seems that may not be the way to do it.
14:11 damaya Actually, Andy2, I am also learning Mojolicious. For me, I like to look at the example applications that they've compiled here: https://github.com/kraih/mojo/wiki/Example-applications
14:11 Andy2 yep me too
14:12 damaya I had an issue with Mojo::UserAgent a few weeks back and I got in and started digging around in Mojolicious source. I also found that to be really enlightening, and much easier to understand than I had expected.
14:13 Andy2 yep as soon as you have a basic understanding it gets much easier to follow the examples
14:15 damaya And finally, I found this: https://metacpan.org/source/SHARIFULN/Mojolicious-Plugin-Mail-1.1/lib/Mojolicious/Plugin/Mail.pm
14:16 damaya I figure since it is using a MIME::Lite object, it may be somewhat helpful to look at to get an understanding of how the object is used.
14:16 damaya And with that, I am out. G'night all.
14:16 Andy2 have a good night
14:17 damaya You too, and good luck. Let me know what you figure out.
14:17 Andy2 i will
14:23 ka2u joined #mojo
14:26 GabrielV_ joined #mojo
14:33 tempire joined #mojo
14:37 mire_ joined #mojo
14:42 ladnaV joined #mojo
15:06 s1037989 joined #mojo
15:10 Stefan joined #mojo
15:12 gryphon joined #mojo
15:27 jberger_ bpmedley: reading the prelude to test #5 makes me think that atomic read and modify is not "in the spirit" of the exercise
15:31 bpmedley Possibly not.  Should we use find_one and update?
15:35 rem_lex|pivo joined #mojo
15:50 jberger_ that is what i'm working on currently
15:58 Vandal joined #mojo
16:02 bpmedley jberger_: Do you know how to use multi => 1 with update?
16:04 jberger_ yes, I guess a batch update might help
16:04 jberger_ I was working on shared solution
16:05 jberger_ hmmmm, maybe ....
16:10 Andy2 jberger_: If you don't mind me asking, what is teh prefered way to pass an object from one route to an other?
16:11 bpmedley Andy2: Can you use a state variable?
16:11 Andy2 I don't know, i just started using Mojolicious::Lite yesterday
16:11 bpmedley Cool stuff.  Do you have an example we can look at?
16:11 jberger_ bpmedley: reading Andy2's previous messages, he seems to be meaning passing an object from a request by a client to a subsequent request by the same client
16:12 Andy2 I already use sessions and tried earlier to save the ojvect in the session but that did not work
16:12 jberger_ if that's the case, a state variable won't help
16:12 jberger_ Andy2: what kind of object? can it be serialized?
16:13 Andy2 It is a custom object
16:13 Andy2 *modul
16:13 jberger_ can it be serialized?
16:13 Andy2 What are the criteria for that?
16:13 Andy2 I don't know
16:14 jberger_ is it a blessed hashref with simpl-ish data?
16:14 Andy2 yes
16:15 Andy2 ok, so serialization is what i should try? :)
16:15 jberger_ then serialize it using say Storable, and store it in the flash
16:15 Andy2 ok
16:15 Andy2 thanks
16:18 jberger_ in any real scale webapp, there is no guarantee that the same server will serve the same client twice
16:18 jberger_ therefore you either have to write the object to a database and store a reference to it in the session, or else write the object to text (serialize) and store it in the session or flash
16:19 bpmedley I was assuming the daemon server - should have mentioned that.
16:19 * jberger_ doesn't assume that anymore
16:19 bpmedley :)
16:19 Andy2 :)
16:20 jberger_ starting a new user up a road that prevents scalability is starting them down a road to premature refactoring
16:20 bpmedley It's early, sorry.
16:21 jberger_ np
16:24 bpmedley jberger_: I think I mis-understood multi => 1 in the docs.  I'm not sure a bulk/batch update method exists in MongoDB.
16:24 jberger_ bpmedley: I was just looking at that and I think I agree
16:27 jberger_ bpmedley: https://github.com/jberger/FrameworkBenchmarks/blob/master/mojolicious/app.pl
16:28 jberger_ the only other thing I could do would be to fire-and-forget the update, but it seems against the spirit too
16:30 webart we simply must disrupt the webinar industry   ... flash player
16:30 webart must go
16:30 jberger_ easier to look at the diff perhaps: https://github.com/jberger/FrameworkBenchmarks/commit/fa38a442ab19256a625258f437cd305eb3ae3399
16:31 jberger_ webart: right channel?
16:31 purl i heard right channel was not this one
16:31 bpmedley Looks much better than the original.
16:31 webart is HTML5 (or at least some kind of xplatform video) and modern forms of authorization too much to ask ?  :-)
16:32 webart jberger_ well only that with mojolicious small children can create competing tools but ...
16:33 jberger_ webart: I'm not sure we are privy to the beginning of whatever conversation you are having
16:34 jberger_ bpmedley: now its time for the much less fun task of updating the supporting scripts :-/
16:35 bpmedley Where are those again?
16:35 bpmedley https://github.com/jberger/FrameworkBenchmarks/blob/master/mojolicious/setup.py  ?
16:35 jberger_ https://github.com/jberger/FrameworkBenchmarks/blob/master/mojolicious/setup.py
16:35 jberger_ ha, you beat me
16:36 jberger_ there is also an installation file, but that's not so bad, just update the Perl module list
16:37 Andy2 jberger_: The serialization with freeze thaw should work by saing it to the session as well, right?
16:37 jberger_ and whatever nginx conf and benchmark conf
16:38 jberger_ Andy2: yes, actually the flash is stored in the session, so the only thing that matters is how you are going to use it
16:38 Andy2 ok
16:38 jberger_ every subsequent request => session, just the next request => flash
16:38 Andy2 ok
16:40 bpmedley jberger_: http://pastie.org/8739454
16:40 bpmedley Andy2: Remeber, the sesion is limited to 4k, I think.
16:41 jberger_ bpmedley: so you are removing nginx all together?
16:42 bpmedley Yes.  Why do we need it?
16:42 jberger_ not sure, does it help?
16:42 bpmedley Not that I can tell.
16:42 bpmedley At first, I thought it was required for the benchmark; however, now, I don't think it is.
16:42 jberger_ I use nginx just to forward 80 to 808X for each app
16:43 bpmedley Isn't the conf file listening on 8080 for nginx?
16:43 Andy2 jberger_: could you please have a look here: http://paste.kde.org/pzbkk9fmz
16:43 jberger_ all I'm saying is I'm not the right person to ask on deployment
16:43 Andy2 Probably a simple problem ..
16:43 jberger_ CALLING ALL DEPLOYMENT EXPERTS!
16:44 bpmedley Andy2: What is your end goal?
16:44 Andy2 i want to call a method on that object again to get some date
16:45 Andy2 *data
16:45 jberger_ Andy2: [ \$obj ]
16:45 jberger_ ?
16:46 jberger_ Storable wants you to serialize a simple reference?
16:46 jberger_ you can't just freeze the object?
16:46 Andy2 let my try that
16:47 Andy2 i did it that way because i saw it in an example
16:47 jberger_ Andy2: the problem is that you have one more reference (\) than dereference
16:47 jberger_ but I don't think you need any of that
16:47 jberger_ lets see you freezing the object works
16:47 jberger_ and yes as bpmedley says, there is a cap on session size
16:48 jberger_ usually one just stores some unique key in the session and looks up the data in the database again
16:51 meshl joined #mojo
16:51 Andy2 $stored = freeze \$extract;
16:51 Andy2 i did it like this now
16:51 Andy2 and then $thawed = thaw $stored;
16:51 Andy2 in the new rout
16:51 Andy2 thats what you ment, right?
16:51 jberger_ $stored = freeze $extract # does this work?
16:52 salparadise can I do this in one line?
16:52 salparadise my $text =  $tx->res->dom->find('table[class="contentpane"] tr')->[-1];
16:52 salparadise my $td = $text->find('td')->[-1]->all_text;
16:53 Andy2 jberger_: ah yes that works..
16:53 Andy2 thanks a lot :)
16:53 bpmedley http://pastie.org/8739513
16:53 jberger_ salparadise: please don't paste into the channel
16:54 salparadise jberger_: sure apologies
16:54 salparadise didn't think two lines would have been bad
16:54 Andy2 bpmedley: thx
16:54 jberger_ salparadise: https://metacpan.org/pod/Mojo::DOM::CSS#E:last-of-type
16:55 salparadise jberger_: thanks
16:55 salparadise btw, read your article on non-blocking apps, pretty good
16:55 jberger_ rule number one: dive in as far as possible using css selectors before resorting to anything else
16:56 * jberger_ blushes
16:57 salparadise mojo is awesome but sometimes I get lost with the lack of documentation and I know you guys are working on that
16:57 salparadise so articles like that are really helpful
16:57 jberger_ Andy2 / bpmedley sure Data::Dumper/eval works, still it scares me at times
16:58 jberger_ salparadise: lack of documentation?
16:58 purl lack of documentation is, like, reaaaaaaaaaly annoying
16:58 jberger_ if there are missing pieces, let us know
16:58 salparadise jberger_: documentation is there I guess, lack of examples maybe?
16:59 jberger_ good big/real-world examples are indeed hard to fit into any documentation set
16:59 * salparadise nods
17:00 jberger_ and yes that's why I like to write conversational-style blog posts
17:01 jberger_ I'm glad you like them
17:02 salparadise yep, thanks for doing it, they are helpful
17:11 ka2u joined #mojo
17:15 gnephiak If I want to keep only one MongoDB connection using Mango, how do I make collection connection in controller class and my own class?
17:16 gnephiak I'd like to pass $mango in class constructor, but I don't know how to pass it from application class
17:20 jberger_ gnephiak: bpmedley and I are doing just that in our benchmark: https://github.com/jberger/FrameworkBenchmarks/blob/master/mojolicious/app.pl#L9
17:21 jberger_ bpmedley btw, I've simplified the updates logic further ^^
17:29 gnephiak jberger_: I should simply use helper and forget constructor parameter, right?
17:29 jberger_ use whatever constructor parameters you need, of course
17:29 gnephiak jberger_: and that class has to inherit Mojo::Base, am I right?
17:30 jberger_ helper is not a feature of Mojo::Base
17:30 jberger_ the helper function comes from Mojolicious::Lite, in a full app, use $app->helper(...) in the startup method
17:31 gnephiak I am struggled to figure where should I put my database-related logic code
17:31 gnephiak I think I shouldn't put them in the controller class, but where?
17:31 jberger_ helpers are shared with all controllers
17:31 jamesw joined #mojo
17:31 jberger_ so that is useful for things like connection logic
17:32 gnephiak hmm...learned another useful thing
17:32 jberger_ model logic can live wherever you like from that point
17:33 gnephiak If I understand correctly, you mean model logic can be put in the helper
17:34 gnephiak and controller can use them, without some constructor initialization concern
17:35 Stefan joined #mojo
17:37 jberger_ controllers are meant to connect model to view/template. Can model logic be implemented in helpers? sure. Can Model logic be elsewhere and rely on controller to use a helper to build a db connection for it to use? also sure
17:37 jberger_ use helpers when you want to share logic between app and all controllers
17:37 jberger_ the rest is up to you
17:38 jberger_ gnephiak: in Galileo I do have model helpers: https://github.com/jberger/Galileo/blob/master/lib/Galileo.pm#L151
17:39 jberger_ but I have other controller/view-specific "model" logic in the controller class: https://github.com/jberger/Galileo/blob/master/lib/Galileo/User.pm
17:40 jberger_ so this controller is really a hybrid
17:40 gnephiak hmm...I think I need times to digest this, still pretty new to web MVC
17:41 jberger_ (hmmm, that might not have been a great example pair :-/)
17:41 jberger_ well I guess it is ok
17:42 gnephiak jberger_: thanks for your help! I might spend several more days thinking this without your clarification
17:43 rem_lex joined #mojo
17:44 Stefan joined #mojo
17:49 Stefan joined #mojo
17:55 maxhq joined #mojo
18:50 ka2u joined #mojo
18:56 cstamas joined #mojo
18:57 cstamas hi
18:57 purl hello, cstamas.
18:58 cstamas i am about to package the latest version from metacpan and some sanity checks returns this output
18:58 cstamas (man page formatting)
18:58 cstamas http://paste.debian.net/hidden/f114cacc/
19:00 cstamas it would be nice if you can take a look, thx
19:06 basiliscos joined #mojo
19:16 denis_boyun joined #mojo
19:18 bpmedley jberger_: Looks good!
19:19 bpmedley All we need now is to decide on deployment?
19:24 hummeleBop joined #mojo
19:34 asarch joined #mojo
19:59 denis_boyun__ joined #mojo
20:24 damaya Good morning!
20:24 purl Lies!
20:24 damaya hmm
20:41 lukep joined #mojo
20:44 GabrielVieira joined #mojo
20:48 damaya joined #mojo
20:48 damaya Actually, scratch that question. I'm going to include it in the dist, just in case the host does not have access to the internet.
20:51 Stefan joined #mojo
20:57 meshl joined #mojo
21:02 meshl joined #mojo
21:03 moritz I'm starting to port an existing appliciation to mojolicious, and I'd like to keep the URL schema
21:04 moritz now that app uses URLs like /de/foo for German pages, /en/foo for English, and /foo for language auto detection
21:04 Stefan joined #mojo
21:04 moritz what's the best way to handle this in Mojolicious?
21:05 damaya Hm, it seems to me that you could use a helper to detect the language then use under to create routes under each language.
21:06 moritz damaya: I'd like to avoid setting up each route three times
21:06 damaya Ah, yeah, that makes sense. What about returning the language then creating a route like ($lang.'/foo') ?
21:06 beyondcreed joined #mojo
21:06 damaya And that'd be a better way anyway, if you add other languages in the future.
21:07 damaya or ('/'.$lang.'/foo');
21:07 damaya I guess there are probably even better ways even, but that is what comes to mind for me.
21:08 moritz can't I just s{^/(de|en)(?=/)}{} at the beginning somewhere, and then dispatch on the result?
21:08 jberger joined #mojo
21:09 moritz or something like the formats mechanism for the start of the URLs?
21:10 * damaya silently leaves the room
21:10 Stefan joined #mojo
21:10 damaya :)
21:11 moritz maybe something with the before_dispatch hook?
21:16 gryphon joined #mojo
21:24 bpmedley moritz: https://gist.github.com/brianmed/5903844  <-- Something like this?
21:29 moritz bpmedley: I'm not sure; I don't want to redirect
21:29 Stefan joined #mojo
21:32 Stefan joined #mojo
21:33 frldy joined #mojo
21:40 bpmedley moritz: What are you going to use to differeniate between the routes?  A header?
21:41 moritz bpmedley: for the /foo route, yes
21:41 moritz the Accept-Language header
21:44 GabrielV_ joined #mojo
21:45 frldy $routes->route('/:language/foo', language => [qw(de en)])->to('controller#action', language => 'en') seems to work
21:49 moritz frldy: could that handle an empty :language too, without leading double slash?
21:49 frldy works for me
21:49 moritz \o/
21:49 moritz frldy++
21:49 moritz thanks
21:53 moritz huh, /de/foo and /en/foo work here, but /foo doesn't
21:54 moritz anyway, time for sleep here
21:54 moritz thanks everybody
22:16 Stefan joined #mojo
22:27 GabrielVieira joined #mojo
22:27 Stefan joined #mojo
22:40 russum1 joined #mojo
22:49 jberger__ joined #mojo
22:56 sue joined #mojo
23:00 bpmedley http://pastie.org/8740290 <-- Should "/foo" work like "/baz"?
23:14 GabrielV_ joined #mojo
23:29 russum joined #mojo
23:35 russum1 joined #mojo
23:35 russum joined #mojo
23:42 bpmedley I think it may have been an old version.
23:44 bpmedley http://pastie.org/8740368  <-- There has got to be a better way to change the default

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