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

IRC log for #mojo, 2017-09-01

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

All times shown according to UTC.

Time Nick Message
00:53 kiwiroy joined #mojo
01:19 stryx` joined #mojo
01:26 kiwiroy joined #mojo
01:42 kiwiroy joined #mojo
01:51 ilbot2 joined #mojo
01:51 Topic for #mojo is now � nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
01:53 kiwiroy joined #mojo
02:22 dmanto joined #mojo
02:25 noganex_ joined #mojo
04:04 dboehmer joined #mojo
04:06 disputin joined #mojo
04:07 disputin joined #mojo
05:09 stryx` joined #mojo
05:20 inokenty-w joined #mojo
06:26 karjala_ joined #mojo
06:32 Vandal joined #mojo
06:38 n16gel joined #mojo
06:50 prg joined #mojo
07:07 Dandre joined #mojo
07:16 trone joined #mojo
07:27 AndrewIsh joined #mojo
07:54 Dandre joined #mojo
08:34 rshadow joined #mojo
08:43 aborazmeh joined #mojo
09:19 Janos joined #mojo
10:02 kubrat joined #mojo
10:48 Gedge joined #mojo
11:04 tchaves joined #mojo
11:12 Alex342 joined #mojo
11:15 Alex342 hei guys
11:15 Alex342 i tried to use grep to find a string into array
11:16 Alex342 It doesn't work
11:16 Alex342 This is what i tried
11:16 Alex342 grep {$_ eq 'solved'} $page_status ------ grep(qr/solved/, $page_status).
11:17 nicomen $page_status is probably an array-ref, you need to dereference it: @{ $page_status || [] }
11:18 nicomen grep { /solved/ } @{ $page_status || [] };
11:18 Alex342 % my $page_status = ${ $pages_data }{ $page_id }{ 'status' };
11:19 Alex342 Let me try
11:20 nicomen probably $pages_data->{$page_id}->{'status'}
11:21 nicomen and that sounds like not an array but a single value
11:24 Alex342 yes
11:24 Alex342 it's a long string
11:29 pink_mist Alex342: grep works on arrays, not strings
11:29 pink_mist Alex342: if you wanted to check if a string contained something, just use a regex on it directly
11:33 gregf_ joined #mojo
11:40 Alex342 nicomen: It is an array actually. I didn't implement it :)). I had to replace match::smart with grep . Thanks guys
12:15 marty_ joined #mojo
12:27 marty joined #mojo
12:28 marty joined #mojo
12:33 stryx` joined #mojo
12:41 tcohen joined #mojo
12:44 marty joined #mojo
12:59 bianca joined #mojo
13:12 Alex3421 joined #mojo
13:15 gizmomathboy joined #mojo
13:45 arthas joined #mojo
14:00 rickbol_ joined #mojo
14:02 tchaves joined #mojo
14:13 rickbol joined #mojo
14:24 dantti_laptop joined #mojo
14:48 dantti_laptop joined #mojo
15:01 jberger I haven't asked a question on SO in a while
15:01 jberger anyone with postgres skillz got any other ideas for me here: https://stackoverflow.com/questions/45984976/coerce-string-of-timestamp-or-interval-to-timestamp/46002814#46002814
15:02 maschine joined #mojo
15:09 Janos joined #mojo
15:10 bc547 joined #mojo
15:18 vicash jberger: if you know what the string input range will be, say a date after 2000, you can check if the epoch value is > the epoch value in 2000 and then add to now() or just return as a timestamp
15:19 jberger can you coerce an interval to an epoch?
15:20 jberger even if you could you'd have to cast the string to an interval before doing so, and that will RAISE
15:20 jberger (if it isn't an interval I mean)
15:21 vicash you might have to benchmark the exception solution vs the select-case solution provided on SO. it is my understanding that the exception solution will be slower, but ymmv.
15:22 jberger is that regex really robust enough?
15:22 jberger and even if so, its pretty unwieldy
15:24 vicash well interval requires a unit, and if your interval input will have a unit, it should be pretty easy to filter out.. that regex is incomplete.
15:25 jberger in effect I'm really asking postgres to validate a string as an interval, I'd rather not have to reimplement the validation in order to do so
15:25 jberger :-P
15:25 dantti_laptop joined #mojo
15:25 vicash is this user entered format ?
15:25 jberger yes
15:25 jberger that's the point
15:25 vicash pardon my ignorance, wouldn't it make sense to validate this in perl ?
15:26 disputin joined #mojo
15:26 jberger maybe, but then again, I'd have to implement a validation for the interval format
15:28 vicash Pg supports ISO 8601 interval format strings like Pyyyy-mm-ddThh:mm:ss so you can force that maybe. the docs https://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-INTERVAL-INPUT here say it is supported.
15:28 pink_mist if (!eval { $db->insert(...); 1; }) { #it was not valid :P
15:28 vicash i agree that free-style interval parsing is unnecessarily complex to implement..
15:29 Pyritic joined #mojo
15:31 vicash jberger: as to pink_mist's solution I would use $db->query('SELECT now() + ?::interval', $input) instead of the INSERT since that is more expensive.
15:31 pink_mist well, I assumed it was supposed to be inserted in the db if it was valid anyway
15:34 vicash jberger, pink_mist: if insert and select have to be in a single run then IF EXISTS (SELECT now() + ?::interval) THEN INSERT INTO MyTable(whatever) VALUES(now() + ?::interval);
15:38 jberger it is supposed to be inserted
15:38 rickbol joined #mojo
15:38 jberger I think overall I've gotten the answer I was looking for, ie, there is no simple way to validate a coercion that doesn't throw an exception
15:39 jberger discovering something like a CAST_OR_NULL() function was what I was looking for
15:40 jberger but I didn't want to ask as an X/Y question
15:40 vicash stored procs are not a bad solution. just document and version them :) Mojo::Pg's migrations feature allows for that.
15:40 jberger yeah
15:41 jberger believe me, though it isn't public code (yet) I've done a fair amount of Mojo::Pg::Migrations for stored procs :-P
15:42 jberger gods, I'd love to clean that up for open source release
16:09 bianca joined #mojo
16:13 * sri wonders if this could be the perfect monitor :o http://www.lg.com/us/monitors/lg-32UD99-W-4k-uhd-led-monitor
16:15 sri kinda weird that hdr10 is getting rolled out so slowly
16:23 ChmEarl joined #mojo
16:31 bianca joined #mojo
17:17 bianca joined #mojo
17:25 itaipu joined #mojo
17:29 rshadow joined #mojo
17:34 gizmomathboy joined #mojo
17:56 mib_knne8n joined #mojo
18:28 Pyritic joined #mojo
18:56 VVelox joined #mojo
18:59 sh14 joined #mojo
19:03 gizmomathboy joined #mojo
19:05 Pyritic joined #mojo
19:07 rshadow joined #mojo
19:22 bianca joined #mojo
19:43 bianca joined #mojo
20:17 petru joined #mojo
22:14 disputin joined #mojo

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