ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
mjago has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Guest4565 has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
Guest4565 has quit [Quit: ...]
bjz has joined #crystal-lang
<FromGitter> <jwoertink> I have this cURL line that works that I'm trying to translate in to a `HTTP::Client` request, but I keep getting `HTTP Error 400. The request hostname is invalid`. Can someone take a look and see what I'm missing here?
<FromGitter> <jwoertink> ```code paste, see link```
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58c4bd257ceae5376aa64b66]
<FromGitter> <fridgerator> I was getting errors like that too, then I just used `HTTP::Client.post` instead and it worked better for me
<FromGitter> <jwoertink> hmm.. is the signature the same?
<FromGitter> <fridgerator> you can still pass headers and body to `#post`
<FromGitter> <fridgerator> so I think so
<FromGitter> <jwoertink> cool. I'll try that
<FromGitter> <fridgerator> anyone successfully using json type with crystal-pg?
pawnbox has joined #crystal-lang
<FromGitter> <jwoertink> lol, yeah, that worked @fridgerator
<FromGitter> <jwoertink> I wonder if that's a bug?
<FromGitter> <fridgerator> i'm not sure
<FromGitter> <fridgerator> I just assumed I was doing something wrong, lol
pawnbox has quit [Remote host closed the connection]
<FromGitter> <jwoertink> well, then I'm doing the exact same thing wrong
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
sija has joined #crystal-lang
onionhammer has quit [*.net *.split]
jokke has quit [*.net *.split]
jamie_ca has quit [*.net *.split]
lhz has quit [*.net *.split]
jamie_ca has joined #crystal-lang
lhz has joined #crystal-lang
jokke has joined #crystal-lang
onionhammer has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
olek_poz has joined #crystal-lang
greengriminal has joined #crystal-lang
olek_poz has quit [Ping timeout: 260 seconds]
tlwr[m] has joined #crystal-lang
<crystal-gh> [crystal] Sija opened pull request #4132: GIT_REMOTE_PATTERNS regexes are being overly greedy (master...fix-doc-generator-git-remote-patterns-repo-regex) https://git.io/vyKYu
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <raydf> @fridgerator, i'm using json with crystal-pg. Are you having any trouble?
<FromGitter> <fridgerator> are you using `DB.mapping` ?
<FromGitter> <fridgerator> i'm not sure what type to set that field to
<FromGitter> <raydf> JSON::ANy
<FromGitter> <raydf> Any*
<FromGitter> <raydf> I'm not using DB.mapping
<FromGitter> <raydf> but i'm almost sure it should work
<FromGitter> <fridgerator> ok that might work
<FromGitter> <fridgerator> i'm using `DB.mapping`, if I set the type to `JSON::Any` can I assign the value using a hash?
<FromGitter> <raydf> You can use DB.mapping with the property mapped to Hash(String, JSON::Any)
<FromGitter> <raydf> i suppose that the key should be a string for your case?
<FromGitter> <fridgerator> ok great
<FromGitter> <fridgerator> yeah probably string
<FromGitter> <raydf> https://github.com/will/crystal-pg/blob/master/src/pg/decoder.cr#L194 in this code the driver decode the string to JSON::Any
<FromGitter> <raydf> with a JSON.parse
<FromGitter> <fridgerator> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58c4e2ef7ceae5376aa6ddb4]
<FromGitter> <fridgerator> `no overload matches 'Thing#settings=' with type Hash(String, String)`
<FromGitter> <fridgerator> do I need to cast each value to `JSON::Any` ?
<FromGitter> <raydf> yes
<FromGitter> <raydf> give me a second
<FromGitter> <fridgerator> I appreciate your help
<FromGitter> <raydf> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58c4e3561465c46a561e9e33]
<FromGitter> <raydf> you can use this function for converting some objects to JSON::Type and then get the JSON::Any from that
<FromGitter> <fridgerator> great, thanks!
<FromGitter> <raydf> or you could modify the function to always return JSON::Any
<FromGitter> <fridgerator> ok I think I can make this work, much appreciated @raydf
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
jamie_ca has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
splitty_ has quit [Quit: Leaving]
splitty_ has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
Qchmqs has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
olek_poz has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
pawnbox has joined #crystal-lang
qchmqs_ has joined #crystal-lang
qchmqs_ has quit [Client Quit]
Qchmqs has quit [Ping timeout: 256 seconds]
pawnbox has quit [Ping timeout: 246 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] MakeNowJust opened pull request #4134: Formatter: fix to separate defs with visibility modifiers (master...fix/crystal-format/modifier-def) https://git.io/vyKWw
crystaltest has joined #crystal-lang
pawnbox has joined #crystal-lang
crystaltest has quit [Remote host closed the connection]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
sija has quit [Quit: Connection closed for inactivity]
Philpax_ has quit [Ping timeout: 260 seconds]
alibby has quit [Ping timeout: 256 seconds]
alibby has joined #crystal-lang
Qchmqs has joined #crystal-lang
alibby1 has joined #crystal-lang
alibby has quit [Ping timeout: 240 seconds]
Philpax_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
bew78 has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 256 seconds]
Philpax__ has joined #crystal-lang
Philpax_ has quit [Ping timeout: 260 seconds]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Qchmqs has quit [Quit: Konversation terminated!]
shelvacu has quit [Quit: Goodbye for now]
shelvacu has joined #crystal-lang
<FromGitter> <raydf> np @fridgerator
sz0 has joined #crystal-lang
greengriminal has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
<FromGitter> <zatherz> ` alias Char is already defined`
pawnbox has joined #crystal-lang
<FromGitter> <zatherz> https://hastebin.com/ewaqupirat
<FromGitter> <zatherz> any idea what this is caused by?
<FromGitter> <zatherz> nevermind. I had to remove all the crystal prelude files and then update them, instead of copying on top
greengriminal has quit [Ping timeout: 240 seconds]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
sz0 has quit [Quit: Connection closed for inactivity]
mjago has quit [Quit: ERC (IRC client for Emacs 25.1.1)]
<FromGitter> <zatherz> is there a method that turns a string into an array of strings with at most X length?
<FromGitter> <zatherz> like `"abc".that_method(2) #=> ["ab", "c"]`
<FromGitter> <jwoertink> `"abc".split("").in_groups_of(2).map(&.join)` ?
<FromGitter> <zatherz> do you have any idea if that's more performant than this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58c5905d872fc8ce62f21dbc]
<FromGitter> <jwoertink> I'm not sure. You could write a small script and use `Benchmark` to see
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
marius has quit [Changing host]
marius has joined #crystal-lang
<BlaXpirit> zatherz, this should have OK performance https://carc.in/#/r/1pl5
sija has joined #crystal-lang
bew78 has quit [Quit: WeeChat 1.7]
Philpax_ has joined #crystal-lang
greengriminal has joined #crystal-lang
Philpax__ has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
Ven has joined #crystal-lang
bjz has joined #crystal-lang
<FromGitter> <fridgerator> anyone around that knows about `IO`?
<FromGitter> <fridgerator> I set up a logger for crecto : https://github.com/fridgerator/crecto/blob/logging/src/crecto/db_logger.cr
<FromGitter> <fridgerator> to print to STDOUT, you can just use `Crecto::DbLogger.set_handler(STDOUT)`
<FromGitter> <fridgerator> was hoping to do something like: ⏎ ⏎ ```f = File.open("database.log", "w") ⏎ Crecto::DbLogger.set_handler(f)``` [https://gitter.im/crystal-lang/crystal?at=58c5b760872fc8ce62f3118d]
<Papierkorb> What's the error you're getting?
<FromGitter> <fridgerator> no error, but nothing is written to the file
<Papierkorb> The data may be buffered
<Papierkorb> Try setting `f.sync = true`, or stopping your process and read the file again
<FromGitter> <fridgerator> `sync = true` worked, thanks!
<Papierkorb> fridgerator, lines 6,7: Instead of the double nil-check (not_nil!, nil?), consider doing `if l = @@log_handler; l << ...` or `@@log_handler.try{|l| l << ...}` instead
<FromGitter> <fridgerator> ok thanks, i've been curious about this pattern to
<FromGitter> <fridgerator> I know if you check `.nil?` inside of an `if` block, then its already inferred that its not nil so you don't have to check
<Papierkorb> Instead of manually writing escape sequences, you can use the Colorize module. Though I wouldn't use those at all for log files
<Papierkorb> Yes, but you can also write say `if something_nilable` without .nil?, which does the same if something_nilable is not a Bool
<Papierkorb> if course, if something_nilable is `false`, it would still not execute the branch :)
<FromGitter> <fridgerator> ok
<FromGitter> <fridgerator> wonder if I can check the type of IO, and apply colors if it is not a `File`
<FromGitter> <fridgerator> thanks for your help @Papierkorb
<Papierkorb> You could use `.is_a?(File)`, but that's not good code. Much better: Use `IO#tty?`
<Papierkorb> https://crystal-lang.org/api/0.21.1/IO.html#tty%3F%3ABool-instance-method
<FromGitter> <fridgerator> oh perfect!
<Papierkorb> Even better: If you pipe the output of your program to a file (Or systemd catches it), it'll auto-detect that it's not a TTY too.
<Papierkorb> Try this shell command: `crystal eval 'pp STDOUT.tty?' | cat` with and without the `| cat` part
<FromGitter> <fridgerator> thats slick
Googz has joined #crystal-lang
zipR4ND has joined #crystal-lang
<zipR4ND> hi all
<zipR4ND> is there any chance of getting this to compile and run correctly? https://play.crystal-lang.org/#/r/1plt/
<FromGitter> <fridgerator> https://play.crystal-lang.org/#/r/1plz
<FromGitter> <fridgerator> *shrugs* ?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
greengriminal has joined #crystal-lang
Googz has quit [Ping timeout: 260 seconds]
<txdv> how do i resolve a hostname to an ip?
<Papierkorb> txdv: If you really need to, you can use Socket::Addrinfo.resolve: https://crystal-lang.org/api/0.21.1/Socket/Addrinfo.html#resolve%28domain%2Cservice%2Cfamily%3AFamily%3F%3Dnil%2Ctype%3AType%3Dnil%2Cprotocol%3AProtocol%3DProtocol%3A%3AIP%2Ctimeout%3Dnil%29%3AArray%28Addrinfo%29-class-method
<Papierkorb> txdv: You don't need that to connect to an address though
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<txdv> in /opt/crystal/src/socket/addrinfo.cr:28: can't restrict Nil to Type
<txdv> Oo
<txdv> feels like the return clause is never called
<Papierkorb> Yep, looks like a bug -.-
bew78 has joined #crystal-lang
<bew78> Is there a way to show the source code (might be generated) after all macro expansions ?
<bew78> I know there is `{% debug() %}` but this will print only my current macro...
<txdv> hm
<txdv> is there a way to convert a string to a binary ascii representation?
<bew78> I'm looking for something like `crystal build --no-codegen --dump-after-macros` or something like that, do you think I should open an issue for that ?
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter> <luislavena> bew78: `crystal tool expand`https://github.com/crystal-lang/crystal/pull/3732
<txdv> io.write_byte(0) Error in main.cr:12: no overload matches 'IO::Memory#write_byte' with type Int32
<Papierkorb> write_bytes
<txdv> yeah but that needs a slice
<txdv> write-bytes writes 4 bytes
<txdv> and i cant cast an int32 to an uint8
<txdv> :D
<txdv> nevermind, to_u8
<bew78> luislavena: I keep getting the usage message, without any explaination on error, what did I missed ? `crystal tool expand test.cr`
<FromGitter> <drosehn> I don't understand what `expand` wants, but `crystal tool expand -c macro-expand.cr macro-expand.cr` did seem to do something more useful than printing just the usage message.
<bew78> true, and by specifying a location with `crystal tool expand -c test.cr:9:5 test.cr` gives me `no expansion found` even though `9:5` is on a macro name...
<FromGitter> <drosehn> ... although maybe I was just lucky there. I tried it on a different file which has some macros in it, and it complains "Error: cursor location must be file:line:column". And if I add a "line:column", I always seem to get `no expansion found`.
<bew78> I'm not alone!..
<bew78> maybe there is a bug in the matrice... somewhere in the universe...
<FromGitter> <drosehn> Looks like the "line:column" needs to be somewhere inside a `{{...}}`
<FromGitter> <drosehn> so it doesn't show you the result of expanding all the macros in a source file, but just what's happening inside a single macro-expansion.
<FromGitter> <drosehn> ... I think.
<bew78> Yes, I got it to work (I was not testing the right file, it's late here ^^), but yes, it does not show me more than a `{% debug() %}`..
<txdv> how do i read an u16 from an io?
<bew78> I'm trying to show get the list of instance vars from a macro (with `@type.instance_vars`), but I always get [] (see: https://carc.in/#/r/1pmf)
pawnbox has quit [Remote host closed the connection]
<FromGitter> <drosehn> Wouldn't you need to be operating on an instance of `class A` for that to work?
<bew78> it's not what I want.. maybe it's not possible :(
<FromGitter> <drosehn> I was playing around with something like this once. Here's an excerpt:
<FromGitter> <drosehn> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58c5d84ede504908227fc645]
<FromGitter> <drosehn> so then you'd call `A.class_method_names` on a class, or `some_a.method_names` on an instance of that class.
<FromGitter> <drosehn> I'm not sure that code-excerpt will work correctly outside of the file where I was playing with it, but maybe it'll give you some ideas of what you could try.
olek_poz has quit [Ping timeout: 240 seconds]
<bew78> Nice! but I can't use that for my case, as I need to generate code for the class, based on the current instance vars defined
<bew78> so cannot be called from a method
<bew78> like you do
<FromGitter> <drosehn> Hmm. but what would happen if you added `self.class_method_names` inside of the definition of `class Object ... end`
<bew78> I don't think it'll do much differences
<FromGitter> <drosehn> Oh, except that you want instance_variables, so I suspect that's going to be difficult.
bjz has joined #crystal-lang
<bew78> hmmm, I testing the limits of the current macro system implementation ^^
<bew78> I'm
<bew78> *
<FromGitter> <fridgerator> there's a video about macros floating around somewhere of a presentation by one of the core members thats pretty good
<bew78> ah? do you have the link?
<FromGitter> <fridgerator> I don't, i'm looking for it
bjz has quit [Client Quit]
greengriminal has quit [Quit: This computer has gone to sleep]