ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
absolutejam2 has quit [Ping timeout: 265 seconds]
_whitelogger has joined #crystal-lang
dwdv_ has quit [Ping timeout: 240 seconds]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 246 seconds]
<FromGitter> <sam0x17> FYI `html-minifier` shard is done and fully tested + documented https://github.com/sam0x17/html-minifier -- embeds html-minifier from npm via duktape.cr -- zero dependency html/css/js minifier
hightower3 has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> @sam0x17 that's actually a pretty cool project
<FromGitter> <watzon> Good job
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <hoang17> im writing a cli tool with crystal and i want to have `-v` or `--version` flag to print the current version of my program, is there a proper way to do it so that it is consistent with shards.yml?
<FromGitter> <hoang17> is there a way to get the version from `shard.html` at compilation time?
<FromGitter> <watzon> If you read the file in at compile time and then parse it, year
<FromGitter> <watzon> https://crystal-lang.org/api/0.30.1/Crystal/Macros.html#read_file(filename):StringLiteral-instance-method
<FromGitter> <hoang17> thank alot @watzon i think it is exactly what im looking for
<FromGitter> <watzon> Most people just maintain the current version number in two places though. shard.yml and version.cr
<FromGitter> <watzon> But of course you could always parse shard.yml in version.cr
<FromGitter> <hoang17> i see cool 👍, do you have any sample code snippet
<FromGitter> <watzon> Let me see what I can come up with really quick
<FromGitter> <hoang17> 🙏😍
<FromGitter> <watzon> Idk if this will work or not, but from what I understand it should ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dbe8ca9a3f0b17849daf745]
<FromGitter> <hoang17> thanks alot ! iam trying it out now
<FromGitter> <hoang17> @watzon it work like a charm 👏
<FromGitter> <hoang17> thanks again for your help 🙏
<FromGitter> <watzon> Good to hear, and no problem :)
<FromGitter> <hoang17> you have saved me a few hours of searching for solution 😀
<FromGitter> <watzon> Happy to help
absolutejam2 has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <hoang17> how can i print the memory usage of the current running process in crystal? something like this in golang https://golangcode.com/print-the-current-memory-usage/ 🤔
<FromGitter> <watzon> Idk if Crystal has anything like `runtime.MemStats`
absolutejam2 has quit [Ping timeout: 268 seconds]
dwdv_ has joined #crystal-lang
<FromGitter> <hoang17> is there a way to invoke syscall?
hightower3 has joined #crystal-lang
<hightower3> Hm tell me, I use File.open() { |io| ... } and I get IO object. Then during reading from it, I want to make another IO to separately read part of this data. I intended to do this with io.read_at(offset,length) {|io2|...} assuming my block would get an IO in io2. But it gets PReader. What's the catch?
<jhass> it's an IO
<FromGitter> <watzon> @hoang17 you can use backticks to call a shell function. For instance:
<FromGitter> <watzon> ``````
<FromGitter> <hoang17> yes, i just found that in the doc @watzon
<FromGitter> <hoang17> how `shards` print its `--version`
<FromGitter> <ochran> Morning, when running my crystal app from the release binary, I get the following: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dbeb40314d55a3785c7bd0c]
<FromGitter> <ochran> Anyone seen anything similar?
<hightower3> Given an IO at certain starting #pos, what's the best way to read a string of arbitrary length, from current position to first null byte?
<hightower3> is there a function which does it or I need to find the length manually?
<hightower3> (I.e. I see read_string, but it expects the length parameter, which I don't have unless I manually check first)
<hightower3> maybe gets...
<hightower3> ah Char::ZERO
<FromGitter> <bararchy> Does Object sent via a Channel will be reference or copy?
absolutejam2 has joined #crystal-lang
alexherbo2 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 240 seconds]
absolutejam2 has joined #crystal-lang
<jhass> you cannot use Object as a generic argument yet
<jhass> maybe never will be
<FromGitter> <bararchy> I mean an Object, Hash for example or Array
<jhass> depends on whether it's a Reference or a Value, obviously
<FromGitter> <bararchy> I need to maybe "refactor" my question. ⏎ Sending a Hash via channel, will do mean the other end will get the actual Hash (and changing it will effect the original sent one) or it's now a copy of the sent Hash ?
<jhass> easiest thing to try out! https://carc.in/#/r/7y1e
<FromGitter> <bararchy> hmmmm that also means then that working on the same Hash inside and outside of a `spawn` for example doesn't promise MT safety.
<FromGitter> <bararchy> ok,good to know :)
absolutejam2 has quit [Ping timeout: 265 seconds]
<FromGitter> <Blacksmoke16> @ochran `GC.stats`
<FromGitter> <Blacksmoke16> Then total bytes
<FromGitter> <Blacksmoke16> Hightower gets to end,
<FromGitter> <Blacksmoke16> ?
<FromGitter> <Blacksmoke16> er prob https://crystal-lang.org/api/0.31.1/IO.html#gets(delimiter:String,chomp=false):String?-instance-method this one
<FromGitter> <sam0x17> @watzon thanks
Human_G33k has quit [Ping timeout: 264 seconds]
HumanG33k has joined #crystal-lang
absolutejam2 has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <ImAHopelessDev_gitlab> good morning
absolutejam2 has quit [Ping timeout: 246 seconds]
<FromGitter> <bararchy> Does it make sense that this passes compile without a Warning at all? seems unexpected ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ As in, I know it works, but you kinda don't know what gonna be the return type, Int32 or String [https://gitter.im/crystal-lang/crystal?at=5dbf011de469ef4358b7706a]
<FromGitter> <Blacksmoke16> why wouldnt it work?
<FromGitter> <Blacksmoke16> shouldnt*
<FromGitter> <tenebrousedge> I would expect the last definition to be executed
<FromGitter> <bararchy> because I don't know what takes priority, the `getter` or the `def`
<FromGitter> <tenebrousedge> you can always override methods
<FromGitter> <Blacksmoke16> yea prob the last one
<FromGitter> <Blacksmoke16> what happens if you do `getter testing : Int32`
<FromGitter> <bararchy> which is the last one though? as in `getter` generates a new def using a macro
<FromGitter> <Blacksmoke16> well getter would be expanded as the first method
<FromGitter> <Blacksmoke16> since its just a macro
<FromGitter> <Daniel-Worrall> Yeah it'd be expanded with a string return from the initializer and then overwritten below with int32 return
absolutejam2 has joined #crystal-lang
<FromGitter> <lbarasti> Hi folks, I'll be doing some more live-coding in Crystal today, in 1 hour (19:00 UTC). I won't be announcing these here anymore, to keep the noise down, but please, spread the word! ⏎ Today's topics: 1. Encapsulating data into classes, 2. Type aliases, 3. Extracting tasks into modules, 4. Running tasks periodically ⏎ https://www.twitch.tv/lbarasti
absolutejam2 has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> I'll re-tweet if you're on Twitter @lbarasti
<FromGitter> <bararchy> Does anyone else get strange crashes on build with -Dpreview_mt ? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dbf19e6a03ae1584f5f8298]
<FromGitter> <lbarasti> I am indeed @bararchy https://twitter.com/lbarasti/status/1191052148890644481 Thanks!
<FromGitter> <bararchy> Happens only on docker ENV with `ubuntu:latest`
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
dwdv_ has quit [Ping timeout: 276 seconds]
ht__ has joined #crystal-lang
ht__ has quit [Remote host closed the connection]
ht__ has joined #crystal-lang
absolutejam2 has joined #crystal-lang
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> Any Machine Learning enthusiasts here? did you know there is a pure-crystal Neural Network shard to play around with which includes an image-recognition capabilities? -> https://github.com/NeuraLegion/shainet
alexherbo2 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
ht__ has quit [Quit: ht__]
<FromGitter> <sam0x17> yes and yes ;)
<FromGitter> <Daniel-Worrall> @sam0x17 Have you compared runtime speed with html-minifier vs node
<FromGitter> <Daniel-Worrall> I'm looking to use duktape in a future project so was wondering what the overhead would be like for including/running a native lib
<FromGitter> <Blacksmoke16> @watzon ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ This is the structure you're trying to deal with? [https://gitter.im/crystal-lang/crystal?at=5dbf513b9825bd6bac1f990d]
<FromGitter> <watzon> Close, `type` should be `@type`
<FromGitter> <Blacksmoke16> ok
<FromGitter> <greenbigfrog> Is there no shortcut for `Time.utc_now.to_unix`??
<FromGitter> <Blacksmoke16> its `.utc` now
<FromGitter> <greenbigfrog> whatever :) ⏎ ⏎ Is there a shortcut for `Time.utc.to_unix`?
<FromGitter> <Blacksmoke16> not that i know of
<FromGitter> <Blacksmoke16> @watzon ran into some stuff i need to refactor, mainly related to nested types. also thinking about the API more
<FromGitter> <Blacksmoke16> but ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dbf55f62a6494729c91a90c]
<FromGitter> <Blacksmoke16> is what i got so far :shrug:
<FromGitter> <Blacksmoke16> er updated
<FromGitter> <Blacksmoke16> i think this would require more than 1 discriminator tho
<FromGitter> <Blacksmoke16> we shall see
<FromGitter> <watzon> Hopefully not, but if it does that's not the end of the world
<FromGitter> <Blacksmoke16> from what i've seen this isn't the exact use case for discriminators
<FromGitter> <Blacksmoke16> normall its more like for a single abstract parent class then children
<FromGitter> <Blacksmoke16> vs nested like that
<FromGitter> <ImAHopelessDev_gitlab> `upto` = 💓
<FromGitter> <Daniel-Worrall> What are people using to make CLIs? stdlib or shard?
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
HumanG33k has quit [Ping timeout: 240 seconds]
HumanG33k has joined #crystal-lang
<FromGitter> <watzon> @Blacksmoke16 that makes sense. TDLib is a headache haha.
<FromGitter> <watzon> @codeswish standard lib is good enough for small things, but if the cli is a main focus of your app I'd use a shard
<FromGitter> <Daniel-Worrall> Believe you tagged the wrong person there, but ty