00:17
lucasb_ has quit [Quit: Connection closed for inactivity]
02:36
chimkan has joined #crystal-lang
02:38
laaron has joined #crystal-lang
02:39
chimkan has quit [Client Quit]
02:40
laaron has quit [Client Quit]
02:40
laaron has joined #crystal-lang
03:10
laaron has joined #crystal-lang
04:52
_whitelogger has joined #crystal-lang
06:08
laaron has joined #crystal-lang
06:12
<
FromGitter >
<Nbotz> how can i return the minute and second of Time.now in integer?
06:14
<
FromGitter >
<Nbotz> i know i can do it through `to_s`, but then i cant do arithmetic
06:14
<
FromGitter >
<watzon> What exactly do you mean @Nbotz?
06:14
<
FromGitter >
<watzon> How do you want the minute and second together if not as a string?
06:15
<
FromGitter >
<Nbotz> like
06:16
<
FromGitter >
<Nbotz> like `1545` with 15 being the minutes and 45 being the seconds
06:16
<
FromGitter >
<Nbotz> but as an integer so i can do arithmetic
06:18
<
FromGitter >
<Nbotz> im trying to find the offset between the initial time, and the updated time, but seconds reset after 60, and minutes are too short to increment
06:19
<
FromGitter >
<watzon> Ok...
06:19
<
FromGitter >
<watzon> Well this will give you what you want
06:20
<
FromGitter >
<watzon> ```Time.now.to_s("%M%S").to_i```
06:21
<
FromGitter >
<watzon> Are you trying to time execution time? Like a stopwatch?
06:21
<
FromGitter >
<Nbotz> oh, i had to use `to_i` in `Time.now`
06:21
<
FromGitter >
<Nbotz> yeah, im timing the time the server starts to the time a new client enters the server
06:22
<
FromGitter >
<watzon> You know that you can just do arithmatic with `Time` right?
06:23
<
FromGitter >
<Nbotz> would using the whole time be better than just the minute and second?
06:24
<
FromGitter >
<watzon> Look into `Time::Span`
06:24
<
FromGitter >
<watzon> Actually devdocs is outdated
06:25
<
FromGitter >
<watzon> Don't know that anything has been changed with `Time::Span` though
06:26
<
FromGitter >
<Nbotz> thanks, but the `to_s("%M%S").to_i` works best for right now, thanks for your help
06:26
<
FromGitter >
<watzon> You can initialize a `Time.now` when the process starts, a `Time.now` when it ends, and then subtract the first one from the second one. It's going to be much less error prone.
06:27
<
FromGitter >
<watzon> The string to int method is going to be janky
06:34
laaron has joined #crystal-lang
06:39
<
FromGitter >
<Nbotz> the thing is, it returns a time, when i need a single int
06:40
<
FromGitter >
<Nbotz> and if i single it out to `time.seconds` then i get the same problem i had before
06:40
<
FromGitter >
<watzon> It returns a `Time::Span`
06:41
<
FromGitter >
<Nbotz> yes, im calculating two `Time::Span` and it returns a `Time::Span` but i need it to return an int
06:44
<
FromGitter >
<watzon> `Time::Span#total_seconds` will give you the total amount of seconds that has elapsed since the process started
06:48
<
FromGitter >
<Nbotz> ah it worked
06:48
<
FromGitter >
<Nbotz> yeah that works best, thanks i see now
06:48
<
FromGitter >
<watzon> It's always best to work with the language :)
06:49
<
FromGitter >
<Nbotz> crystal is surprisingly accommodating. i never knew about the timespan stuff
08:53
gangstacat has quit [Ping timeout: 258 seconds]
09:03
ashirase has quit [Ping timeout: 245 seconds]
09:07
ashirase has joined #crystal-lang
09:24
laaron has quit [Remote host closed the connection]
09:24
laaron has joined #crystal-lang
09:38
gangstacat has joined #crystal-lang
10:44
laaron- has joined #crystal-lang
10:47
laaron has quit [Remote host closed the connection]
11:09
devil_tux has joined #crystal-lang
11:20
devil_tux has quit [Ping timeout: 248 seconds]
11:29
devil_tux has joined #crystal-lang
11:48
duane has joined #crystal-lang
11:49
alex`` has joined #crystal-lang
11:53
<
FromGitter >
<Prutheus> How to convert a String `"2"` to `"02"` (adding leading 0's) ?
11:56
<
jokke >
Prutheus: "2".rjust(2, '0')
11:56
<
jokke >
`"2".rjust(2, '0')`
12:49
alex`` is now known as alexherbo2
12:50
alexherbo2 is now known as alex``
13:01
laaron has joined #crystal-lang
13:12
duane has quit [Ping timeout: 248 seconds]
13:32
Creatornator has joined #crystal-lang
13:39
duane has joined #crystal-lang
13:51
laaron has joined #crystal-lang
14:17
alex`` has quit [Ping timeout: 245 seconds]
14:18
alex`` has joined #crystal-lang
14:24
laaron has joined #crystal-lang
14:44
duane has quit [Ping timeout: 245 seconds]
14:58
return0e has joined #crystal-lang
15:00
return0e_ has quit [Ping timeout: 258 seconds]
15:04
duane has joined #crystal-lang
15:15
BaldEagleX02 has joined #crystal-lang
15:59
moei has joined #crystal-lang
16:26
duane has quit [Ping timeout: 245 seconds]
16:31
<
pracabor >
is it not (yet) possible to chain iterators in Crystal? I'm trying `array.each_slice(8).map {...}` and getting an error.
16:32
<
pracabor >
in ruby, eg: ` "abcdefghijklmnop".split('').each_slice(8).map(&:join) => ["abcdefgh", "ijklmnop"]`
16:32
<
FromGitter >
<jwoertink> With a HTTP::Handler, if the `call` doesn't return `call_next`, what
*should* it return? `context`?
16:34
<
FromGitter >
<jwoertink> @Nbotz If you're measuring time, you can also use `elapsed_time = Time.measure do`
16:35
<
FromGitter >
<jwoertink> pracabor, I don't think that's supported yet
16:37
<
pracabor >
(I can't make any statement about the correctness of this behavior, but it is at least _working_)
16:37
<
FromGitter >
<jwoertink> ah, cool. That's what I thought
16:44
<
FromGitter >
<pynixwang> method arg annotation implemented?
16:44
alex``` has joined #crystal-lang
16:45
<
FromGitter >
<r00ster91> yep: `def method(arg : String)` if you mean that
16:48
alex`` has quit [Ping timeout: 268 seconds]
16:51
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
16:53
alex``` has quit [Ping timeout: 246 seconds]
16:55
alex``` has joined #crystal-lang
16:59
<
Yxhuvud >
pracabor: works fine. `p "abcdefghijklmnop".split("").each_slice(8).map(&.join).to_a`
17:12
<
FromGitter >
<watzon> His problem is this `.map(&:join)`
17:12
<
FromGitter >
<watzon> It needs to be `.map(&.join)`
17:20
flaviodesousa has joined #crystal-lang
17:20
flaviodesousa has quit [Client Quit]
18:03
Creatornator has joined #crystal-lang
18:15
alex``` has quit [Ping timeout: 245 seconds]
18:17
alex``` has joined #crystal-lang
18:26
alex``` has quit [Ping timeout: 248 seconds]
18:27
alex``` has joined #crystal-lang
18:28
alex```` has joined #crystal-lang
18:32
alex``` has quit [Ping timeout: 245 seconds]
18:50
alex`` has joined #crystal-lang
18:50
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
18:53
alex```` has quit [Ping timeout: 246 seconds]
18:59
alex`` has quit [Ping timeout: 244 seconds]
19:01
alex`` has joined #crystal-lang
19:13
Creatornator has joined #crystal-lang
19:26
duane has joined #crystal-lang
19:46
rohitpaulk has joined #crystal-lang
19:50
<
FromGitter >
<tenebrousedge> '0' is a char
19:50
<
FromGitter >
<tenebrousedge> "0" is a string
19:51
<
FromGitter >
<tenebrousedge> and array(char) doesn't have `rjust`
19:52
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
19:52
<
pracabor >
the problem is where the `p` is
19:53
<
pracabor >
@tenebrousedge rjust wants a char, not a string, but I also had a missing .join("") in there
19:54
<
pracabor >
anyway, that might represent a bug in the compiler of some sort, but I have it working now. thanks for looking
19:58
<
FromGitter >
<watzon> Much nicer looking
19:58
<
pracabor >
that does run, but I disagree about it being readable
19:58
<
pracabor >
but thats personal preference
19:59
<
FromGitter >
<tenebrousedge> `&:join` isn't particularly readable until one becomes more familiar with Ruby
20:00
<
FromGitter >
<tenebrousedge> `&.` is a Crystal-ism
20:00
Creatornator has joined #crystal-lang
20:02
<
FromGitter >
<watzon> `&.` makes more sense imo
20:02
<
FromGitter >
<tenebrousedge> I was pained to see the reaction of the Ruby community to the idea of introducing that syntax to Ruby
20:04
<
FromGitter >
<wernerj> As a rubyist new to Crystal, &: makes more sense to me.
20:04
<
FromGitter >
<Blacksmoke16> how you figure?
20:04
<
FromGitter >
<Blacksmoke16> `.` is more clear its just a method call
20:05
<
FromGitter >
<Blacksmoke16> where in both cases `&` just represents each item in the array
20:05
<
FromGitter >
<watzon> Exactly
20:05
<
FromGitter >
<wernerj> I see it a shortcut for .send(:method)
20:06
<
FromGitter >
<tenebrousedge> I wouldn't mind both being available. Ruby's fundamental method is `send`, and the object model is based on the idea that methods are just signals to objects, which can respond to those methods as they choose
20:06
<
FromGitter >
<Blacksmoke16> time to unlearn some Ruby :P
20:06
<
FromGitter >
<watzon> I don't think we'll ever see `Object#send` in Crystal
20:06
<
FromGitter >
<tenebrousedge> but `&:` is actually a shortcut for `to_proc`, not `send`
20:07
<
pracabor >
I most definately flunked out of a ruby interview a couple years ago because I couldn't remember it was &: instead of &.
20:07
ua_ has joined #crystal-lang
20:08
<
FromGitter >
<tenebrousedge> there are probably good reasons for not having `send` in Crystal
20:08
ua has quit [Ping timeout: 244 seconds]
20:09
<
FromGitter >
<watzon> I'm fairly certain there are, I can't remember the exact reasoning though
20:09
<
FromGitter >
<tenebrousedge> you could probably implement it as a macro?
20:10
<
FromGitter >
<Blacksmoke16> you can
20:10
<
FromGitter >
<Blacksmoke16> is the corresponding issue
20:12
rohitpaulk has quit [Ping timeout: 245 seconds]
20:13
<
alex`` >
what is the way to read a project config.yml?
20:13
<
alex`` >
src/foo.cr
20:13
<
alex`` >
I want to read config/foo.yml
20:14
<
FromGitter >
<Blacksmoke16> based on the name of the cr file?
20:14
<
alex`` >
I wonder when the file is read
20:14
<
alex`` >
is it when executing the binary
20:14
<
FromGitter >
<Blacksmoke16> can either do it at runtime or compile time
20:14
<
FromGitter >
<Blacksmoke16> depends what method you use
20:14
<
alex`` >
or the contents of the yaml is in memory
20:15
<
FromGitter >
<Blacksmoke16> can either use like `YAML.parse(File.read "path/to/config.yml")`
20:15
<
FromGitter >
<Blacksmoke16> or ideally have a struct/class that defines the structure, then can do `Config.from_yaml File.read "path/to/config.yml"`
20:16
<
alex`` >
path/to/config.yml, if relative, for example 'config.yml'
20:16
<
alex`` >
it will read depending of the cwd?
20:16
<
alex`` >
I guess it is not what I want
20:16
<
FromGitter >
<Blacksmoke16> iirc its relative to the location of the executing file?
20:16
<
FromGitter >
<Blacksmoke16> i dont really remember
20:16
<
alex`` >
either relative to the project root directory or in-memory
20:17
<
FromGitter >
<Blacksmoke16> there is a `read_file` macro which would include the contents as a string at compile time
20:17
<
alex`` >
for example in src/foo/bar/baz/qux.cr
20:17
<
alex`` >
how I get the config/foo.yml easily
20:17
<
alex`` >
don’t get if it's relative to qux.cr here
20:17
<
alex`` >
or the cwd
20:17
<
FromGitter >
<Blacksmoke16> did you try just doing `File.read "config/foo.yml"`?
20:18
<
FromGitter >
<Blacksmoke16> id just try that and go from there
20:43
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
20:53
alex`` has quit [Ping timeout: 258 seconds]
20:55
alex`` has joined #crystal-lang
21:08
Creatornator has joined #crystal-lang
21:25
duane has quit [Ping timeout: 248 seconds]
22:40
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
23:09
laaron has quit [Remote host closed the connection]
23:10
laaron has joined #crystal-lang
23:16
<
FromGitter >
<Nbotz> is there any way to calculate the duration of a video in crystal?
23:16
<
FromGitter >
<Nbotz> ffmpeg doesnt return anything
23:17
<
FromGitter >
<tenebrousedge> ffmpeg -i doesn't return the duration? what kind of video is this?
23:18
<
FromGitter >
<Nbotz> webm
23:18
<
FromGitter >
<Nbotz> maybe i just didnt call it correctly? i just used `ffmpeg -i #{v} 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,// | sed 's@\..*@@g' | awk '{ split($1, A, ":"); split(A[3], B, "."); print 3600*A[1] + 60*A[2] + B[1] }'`
23:21
<
FromGitter >
<tenebrousedge> where are the webm files coming from?
23:22
<
FromGitter >
<Nbotz> video folder on server
23:22
<
FromGitter >
<Nbotz> public/videos
23:22
<
FromGitter >
<tenebrousedge> are they being generated by some process?
23:23
<
FromGitter >
<Nbotz> no, but `Dir.children` is called on every page refresh to load new videos from the folder
23:41
laaron has joined #crystal-lang