RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.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
duane has joined #crystal-lang
zachk has quit [Quit: Leaving]
wontruefree has quit [Quit: bye]
duane has quit [Ping timeout: 240 seconds]
<FromGitter> <reiswindy> Hi, I have a question about the `.to_json`implementation in Tuples. Why is it implemented with macros instead of using `each_with_index`? Is it for performance reasons or something else?
alex`` has quit [Ping timeout: 260 seconds]
ashirase has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <kolyaio> Hey, I want to format timestamp from Postgres. How can I do it ?
<FromGitter> <kolyaio> I getting string from the database created by amber’s migration of the database timestamp.
<FromGitter> <Timbus> Postgres returns an iso-formatted time. You can just use `Time.parse_iso8601` on the returned value? But that being said, Amber uses the Granite ORM? I haven't used that, but can you not just make the field a `Time` type?
<FromGitter> <Timbus> Amazing.. I just looked and the granite documentation doesn't really cover anything regarding fields. But yes you can just use `field a_time : Time`in your model, and you won't need to do the parsing. Does that help @kolyaio ?
wontruefree has joined #crystal-lang
<FromGitter> <kolyaio> Yeah but that’s looks like a bad solution
<FromGitter> <kolyaio> Because I already have timestamp field called created_at and updated_at
<FromGitter> <kolyaio> Btw what orm should I use instead ?
alex`` has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <kolyaio> I get this error: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b41c2fb3d8f71623d65bd96]
<FromGitter> <bew> why is there a `>>` between the date & the time?
<FromGitter> <bew> it fails to parse because of that
<FromGitter> <kolyaio> @bew I don’t know from where it gets it because in my code there no such thing
<FromGitter> <kolyaio> `<%=Time.parse_rfc3339("2018-07-06 16:00:57 UTC")%>`
<FromGitter> <bew> it says that in `src/controllers/post_controller.cr` (line 4) there is a time parsing using `parse_iso8601`
<FromGitter> <bew> though, maybe it comes from generated code
<FromGitter> <bew> what do you have in that file?
wontruefree has quit [Quit: bye]
<FromGitter> <kolyaio> No arrow :O ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b41c87963042f2df35f9245]
<FromGitter> <kolyaio> Now it says `ERROR: Invalid timezone at 19: "2018-07-06 16:00:57>> UTC" (Time::Format::Error)`
<FromGitter> <bew> I think I've found the problem
<FromGitter> <kolyaio> @bew what’s the problem :O
<FromGitter> <bew> 2sec I'm checking
<FromGitter> <bew> what did you do to fix the "invalid number" error (your first one)
<FromGitter> <bew> ?
<FromGitter> <bew> hm no, it's not what I thought
<FromGitter> <bew> the `>>` is not the problem, it's added in the error message to help locate the issue in the string it's trying to parse
<FromGitter> <bew> do you know where the string is coming from? is it your code?
Philpax has joined #crystal-lang
Raimondii has joined #crystal-lang
ashirase has quit [Ping timeout: 268 seconds]
Raimondi has quit [Ping timeout: 264 seconds]
Raimondii is now known as Raimondi
ashirase has joined #crystal-lang
<FromGitter> <Timbus> It's coming from postgres, and that's not an ISO formatted time I guess? PG docs say it does iso time..
<FromGitter> <Timbus> > Yeah but that’s looks like a bad solution ⏎ > Because I already have timestamp field called created_at and updated_at ⏎ ⏎ I don't understand.. what does that have to do with anything? Are you trying to access those fields? I think you need to show your Post model. [https://gitter.im/crystal-lang/crystal?at=5b41d7923d8f71623d65d9d6]
_whitelogger has joined #crystal-lang
<FromGitter> <foi> Hi! Why nodejs (10.x) tcp socket can't connect to crystal (0.25.1) tcp server? With crystal tcp-client to nodejs-tcp-server - OK ⏎ ⏎ CODE ⏎ ⏎ server.cr ... [https://gitter.im/crystal-lang/crystal?at=5b41ddd13572e970c17f7a32]
<RX14> you have specified to listen only on "localhost"
<FromGitter> <foi> Error: connect ECONNREFUSED 127.0.0.1:8888 ⏎ from nodejs cleint, but via telnet localhost 8888 is ok
<RX14> if the nodejs server is on a different server
<RX14> then it can't connect
<FromGitter> <foi> @FromIRC both on my pc
<RX14> no docker?
<FromGitter> <foi> aaaah. I have docker... i stopping him
<RX14> no I meant was the nodejs running in docker
<RX14> if telnet works but nodejs doesn't - on the same terminal then I haaven't a clue
<FromGitter> <foi> No, not in container
<FromGitter> <foi> i can record video
<RX14> then not a clue
<FromGitter> <Timbus> Yeah if anything it's a node issue at this point, if crystal is listening and you can confirm with telnet.
<FromGitter> <foi> Sorry, i'am not sure where is error. I will record very short video with demonstation
Philpax has quit [Read error: Connection reset by peer]
<FromGitter> <Timbus> Usually it's just a mismatch with what you bound to... You might want to try binding to no name instead of "localhost". Binding to "0" might also work. ⏎ You might also want to specify the host explicitly from the client.
<FromGitter> <foi> https://youtu.be/XzMQBpFKEas
<FromGitter> <foi> Binding crystal tcp server on 0.0.0.0 helps! Thanks!
<FromGitter> <Timbus> np
mech422_ has joined #crystal-lang
mech422 has quit [Ping timeout: 248 seconds]
mech422_ has quit [Ping timeout: 268 seconds]
mech422 has joined #crystal-lang
mech422 has quit [Ping timeout: 276 seconds]
<crystal-gh> [crystal] RX14 closed pull request #6348: Fix access of class vars from generic metaclass (master...bug/3719-class_var_from_generic_metaclass) https://git.io/fNejU
<travis-ci> crystal-lang/crystal#a441539 (master - Fix access of class vars from generic metaclass (#6348)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/401408635
<DeBot> https://github.com/crystal-lang/crystal/pull/6348 (Fix access of class vars from generic metaclass)
lvmbdv has joined #crystal-lang
<FromGitter> <kolyaio> @bew It comes from view
<FromGitter> <kolyaio> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b41f2c6a99e1e52b71fbf0c]
<crystal-gh> [crystal] straight-shoota opened pull request #6356: Fix: Add type restriction to Crypto::Bcrypt::Password#== (master...jm/fix/bcrypt-password-eq) https://git.io/fNv76
Philpax has joined #crystal-lang
<FromGitter> <foi> HI! Why when i connecting from nodejs tcp client (to crystal tcp server) i need always to to add \n to end of tcp-message (otherwise connection is not closed)? In crystal tcp client OK ⏎ ⏎ crystal tcp server ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b4205a481816669a43a3281]
lvmbdv has quit [Ping timeout: 260 seconds]
<oprypin> foi, `gets` is literally "read until you find `\n`"
<oprypin> there also isn't really such a thing as "end" in sockets
Philpax has quit [Quit: Leaving]
<FromGitter> <foi> @oprypin Oleh, but why crystal client << "client" works without "\n" ?
<oprypin> probably because in nodejs you are not doing "read until you find `\n`" but rather "read some number of bytes"
<oprypin> yeah i dunno, this is the only thing i can say would be useful https://crystal-lang.org/api/0.25.1/IO.html#read%28slice%3ABytes%29-instance-method
<oprypin> you need to use a protocol with TCP sockets, they don't have messages, it's just a stream of bytes
<oprypin> are you using this or what? cuz i have no idea https://nodejs.org/api/net.html#net_event_data
<FromGitter> <foi> @oprypin Thanks! it's a Low-level stuff... I'am trying to make text protocol compatible with node-json-socket.
<FromGitter> <foi> @oprypin crystal version https://github.com/foi/crystal-json-socket
Philpax has joined #crystal-lang
lvmbdv has joined #crystal-lang
<oprypin> u can use `gets('#')` and https://crystal-lang.org/api/0.25.1/IO.html#read_string%28bytesize%3AInt%29%3AString-instance-method
<oprypin> no, actually dont use `gets`, `read_line` is always the better alternative https://crystal-lang.org/api/0.25.1/IO.html#read_line%28%2Aargs%2C%2A%2Aoptions%29%3AString-instance-method
<FromGitter> <j8r> `client` is an IO?
lvmbdv has left #crystal-lang [#crystal-lang]
<FromGitter> <foi> @oprypin THANKS! I'll try it. @j8r client is a TCPsocket.
<FromGitter> <LVMBDV> trying irc.gitter.im
<oprypin> y tho
<FromGitter> <LVMBDV> was the freenode channel here first, before the gitter?
<oprypin> probably
<FromGitter> <j8r> TCPSocket inherit from IO, so you could use maybe ⏎ ⏎ ```slice = Bytes.new 8 ⏎ client.raw &.read slice``` [https://gitter.im/crystal-lang/crystal?at=5b420e9e81816669a43a3fef]
<oprypin> i've already specified all needed methods
<FromGitter> <Daniel-Worrall> Does http client handle cookies by default or do I need to do it
<FromGitter> <Daniel-Worrall> As in passing the relevant ones to the next request
<FromGitter> <Daniel-Worrall> If not is there something that does
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/fNvNm
<crystal-gh> crystal/master afeaee4 Ary Borenszweig: Encoding: compare with case insensitive UTF-8 or UTF8 to avoid using iconv when not necessary (#6355)
<FromGitter> <foi> @oprypin Many thanks for your advice! Brilliant
Philpax has quit [Ping timeout: 264 seconds]
<oprypin> @foi `socket.gets(@delimeter).not_nil!.split(@delimeter).first.to_i` -> `socket.read_line(@delimiter, chomp: true).to_i`
<travis-ci> crystal-lang/crystal#afeaee4 (master - Encoding: compare with case insensitive UTF-8 or UTF8 to avoid using iconv when not necessary (#6355)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/401446295
<DeBot> https://github.com/crystal-lang/crystal/pull/6355 (Encoding: compare with case insensitive UTF-8 to avoid using iconv when not necessary)
wojnar has joined #crystal-lang
wojnar has quit [Quit: Leaving]
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
<FromGitter> <BlobCodes> Hello, I got a problem with compiling my crystal program on Ubuntu 1.1.0
<FromGitter> <BlobCodes> root@vmd28694:/var/www/status# crystal build status.cr --release ⏎ *main.o: In function `_*crystal_main': ⏎ /usr/share/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `SSL_library_init' ⏎ /usr/share/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `SSL_load_error_strings' ⏎ /usr/share/crystal/src/openssl/lib_ssl.cr:213: undefined reference to `OPENSSL_add_all_algorithms_noconf'
<FromGitter> <LVMBDV> it doesn't work ((04:13:01 PM) LVMBDV: trying irc.gitter.im)
<FromGitter> <kingsleyh> @BlobCodes are you missing some dependencies on ububtu?
<FromGitter> <BlobCodes> No, I installed all packages on https://github.com/crystal-lang/crystal/wiki/All-required-libraries
<FromGitter> <kingsleyh> @BlobCodes I use 16.04.3 LTS
<FromGitter> <BlobCodes> I use 16.04.4 LTS - I don´t know why I wrote 1.1.0..
<FromGitter> <kingsleyh> the error messages look to me like lib ssl is not found or is somehow incompatible if it is found
<FromGitter> <BlobCodes> OpenSSL 1.1.0h 27 Mar 2018
<FromGitter> <BlobCodes> Crystal 0.25.1 [b782738ff] (2018-06-27) ⏎ ⏎ LLVM: 4.0.0 ⏎ Default target: x86_64-unknown-linux-gnu [https://gitter.im/crystal-lang/crystal?at=5b4245fd81816669a43a9bd3]
<FromGitter> <kingsleyh> I've got: openssl 1.0.2g-1ubuntu4.13
<FromGitter> <kingsleyh> mine looks the same:
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b42469e89db5e701cabe2dc]
<FromGitter> <bew> @kolyaio the time string is not in iso8601 format, so it can't work
<FromGitter> <BlobCodes> I fixed it - the solution is to downgrade the libssl dev package: sudo apt-get install libssl-dev=1.0.2g-1ubuntu4.13
<FromGitter> <kingsleyh> Cool
<FromGitter> <BlobCodes> It doesn´t matter what the real openssl version is ⏎ root@vmd28694:~# openssl version -v ⏎ OpenSSL 1.1.0h 27 Mar 2018 ⏎ < [https://gitter.im/crystal-lang/crystal?at=5b424a82e534eb69a5d2553b]
<FromGitter> <Grabli66> Is it possible to make it work? https://play.crystal-lang.org/#/r/4gxj
<FromGitter> <Grabli66> Thanks. Looks like magic :)
phineas0fog has joined #crystal-lang
<phineas0fog> Hello friends, I have a little problem with crystal compilation on alpine linux (gitlab runner) :
<phineas0fog> \/crystal-0.25.1-1/share/crystal/src/errno.cr:224: undefined reference to `errno'
phineas0fog has quit [Quit: Leaving]
_whitelogger has joined #crystal-lang
<rocx> do macros function more like lisp's (more or less evaluated at runtime) or like C's (only evaluated at compiletime)?
ishahnaz has joined #crystal-lang
<Yxhuvud> The latter
<rocx> ah. guess that shoots string interpolation to require a certain file out the window.
<rocx> so that leaves me to having twenty or so lines in a case, all looking alike except for namespace/module names.
<Yxhuvud> well, as long as the string is known beforhand it may work if you do it correctly. But it could be that require statements are different
<rocx> it's taken from a command line argument so guess that shoots any idea about not using a case..end block.
akaiiro has joined #crystal-lang
<oprypin> rocx, yeah but what about generating that case..end block with macros?
<rocx> ...oh right forgot about that part.
<rocx> thanks.
<oprypin> one needs to think about macros as a way to reduce boilerplate, and not some kind of magical tool
<rocx> i come from a lisp background but i haven't quite grokked macros there either
akaiiro has quit [Ping timeout: 240 seconds]
<rocx> oprypin: thank you for that tip on macros.
ishahnaz has quit []
akaiiro has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
benharri has quit [Quit: not here right now...]
benharri has joined #crystal-lang
akaiiro has quit [Ping timeout: 276 seconds]
Philpax has joined #crystal-lang
duane has joined #crystal-lang