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

IRC log for #mojo, 2015-06-21

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

All times shown according to UTC.

Time Nick Message
00:07 zivester joined #mojo
00:21 woz joined #mojo
00:38 lluad joined #mojo
00:39 mattastrophe joined #mojo
00:45 crab joined #mojo
00:49 * jberger has fun with iperl notebooks + mojo async
00:49 jberger http://nbviewer.ipython.org/gist/jberger/b62332a506b364117e37
00:50 jberger Grinnz++ # Mojo::Reactor::IOAsync
01:02 esh joined #mojo
01:15 absolut_todd joined #mojo
01:19 klapperl_ joined #mojo
01:22 woz joined #mojo
01:32 crab joined #mojo
01:57 jberger although it is interesting, since I don't start it, is_running must be false right?
01:57 jberger hmmm
01:57 jberger I don't especially like that
01:59 Grinnz IO::Async unfortunately has no way to know if it's running
01:59 Grinnz at least, no public way
02:02 jberger a common problem
02:03 jberger woah! lightning just 1/2 block away!
02:03 jberger nice midwestern thunderstorm atm
02:05 jberger I don't see away to force IO::Async to use a certain implementation either
02:05 jberger though I'm still looking
02:06 Grinnz $ENV{IO_ASYNC_LOOP}
02:10 jberger Grinnz++
02:10 jberger that works nicely
02:14 jberger http://nbviewer.ipython.org/gist/jberger/b62332a506b364117e37#
02:16 noganex joined #mojo
02:23 woz joined #mojo
02:50 davido___ joined #mojo
02:56 PryMar56 joined #mojo
02:58 sri_ btw. wayward pines is also really good scifi
02:59 * sri_ wonders if netflix might be the reason so many channels are upping their quality this year
03:22 esh joined #mojo
03:30 kaare_ joined #mojo
03:45 crab joined #mojo
04:24 aggrolite joined #mojo
04:30 bin_005 joined #mojo
07:02 bin_005 joined #mojo
07:13 mattastrophe joined #mojo
07:18 mattastrophe joined #mojo
07:27 berov joined #mojo
07:37 marcus I also greatly enjoy wayward pines.
07:39 amon joined #mojo
07:54 dotan joined #mojo
08:12 Vandal joined #mojo
08:12 aggrolite joined #mojo
08:56 trone joined #mojo
09:25 dod joined #mojo
09:29 dod joined #mojo
09:31 * lb is pining for the fjords
10:04 asidjq joined #mojo
10:05 asidjq left #mojo
10:08 dod joined #mojo
10:09 dod joined #mojo
10:33 woz joined #mojo
10:36 ToApolytoXaos joined #mojo
11:53 punter joined #mojo
12:30 mishanti1 lb: fjords?
12:44 lb mishanti1: oh dear
12:44 lb https://www.youtube.com/watch?v=npjOSLCR2hE
12:51 batman anyone who knows of a module which allow me to search a file from beginning or end, matching a regex?
12:51 batman i think searching from the end of file is rather difficult :/
13:13 batman maybe i should try out Tie::File
13:22 lb batman: if the regex is limited in how much it can match, read in chunks of the file from the end, always matching on current and previous chunk concatenated
13:22 lb i assume the file is too large to just search it all
13:26 asarch joined #mojo
13:28 sri_ batman: File::Map?
13:35 * jberger likes Tie::File for certain applications
13:35 jberger But it kinda depends on what you are trying to do  with your match
13:36 mst the mstomatic is Tie::File powered
13:36 sri_ why Tie::FIle over File::Map?
13:38 sri_ especially for the use case here
13:38 mst why either for the use case here?
13:38 jberger Easily get the last line for example
13:38 mst forwards is trivial, File::ReadBackwards exists for backwards
13:38 jberger But I don't know what his use case is
13:39 jberger Hmmmm, hadn't heard of ReadBackwards
13:39 jberger That might be the place to start
13:40 jberger (Tie::Array::CSV is Tie::File based too)
13:40 sh4 joined #mojo
13:44 mst the core of http://www.trout.me.uk/cgi-bin/mstomatic.cgi is: tie my @poss, 'Tie::File', ...; my $quote = $poss[int rand ~~@poss];
14:15 kaare joined #mojo
14:47 gryphon joined #mojo
14:51 ToApolytoXaos joined #mojo
14:53 dvinciguerra joined #mojo
15:01 woz joined #mojo
15:02 ajr_ joined #mojo
15:23 dod joined #mojo
15:54 romel hello guys. what's the best practice for preparing Mojo::Pg statement string along with values from arbitrary set of incoming params in key->value format?
15:56 mst writing code
15:56 purl writing code is usually boring.  design is interesting, code is boring.
15:56 mst you've given no information about what sort of statement and why you're doing that
15:56 mst so it's impossible to determine which code you should write yet
15:57 punter joined #mojo
15:58 thowe what kind of data is it?
16:01 romel there's a set of data coming from json request with arbitrary number of keys. so is it a good idea to loop through key->value pairs and construct statement string and values array by just concatenating 'field1 = ?' and so on?
16:01 romel i mean maybe there's a better solution
16:04 thowe This is just me, but I think you probably already have a data structure from decoding your json.  Loop through that first in a validation step, then if it passes construct your query.  Mojo::Pg has you working at a raw level.
16:05 thowe Depending on what you are doing, you may want to abstract out that validation for re-use elsewhere.
16:05 thowe But what kindn of data is it?
16:06 romel just 'field name' => 'value' pairs
16:08 romel if it's what you mean :)
16:08 thowe I figured a sanitation step would be in there somewhere.
16:09 thowe building a query is trivial, validation may be otherwise.
16:09 Kogurr joined #mojo
16:11 marmez joined #mojo
16:11 marmez left #mojo
16:11 woz joined #mojo
16:12 thowe So, maybe my question should be how complex is the data structure you end up with?
16:13 romel no complexity at all. just plain hashes from trusted source
16:13 thowe Maybe I should even just stop you there, take a page from mst, and accept that I need to see some code to give an informed answer.
16:14 thowe well, make a loop....  Put a nice tick on the 24th track and rock out.
16:15 thowe I should really get my first cup of coffee...
16:16 thowe Maybe something better will occur if it breaks.
16:22 mst romel: SQL::Abstract will do this for you
16:24 thowe Oh, totally.  I'm so stupid.  You can just feed it your data structure and get your SQL back.
16:24 * thowe slaps forhead
16:24 mst or SQL::Interpol for simple cases
16:26 thowe romel, First example has it all there for you: http://search.cpan.org/~ribasushi/SQL-Abstract-1.81/lib/SQL/Abstract.pm#DESCRIPTION
16:28 sri_ i bet the Mojo::Pg backend of Minion already has an example for what you want to do https://github.com/kraih/minion/blob/master/lib/Minion/Backend/Pg.pm
16:29 romel thank you guys
16:30 sri_ i've done optional where conditions with static sql too (where (state = $1 or $1 is null))
16:30 sri_ which i assume is what you wanted
16:30 sri_ postgres makes it very easy
16:33 * sri_ wonders if someone has done a Mojo::Pg::Abstract yet
16:34 sri_ hmm, doesn't look like it
16:37 sri_ would be so easy, just subclass Mojo::Pg with a db method that reblesses the original return value into Mojo::Pg::Abstract::Database, which then adds methods like insert and friends
16:38 woz joined #mojo
16:38 * sri_ never really like SQL::Abstract for queries though
16:39 * mst should try a Mojo::Pg::DQ at some point
16:53 Grinnz dairy queen??
16:53 * Grinnz could use a postgres blizzard about now
16:57 PryMar56 joined #mojo
17:03 mst Data::Query, so something like $mojo->db->users->where($Q->signup_date > 7->days->ago)->hashes
17:08 pink_mist 7->days->ago? is it introducing autoboxing?
17:09 mst there's already a DateTime autobox somewhere
17:10 mst and it makes for an easier example-to-type-into-channel ;)
17:10 mst could equally support
17:10 mst $mojo->db->users->where($Q->signup_date > (now - interval '7 days'))->hashes
17:35 sri_ too abstract for me
17:36 sri_ or rather too magical
17:38 mst I've worked with the forms of magic involved enough now to be pretty confident I can make them behave
17:38 mst but, y'know, if you don't like SQL::Abstract either ... I'm not sure what you -would- like
17:39 mst have you seen SQL::Interpol ?
17:39 sri_ yea, i have no clue what i would like ;p
17:40 sri_ well, actually, i do like static sql, with proper indentation and capitalization
17:41 mst interpol is that but with a very small amount of sugar
17:41 mst I've not seen any minimalist sugar on SQL thing I like better
17:59 aggrolite joined #mojo
18:05 tianon joined #mojo
18:24 zivester joined #mojo
18:35 marcus I like SQL
18:36 mst I like being able to metaprogram SQL
18:36 _dave_ I'd like to learn postgres to see why you like SQL :)
18:44 sri_ guess perl6 could do some interesting things for sql
18:45 batman sorry for my rather non-specific question earlier. the thing is that i need a way to search and extract the last X lines from a file, to show a conversation in convos.
18:45 batman going to look into File::Map
18:45 batman thanks for the answers.
18:46 mst batman: File::map will memory map
18:46 mst batman: File::ReadBackwards is specifically written to be able to read backwards through lines
18:46 batman want to make something with this api: https://ssl.thorsen.pm/paste/5c6dfc9dbe10
18:48 batman mst: yeah. looked at File::ReadBackwards earlier. looks interesting.
18:49 batman the reason Tie::File looked interesting was that it seemed rather simple to use in my case: @log = reverse @fh[-60..-1]; or something
18:50 mst yeah, but then it has to read the entire file to get the line count etc.
18:50 mst that's a -silly- approach
18:51 mst I use it in the mstomatic because in the mstomatic it's basically irrelevant
18:51 batman ok. didn't know how it worked internally.
18:51 batman guess i'll give File::ReadBackwards a try
18:52 mst I'm saying 'fuck it' and reading the entire file into memory for every request because it's a tiny CGI script and I don't care
18:52 batman :)
18:54 batman oooh. didn't notice it File::ReadBackwards had a tied interface as well :)
18:55 marmez joined #mojo
18:55 marmez left #mojo
18:57 aggrolite joined #mojo
19:12 ajr_ joined #mojo
19:23 mattastrophe joined #mojo
19:32 _dave_ any of you know offhand if there's a way to get perl to return st_birthtime from stat other than $x = `stat ...`; ?
20:00 bin_005 joined #mojo
20:10 jberger _dave_: the stat function isn't what you need? http://perldoc.perl.org/functions/stat.html
20:15 pink_mist that doesn't have birthtime
20:16 pink_mist only mtime, atime, and ctime
20:30 * batman haven't ever heard of birthtime
20:53 _dave_ it's a new stat field, supposedly shows the file creation date
20:53 _dave_ doesn't work over NFS yet apparently
20:54 batman ok.
22:37 jberger so I kinda pseudo-announce my recent modules in http://blogs.perl.org/users/joel_berger/2015/06/yapcna-2015-wrap-up.html
22:37 jberger I do intend to make a more proper blog post on those soonish
22:44 absolut_todd joined #mojo
22:45 sri_ feels like the FFI modules on cpan are not really taking off
22:46 preaction too many other ways to do things. we should try to get libffi into core like p6, ruby, python, and a bunch of other languages have
22:47 preaction then it'd be "a compiler-free way of interacting with native code"
22:47 sri_ yea
22:48 jberger FFI::Platypus + Alien::Base is just starting to come into its own
22:48 rwp joined #mojo
22:49 jberger I'm going to start working on those for UV soonish
22:49 preaction yeah, the first start of FFI in perl was kind of stillborn
23:15 Kripton joined #mojo

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