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
<FromGitter> <Timbus> Yeah, looks like crystal apps freak out if their stdin is closed: ⏎ `perl -e 'if (!fork){close STDIN; exec("crystal")}'`
<FromGitter> <Timbus> guess i'll check github for issue
<FromGitter> <talbergs> https://carc.in/#/r/4h5w I magined to push to module array, but it not compiles. :(
<jokke> Hello o/
<jokke> i'm trying to set up a tls socket in crystal and for some reason it isn't able to negotiate a cipher with a client. The exact same settings on ruby work.
<jokke> any ideas what might be going wrong?
<FromGitter> <l1meon> @talbergs https://carc.in/#/r/4h6p
zachk has quit [Quit: Leaving]
<FromGitter> <Blacksmoke16> saying `it works in Ruby` isnt a good comparison ;p
<FromGitter> <Blacksmoke16> whats the error?
<jokke> sorry. i just picked up where my coworker in a different timezone left it. have to debug for a bit first to get into it
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <Blacksmoke16> i never used that portion of Crystal but may be able to help decipher the error
asterite_ has joined #crystal-lang
DTZUZU2 has joined #crystal-lang
literal_ has joined #crystal-lang
justinmcp has joined #crystal-lang
bmcginty_ has joined #crystal-lang
asterite has quit [Ping timeout: 240 seconds]
bmcginty has quit [Ping timeout: 240 seconds]
justinmcp_ has quit [Ping timeout: 240 seconds]
early has quit [Ping timeout: 260 seconds]
DTZUZU has quit [Ping timeout: 260 seconds]
literal has quit [Ping timeout: 260 seconds]
asterite_ is now known as asterite
early has joined #crystal-lang
duane has joined #crystal-lang
duane has quit [Ping timeout: 264 seconds]
literal_ is now known as literal
duane has joined #crystal-lang
<jokke> ok so the error ist: Unhandled exception: Failed create ssl_socket : SSL_accept: error:1408A0C1:SSL routines:ssl3_get_client_hello:no shared cipher (Exception)
<jokke> *is
<jokke> this is the working ruby code for the ssl server
<jokke> the ciphers are DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256
<jokke> this is the crystal code: https://p.jokke.space/MdqLW/
<jokke> i don't understand what the difference is
<jokke> also i have no idea how to set socket options
<FromGitter> <Timbus> In the ruby you wrap the tcp server into a sslserver.. In the crystal you do not. Are you missing that code or
<FromGitter> <Timbus> I assume you've seen the server example here: https://crystal-lang.org/api/0.25.1/OpenSSL.html where it wraps the socket every time a client connects
<FromGitter> <Timbus> otherwise the context setup looks the same I guess, except we can't see the ciphers you're passing in the ruby example. Can assume it's the same as the crystal though
<jokke> yeah, sorry
<jokke> yeah the ciphers are the same
<FromGitter> <Timbus> cool. yeah I think that's the obvious stuff out the way.
<FromGitter> <Timbus> does it work if you just use the default ciphers? or maybe even try setting it to 'unsafe'?
<FromGitter> <Timbus> sorry, *insecure
<jokke> mhm i try
<jokke> Timbus: nope
<jokke> still get the same erro
<jokke> *error
<jokke> i wonder why it's ssl3_get_client_hello
<jokke> even though i specified tlsv1_2
pabs has quit [Ping timeout: 255 seconds]
pabs has joined #crystal-lang
duane has quit [Ping timeout: 240 seconds]
go|dfish has quit [Remote host closed the connection]
pbodev1 has joined #crystal-lang
go|dfish has joined #crystal-lang
<jokke> und diese lib wird genutzt: https://tls.mbed.org/api/ssl_8h_source.html#l00197
<jokke> oh sorry, wrong chat :D
<jokke> (just the last one)
<FromGitter> <Timbus> Oh.
<FromGitter> <Timbus> I couldn't reproduce the error, because I copied your code nearly exactly and setup my own certs
<FromGitter> <Timbus> turns out I get the error when my certificates are faulty, or missing
<FromGitter> <Timbus> Try making a new self-signed certificate jokke. `openssl req -newkey rsa:2048 -nodes -keyout pkey.pem -x509 -days 365 -out cert.pem`. then use the generated pkey.pem and cert.pem as the private_key and certificate_chain. It should work (at least it does for me)
<FromGitter> <umutuluer> hi guys
alex`` has joined #crystal-lang
<jokke> hm
<jokke> hey uamutuluer
<jokke> *umutuluer
<jokke> any ideas why this throws: Unhandled exception: No address found for foo.bar.baz:5000?
<FromGitter> <umutuluer> i have a problem i spent hours about this but i cant fix
<jokke> ok that's a bad example
<jokke> because foo.bar.baz obviously doesn't exist
<jokke> but it doesn't work with any host
<FromGitter> <Timbus> Broken DNS setup I guess?
<FromGitter> <umutuluer> Δ° define properties in class, but i dont want to fill in initialize
<jokke> on multiple hosts
<FromGitter> <umutuluer> any idea?
<FromGitter> <Timbus> Hm. It's not because there's a path in the connection is it
<jokke> i dunno
<jokke> but it _should_ work, right?
<FromGitter> <Timbus> Umut: You can set default values, or define them as nillable
<FromGitter> <Timbus> Yeah, for sure
<FromGitter> <umutuluer> @Timbus thanks
<jokke> Timbus: wtf... not even this works: https://p.jokke.space/8qYc/
<FromGitter> <Timbus> Yeah, really seems like a DNS issue. Like at this point maybe it's a system library issue
<jokke> god damn
<FromGitter> <Timbus> I assume a TCPSocket also fails?
<jokke> yeah
<jokke> from /opt/crystal/crystal-0.25.0-1/share/crystal/src/socket/tcp_socket.cr:112:33 in 'initialize'
<FromGitter> <Timbus> mmh. So I guess, somehow, your libc isn't able to resolve the address. Really strange but it can happen if you're using docker or even a different libc linux like alpine
Raimondi has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
ashirase has quit [Ping timeout: 240 seconds]
ashirase has joined #crystal-lang
<FromGitter> <nekocentral> I'm having a small problem defining a variable ⏎ ⏎ ``` proxy_set_header Connection "Upgrade";`````` [https://gitter.im/crystal-lang/crystal?at=5b447b44e534eb69a5d70b89]
<FromGitter> <nekocentral> i can't figure it out how to fix it
<FromGitter> <drum445> Not sure how it will deal with quotes inside quotes
<FromGitter> <drum445> Can you change the quotes around Upgrade to single
<FromGitter> <nekocentral> i dont know is nginx accepts that
<FromGitter> <nekocentral> let me try 1 sec
<FromGitter> <nekocentral> it says it accepts it
<FromGitter> <drum445> Top, problem solved then?
<FromGitter> <nekocentral> for now i guess
<FromGitter> <nekocentral> thank you
<FromGitter> <drum445> np
<FromGitter> <nekocentral> I'm wondering, can i call a program like acme.sh from a crystal application?
<FromGitter> <bararchy> ````bash /path/to/acme.sh` ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5b447da19b82c6701bb13ffd]
<FromGitter> <bararchy> or ⏎ ⏎ ````/bin/bash /path/to/acme.sh```` [https://gitter.im/crystal-lang/crystal?at=5b447dbc89db5e701cb09f56]
<FromGitter> <bararchy> if you want more security
<FromGitter> <bararchy> or just ⏎ ⏎ ````/path/to/acme.sh```` ⏎ ⏎ If it's executable with shabang [https://gitter.im/crystal-lang/crystal?at=5b447de281816669a43f435e]
<FromGitter> <nekocentral> damn, that is nice to know ⏎ and using file i can make folders right?
<FromGitter> <nekocentral> and thank you bar
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> np :)
<FromGitter> <bararchy> `Dir`
<FromGitter> <Timbus> FileUtils has mkdir
<FromGitter> <nekocentral> good, than i can litterly make a complete nginx configurator using crystal including folder and LE
<FromGitter> <bararchy> https://crystal-lang.org/api/0.25.1/Dir.html#mkdir%28path%2Cmode%3D511%29-class-method
<FromGitter> <Timbus> why do they.. both have it..
<FromGitter> <nekocentral> thanks, and under fileUtils there is also something to create symlinks right
<FromGitter> <bararchy> @Timbus https://crystal-lang.org/api/0.25.1/FileUtils.html#mkdir%28path%3AString%2Cmode%3D511%29%3ANil-instance-method
<FromGitter> <bararchy> `FileUtils.mkdir("src")` is an Alias for Dir.mkdir
<FromGitter> <bararchy> I think we don't actually need FileUtils and you most likely have 99% of functionality in Dir or File
<FromGitter> <nekocentral> i know that i can check and follow symlinks with file.real_path
<FromGitter> <bararchy> https://crystal-lang.org/api/0.25.1/File.html#link%28old_path%2Cnew_path%29-class-method
<FromGitter> <bararchy> `File` can also create links
<FromGitter> <nekocentral> and file.Link does hard links ⏎ a found it ⏎ file.Symlink
<FromGitter> <nekocentral> my god crystal is handy
<FromGitter> <nekocentral> shoudnt have given up back then
<FromGitter> <Timbus> Hm, reminds me of the ruby libary that just aggregates all of the other file utilities
tilpner has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> RX14 can we get rid of FileUtil?
<RX14> not yet
<FromGitter> <bararchy> it seems that all the functionality is copied in Dir and File
<RX14> no its not lol
<RX14> mkdir_p
<RX14> rm_rf
<FromGitter> <bararchy> RX14 : https://crystal-lang.org/api/0.25.1/Dir.html#mkdir_p%28path%2Cmode%3D511%29-class-method
<FromGitter> <bararchy> ...
<RX14> yeah I was wrong about mkdir_p
<RX14> rm_rf is the main one
<FromGitter> <bararchy> if it's the only offender we can just copy it from FileUtils to Dir
<RX14> and some cp magic
<RX14> no
<RX14> why are you so intent on removing it right away>
<RX14> it needs to go bit it'll take time
<RX14> after we get Path merged
<FromGitter> <bararchy> oh, i'm not in any "hatred rage" against it XD it just seemed that it's a buig class of aliases and maybe flew under the radar
<FromGitter> <bararchy> just wanted to point it out
<RX14> no i've tried to remove it before and come up against issues
<FromGitter> <bararchy> btw, how hard is it to make `.dig` for Hash?
<jokke> hey
<jokke> same problem still
<jokke> i'm wondering why SSL3_GET_CLIENT_HELLO is being called even though i've disabled SSLv3
<FromGitter> <bararchy> jokke I think it's just OpenSSL's way of saying "protocol negotiation in process"
<jokke> mmh
<FromGitter> <bararchy> Does it return a "No shared cipher" error?
<FromGitter> <bararchy> Also even when disabling the SSL3 protocol the system is still `aware` of it, so it will accept a connection and say "I don't support you"
tilpner has joined #crystal-lang
<FromGitter> <Timbus> The only way I got that error was with a missing certificate: ⏎ Unhandled exception: Failed create ssl_socket : SSL_accept: error:1408A0C1:SSL routines:ssl3_get_client_hello:no shared cipher (Exception)
<FromGitter> <Timbus> had nothing to do with the cipher
<FromGitter> <bararchy> ...... `no shared cipher (Exception)`
<FromGitter> <bararchy> XD
<FromGitter> <aisrael> Is there a way to, like, import a static function into the "top level" namespace (ideally limited to this specific file only, but if global then can maybe work with that)? E.g., like in Java `import static java.lang.Math.sqrt;` then you can just go `sqrt(x)` anywhere? ⏎ ⏎ Will including a `module` outside of a class/module work?
<RX14> you can define functions at the top-level which are just aliases
<RX14> and then make them private
<RX14> bit of a hack but
<FromGitter> <Timbus> Funny. I've been working on an implementation of lexical scoped imports in crystal..
<RX14> why?
<RX14> imports don't really make sense in crystal
<FromGitter> <aisrael> Yeah so I just tried it (sorry, was lazy earlier) and yes, `include`ing a `module` in the "global" namespace makes the module functions available at top level
<FromGitter> <aisrael> But once you do that, it's global, not just file-scoped (so, global namespace pollution is a problem)
<RX14> yes exactly
<RX14> include is not the right way to do imports
<RX14> why are you desperate to use these class methods without a reciever?
<RX14> just type a bit more it's not a big deal
<RX14> if it's deeply nested, just use an alias
<FromGitter> <Timbus> Ah, the reason I wan lexical imports is for UFCS
<FromGitter> <aisrael> I mean, even Javascript has `import { foo } from "foo";` so...
<FromGitter> <Timbus> scoped to a file/block
<RX14> but UFCS doesnt make sense in crystal
<FromGitter> <aisrael> Yeah, exactly
<RX14> and JS has... imports
<RX14> crystal has a global namespace
<RX14> they're not compatible
<FromGitter> <Timbus> My plan for UFCS was that receiver methods take the invocant as the first argument
<RX14> but why
<RX14> thjats the implementation, whats the reason?
<FromGitter> <Timbus> So you can implement helper methods, such as your own Int.hours
<FromGitter> <Timbus> and library makers don't have to monkey patch
<FromGitter> <Timbus> seems.. pretty straightforward? or so I thought
<RX14> well i'm not sure how that'd be implemented at all without compiler modifications
<FromGitter> <Timbus> that's what i said
<FromGitter> <Timbus> im doing right now
<RX14> but that PR won't be accepted
<FromGitter> <Timbus> guess ill call it crystal++ :p
<RX14> you can't just PR UFCS to crystal without even discussing it first and expect it to be accepted
<RX14> there's been discussions about UFCS before though
<RX14> and the answer was no
<FromGitter> <Timbus> id prefer to at least prove out the concept, im not expecting to just .. do that
<FromGitter> <Timbus> i saw discussions without considering it in context of an import
<RX14> but the technical feasability of UFCS is not the issue
<FromGitter> <Timbus> ufcs doesn't work without imports. imports arent very useful without ufcs
<RX14> so you're not creating crystal any more
<RX14> you're... forking it
<FromGitter> <Timbus> i also saw requests for 'function piping', and 'ruby refinements' which this would also mostly cover
<FromGitter> <Timbus> im just trying stuff dude, i think if it works and I can prove it out to be simple and useful, its then worth considering?
<RX14> I just don't want to see you waste your time
<RX14> UFCS is a major major change to the language
<RX14> it's far too late
<RX14> neither UFCS or imports will be merged, as long as you understand that then you can experiment for fun as much as you want
Heaven31415 has joined #crystal-lang
<Heaven31415> Hi
<Heaven31415> Is there a way in Crystal to convert string into type object at runtime? Like foo("Int32") => Int32
<RX14> I don't think so
<RX14> why?
<Heaven31415> I'm reading some files and wanted to create objects of specified type based on content of the file
<FromGitter> <cserb> Still looking for a simple way in crystal to transmit data between peers (like in a p2p env) similar to gRPC
<FromGitter> <cserb> Anyone with experience?
<FromGitter> <aisrael> @Heaven31415 The closest is a `Hash(String, Class)`
<FromGitter> <yxhuvud> I'd probably use a case statement.
alex`` has quit [Ping timeout: 260 seconds]
<FromGitter> <umutuluer> Hi again
alex`` has joined #crystal-lang
<FromGitter> <bararchy> hi @umutuluer
<FromGitter> <umutuluer> i try to use array sort method
<FromGitter> <umutuluer> but array is not normal array that has string or int
<FromGitter> <umutuluer> it has class
<FromGitter> <umutuluer> [] of MyClass
<FromGitter> <umutuluer> i want to sort as my_class_instance.price
<FromGitter> <j8r> you want to sort depending of a value in the Class?
<FromGitter> <umutuluer> yes
<FromGitter> <bararchy> ```my_array.sort_by {|member| member.value}```
<FromGitter> <j8r> you can pass a block
<FromGitter> <umutuluer> i checked api page but error occurred
<FromGitter> <umutuluer> just a secon
<FromGitter> <umutuluer> d
<FromGitter> <umutuluer> my code is here
<FromGitter> <umutuluer> i run the code in play.crystal-lang.org
<FromGitter> <umutuluer> error message is : Error in line 62: undefined method 'sort_by ' for Array(Order) (did you mean 'sort_by'?) ⏎ ⏎ Rerun with --error-trace to show a complete error trace.
alex`` has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
<FromGitter> <bararchy> Working for me @umutuluer
<FromGitter> <bararchy> btw if you dont initialize and just use the `Order` as a container maybe use a struct instead of class
<FromGitter> <umutuluer> yes, you are right @bararchy
<FromGitter> <umutuluer> i forgot define as new variable
<FromGitter> <asterite> Jarrod Funnell: I like UFCS and I like imports over require. If it can solve monkey patching, I wouldn't mind a discussion about it and a PR
<FromGitter> <umutuluer> thanks
<FromGitter> <umutuluer> im gonna use struct, i guess only pass variable not reference
<FromGitter> <bararchy> @asterite oh, no! let's not :\ Crystal is Crystal, let's not force the lang to be something it isn't meant to be
<FromGitter> <asterite> He said he had a way to make it work, why not experiment with that? Wouldn't you like to import some functions into a file without having them affect the global namespace? I think it's a nice thing.
<FromGitter> <asterite> Like, import "number/humanize" only when needed. Or those time methods like 1.second and so on
<FromGitter> <bararchy> because you can already have those using ⏎ ⏎ ```require "http/client" ⏎ ``` ⏎ ⏎ and only get client, and it won't pollute the global namespace because you get all functionality undr Client [https://gitter.im/crystal-lang/crystal?at=5b44ae9e3572e970c1855f66]
<FromGitter> <bararchy> @umutuluer Maybe like this? https://play.crystal-lang.org/#/r/4hcq
<FromGitter> <umutuluer> @bararchy thanks it is clear
alex`` has quit [Quit: WeeChat 2.1]
<FromGitter> <umutuluer> but why do you use **args in initialize
<FromGitter> <umutuluer> i dont understand this
<FromGitter> <j8r> If he wants to only import one Class from a file, this means it hasn't well organized its project in multiple files
<FromGitter> <bararchy> @j8r < true
<FromGitter> <bararchy> @umutuluer I was about to add all the param set in the initialize method instead of using properity, but just wanted to show the point of using struct and initialize `Time` inside the initialize method
<FromGitter> <umutuluer> okey, so do i use Order.new(user_id = 5) ?
<FromGitter> <umutuluer> ok, i get it thanks
<FromGitter> <umutuluer> :)
<FromGitter> <bararchy> @umutuluer -> https://play.crystal-lang.org/#/r/4hd4
<FromGitter> <bararchy> if you do `user_id = 5` it will create a useless allocation
<FromGitter> <bararchy> btw, this looks interesting, is that some kind of wallet or something for bitcoin?
<crystal-gh> [crystal] ysbaddaden reopened pull request #3536: Add dig method to Enumerable (master...hash-dig) https://git.io/vXKFP
<crystal-gh> [crystal] ysbaddaden closed pull request #3536: Add dig method to Enumerable (master...hash-dig) https://git.io/vXKFP
<FromGitter> <Grabli66> Hi! Please, help. What is wrong? https://play.crystal-lang.org/#/r/4hd6
<FromGitter> <bararchy> @Grabli66 well, it's kinda self explenatory, you passed the wrong Type into a method that expects another type
<FromGitter> <Grabli66> Can you, please, show me, where i do that? :)
<FromGitter> <bararchy> ProtocolTwo#send' expects ⏎ ⏎ 1) ProtocolTwo#send(s : RequestTwo) ⏎ and you tried ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5b44b3053572e970c1856b6b]
<FromGitter> <bararchy> it tells you, in line 42
<FromGitter> <bararchy> `in line 42: no overload matches 'ProtocolTwo#send' with type RequestOne`
<FromGitter> <Grabli66> But protocol in 42 line must be ProtocolOne, because itemOne = ItemOne.new(ProtocolOne.new)
<FromGitter> <umutuluer> @bararchy yes, actually im working a company that is related to exchange
<FromGitter> <bararchy> @Grabli66 It can be both, Protocol one and Protocol two. I don't think method signitures "like" logic works in Class objects
<FromGitter> <umutuluer> we are using golang but i want to use crystal in production, my cto says show me talents of crystal :)
<FromGitter> <bararchy> @umutuluer that's cool! what company? it seems I know alot of Exchange companies using Go
<FromGitter> <bararchy> no sure why
<FromGitter> <Grabli66> @bararchy , is it possible to make it work? :)
<FromGitter> <bararchy> hell, no clue @Grabli66 I might be wrong though, better get RX14, @asterite or @bcardiff to validate my claim
<FromGitter> <Grabli66> @bararchy ok
<FromGitter> <bararchy> I wish we have @coreteam
<FromGitter> <Grabli66> I wish a generics works
<FromGitter> <umutuluer> @bararchy unfortunalety i could not give any information about company. because there is a privacy contract
<FromGitter> <bararchy> oh, makes sense
<FromGitter> <bararchy> why do they use Go?
<FromGitter> <bararchy> as oppose to Python, Ruby, Java, C++ , etc..
<RX14> @Grabli66 the instance variable is of type Protocol
<RX14> therefore it can be ProtocolOne or ProtocolTwo
<FromGitter> <bararchy> I was right, yey!
<FromGitter> <Grabli66> RX14, you are right. But how to make it work? :)
<RX14> it doesn't matter what the type is at runtime
<RX14> the compiler has no idea what type it is at runtime
<FromGitter> <umutuluer> why golang, because it is fast and fast development and lastly, the most important thing is traffic, high traffic in the web
<RX14> @Grabli66 I don't have a clue and it depends greatly on what you're trying to do
<FromGitter> <Grabli66> I want an abstract Protocol with method send
<FromGitter> <umutuluer> python, java, ruby is unsufficient
<RX14> the core of the issue is what you don't implement send(Protocol)
<FromGitter> <aisrael> @bararchy Go is compiled, doesn’t need JVM or interpreter. But I personally really don’t like the language. Hence, Crystal.
<RX14> you always implement send with a specific protocol
<RX14> the Item classes would have to be generic with the specific Protocol you use
<FromGitter> <bararchy> @Grabli66 you should have a single protocol ⏎ ⏎ and have multiple `send` methode ⏎ ⏎ ```Protocol.send(Data1), Protocol.send(Data2)```` [https://gitter.im/crystal-lang/crystal?at=5b44b7493d8f71623d6bf284]
<RX14> i.e. make it class ItemOne(Protocol)
<FromGitter> <Grabli66> I can't do that. Cause i want change Protocol for ItemOne in runtime.
<FromGitter> <umutuluer> @aisrael actually go is good except syntax, i really hate its syntax
<FromGitter> <umutuluer> especially compile time is impressive
<FromGitter> <bararchy> yeha, terrible Syntax
<FromGitter> <Grabli66> RX14, ItemOne know nothing about protocols. Protocol is like interface. That can be changed.
<RX14> @Grabli66 so what do you want to happen if you pass ProtocolTwo to ItemOne?
<RX14> because you're written in the types that you want that to be possible
<FromGitter> <Grabli66> RX14, you are right :)
<FromGitter> <Grabli66> I must to think
<FromGitter> <codenoid> hi
<FromGitter> <codenoid> there is string ⏎ ⏎ ```a = "fwafw252,fwf:@$&fwf"``` [https://gitter.im/crystal-lang/crystal?at=5b44ba0d9b82c6701bb1d80c]
<FromGitter> <codenoid> how to split that string with regexp, by non alpha char
<FromGitter> <codenoid> i do a.split(/^a-z/)
<FromGitter> <codenoid> but it doesn't work
<FromGitter> <codenoid> wanted result `[fwafw,fwf,fwf]`
<FromGitter> <umutuluer> it looks great, i will check
<FromGitter> <umutuluer> thanks @bararchy
duane has joined #crystal-lang
<FromGitter> <asterite> bararchy: if you do `require "http/client"`in any flie in your project, you can use `HTTP::Client` in any other file in your project without having to do `require "http/client"`in those files. That's what global pollution means, and it's bad because it's not clear where that `HTTP::Client` came from in the first place (in the files that don't require them)
Philpax has quit [Read error: Connection reset by peer]
<FromGitter> <bararchy> Oh, I like it TBH. ⏎ It's much better then to have the `require` part all around your code. ⏎ I just put everything that comes from outside (shards, std) in the main file, and if I need something internal I put it in the head of the file that needs it
greenbigfrog has quit [Ping timeout: 256 seconds]
greenbigfrog has joined #crystal-lang
<FromGitter> <j8r> but thus means a file is a namespace like in python? No way to have this. ⏎ But instead we could have a `require "http/client"` inside a module
<FromGitter> <j8r> You can have `MyModule::HTTP::Client`
Heaven31415_ has joined #crystal-lang
<FromGitter> <umutuluer> why puts command is not working in spec?
<FromGitter> <umutuluer> for example in golang we can do printing operation
Heaven31415 has quit [Ping timeout: 264 seconds]
<FromGitter> <j8r> puts == STDOUT.print "\n"
<FromGitter> <j8r> you have to modify the IO
<FromGitter> <bararchy> @umutuluer of curse its working, if your specs are too short then STDOUT.flush
<FromGitter> <j8r> But what the use case of printing to stdout in spces?!
<FromGitter> <umutuluer> only to show variable value
<FromGitter> <umutuluer> because im using fake data in tests
<FromGitter> <umutuluer> sometimes i need
<FromGitter> <umutuluer> fake data is dynamic, always i use wrong method in fake library
<FromGitter> <umutuluer> https://github.com/askn/faker
<FromGitter> <umutuluer> thanks for helping all of them
<RX14> i've never had a problem printing in specs
Heaven31415_ has quit [Quit: Leaving]
greenbigfrog has quit [Ping timeout: 256 seconds]
alex`` has joined #crystal-lang
greenbigfrog has joined #crystal-lang
<FromGitter> <j8r> yeah there shouldn't have differences between running specs vs another crystal program
<FromGitter> <j8r> what's the error, if there is one?
<crystal-gh> [crystal] delef opened pull request #6360: Change String#includes? for multiple substrings (master...master) https://git.io/fNTfE
<FromGitter> <drum445> Hello, I want to be able to have an array of type where type is passed into a function ⏎ https://play.crystal-lang.org/#/r/4hg4 ⏎ ⏎ How could I do this [https://gitter.im/crystal-lang/crystal?at=5b44d5073d8f71623d6c4d38]
<RX14> you can't do Array(object_type).new since `object_type` isn't a type variable
<RX14> you need to perform a little trick to get the type you pass into the function available as a type variable
<FromGitter> <drum445> how could I store multiple of a passed through object?
<FromGitter> <drum445> as I don't believe Crystal has a dynamic type like c# or go
<FromGitter> <drum445> well isn't that fancy
<FromGitter> <drum445> cheers @RX14
<RX14> yep
<RX14> you're creating a generic method
<RX14> you can do the same in java or C# using generics
<FromGitter> <drum445> I'm trying to create something similar to dapper
<FromGitter> <drum445> so sql result set to object
<FromGitter> <drum445> So that will help a lot, thanks again
<FromGitter> <drum445> Also when are you streaming next lol
<RX14> not sure
<FromGitter> <drum445> fair
rohitpaulk has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
wontruefree has joined #crystal-lang
lvmbdv has joined #crystal-lang
<lvmbdv> is the source for crystalshards.xyz available?
<lvmbdv> i looked around and found a few projects named "crystalshards" but none look right
<wontruefree> that is the link on the bottom of the website
<lvmbdv> oh yeah, thanks
<wontruefree> np :)
<lvmbdv> weird that it's still a fork
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
<wontruefree> yeah it is
<wontruefree> looks also unmaintained
<RX14> does it work? yes
<RX14> then maybe it doesn't need to be fixed :)
<RX14> there's also crystalshards.org and https://github.com/crystalshards/crystalshards.org
<wontruefree> very true not all code needs to be recently committed
<FromGitter> <drum445> Hello again, how can I combine
<FromGitter> <drum445> I want to be able to use the parser to load a .csv file into memory, but load it with headers using CSV.new()
<RX14> i'm confused - what do you want to do?
<RX14> what can't you do using CSV.new that you want to do?
<FromGitter> <bararchy> RX14: https://github.com/tbrand/iemon
<FromGitter> <drum445> It doesn't accept a file as the param
<FromGitter> <bararchy> Seems like a nice approach getting what Pchan tries to do, no?
<RX14> Files are IOs
<RX14> CSV.new accepts IO
<RX14> File.open(filename) do |file|; CSV.new(file); end
<RX14> seems very limiting
<RX14> the need to make the properties special shm objects and shm wrappers
<FromGitter> <drum445> so it does ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b44e8b3f166440661299109]
<FromGitter> <drum445> cheers again sir
<RX14> please use FIle.open with a block
wontruefree has quit [Quit: bye]
lvmbdv has quit [Quit: Leaving.]
<FromGitter> <opensas_gitlab> hi everyone, I was wondering if there's any dependency injection framework for crystal. I googled around a little bit but couldn't find anything like that. Or is there some reason why it just doesn't make sense to use a DI framework with crystal???
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <drum445> Why on earth is that returning username and not "Ed" lol ?
wontruefree has joined #crystal-lang
<FromGitter> <bew> @drum445 note that `typeof(j_doc)` is String
moei has quit [Quit: Leaving...]
<FromGitter> <hugoabonizio> @drum445 what you want is `p.username` https://play.crystal-lang.org/#/r/4hiy
rohitpaulk has joined #crystal-lang
<FromGitter> <drum445> Cheers guys, yeah I had to parse the to_json as JSON
moei has joined #crystal-lang
zachk has joined #crystal-lang
zachk has quit [Changing host]
zachk has joined #crystal-lang
<FromGitter> <asterite> opensas there's no way to do dependency injection in Crystal because: you can't have a variable of type object (yet), and there's no runtime reflection (probably never going to happen)
<RX14> @asterite what's the main reason we don't have variables of type Reference?
duane has quit [Ping timeout: 260 seconds]
<FromGitter> <asterite> I didn't implement it. Plus it's a huge union type, not sure how it will affect compile times. But I can try to experiment with it and see if it works.
<FromGitter> <asterite> I'm any case, dependency injection requires runtime reflection, so that's not possible to implement
<RX14> i'm sure you could be a tad creative with macros and get something pretty close
<RX14> autogenerating a constructor in the class which took a DI container and asked it for the args of new could be good enough
<RX14> and probably not too bad of a macro
<Yxhuvud> dependency injection a la spring perhaps require that, but it is a way bigger concept than that. write a method that take as an argument something that it applies to something else? Well congrats, you are probably doing dependency injection
wontruefree has quit [Ping timeout: 260 seconds]
wontruefree has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Is it possible, or desired, to type restrict instance variables since we currently have to assign it to a local variable for the compiler to restrict them?
zachk has left #crystal-lang ["Leaving"]
<RX14> no, the reason why class vars can't be restricted is for thread safety
<RX14> another thread can change the type of the instance variable between the type check and the use
<RX14> thats why you have to copy it when you type check - to make sure it's a local var and can't be changed out from under you
<FromGitter> <Daniel-Worrall> That makes sense, so the type restrictions are happening in the variable objects themselves. I could see it being possible if we redesigned it so we could allow a reference of the object with type restriction assigned for that block/code flow
<crystal-gh> [crystal] delef closed pull request #6360: Change String#includes? for multiple substrings (master...master) https://git.io/fNTfE
<FromGitter> <rishavs> Just hit this error; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b450ab089db5e701cb22bfc]
akaiiro has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Is there a nice tool to debug uncompilable code?
<FromGitter> <Daniel-Worrall> or debug the compiler itself
duane has joined #crystal-lang
duane has quit [Ping timeout: 265 seconds]
<FromGitter> <bew> @rishavs what you do is super slow, for example instead of doing `rows = rows + [row]` you can do `rows << row`
<FromGitter> <rishavs> thanks @bew
pbodev1 has quit [Quit: ChatZilla 0.9.93 [Firefox 56.0/20170903140023]]
<crystal-gh> [crystal] j8r opened pull request #6362: Remove `ditto` and `nodoc` without colons (master...ditto_nodoc_only_with_colons) https://git.io/fNTKe
<FromGitter> <Timbus> @asterite Thanks! I just woke up. I'll write up a simple proposal some time soon.. it's a very simple, non-breaking mechanism.. But I want to implement some of it first, to prove it works outside of my head
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <j8r> Sometimes in the code we can see `ary = ary = [] of ...` - reference to @asterite ? πŸ˜„
rohitpaulk has joined #crystal-lang
hightower2 has quit [Ping timeout: 255 seconds]
<FromGitter> <drum445> Is there anything in the standard lib that allows you to transform a SQL result set into an object or result of object? ⏎ Also something that allows you to inject the object's attributes into a SQL query without having to do it manually. I'm making a library for it but would be interested to see if something similar already exists
<FromGitter> <drum445> So something like this ⏎ ⏎ ```db.exec "insert into person values ({id}, {name})", person``` [https://gitter.im/crystal-lang/crystal?at=5b452f8360c38707836eae8c]
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> could make it a method on the object
<FromGitter> <Blacksmoke16> then could do like `db.exec person.insert`
<FromGitter> <Blacksmoke16> where `person.insert` build out the SQL statement
<FromGitter> <Blacksmoke16> like
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/4hkz
<FromGitter> <drum445> Not bad, I quite like how dapper works in asp.net. I might try and make a similar library, but I will keep that idea in mind cheers @Blacksmoke16 . ⏎ I'll post my probably tragic attempt at a library here tomorrow ;)
<FromGitter> <Blacksmoke16> or could use an ORM
<FromGitter> <Blacksmoke16> then could just do like you know, `person.save`
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/4hlq shouldnt this print nameage
<FromGitter> <asterite> There's DB.mapping right in Crystal-db, though it's not complete. Then there are some ORMs out there
<FromGitter> <asterite> No, you want just {{name.stringify}}
<FromGitter> <Blacksmoke16> <3
<FromGitter> <asterite> Think about the code that the macro generates. Your way is outputting name, age, and that will call the properties
<FromGitter> <Blacksmoke16> thanks
<FromGitter> <drum445> any orm libray suggestions?
<FromGitter> <Blacksmoke16> Granite ;)
<robacarp> whoop
<FromGitter> <drum445> any lightweight ones like dapper?
<FromGitter> <Blacksmoke16> define lightweight
<FromGitter> <Blacksmoke16> crystal-db would be pretty light weight id say
<FromGitter> <drum445> Something that removes the needs to manually map column to object field
<FromGitter> <drum445> same thing on inserts/updates
<FromGitter> <drum445> having to do rs.read(String) on huge selects isn't fun
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] straight-shoota opened pull request #6363: Enable Time::Location features on win32 (master...jm/fix/time-enable-win) https://git.io/fNTyi
<FromGitter> <asterite> I don't think something like dapper exists
<FromGitter> <jwoertink> @drum445 https://github.com/jwoertink/crystal_orm_test/
<FromGitter> <jwoertink> You can look through the code to compare the ORMs to see which setup you like best. Granite is currently the fastest consistently, though, I had a really hard time setting it up because the docs weren't up to date. Clear has been the easiest to get up and running, and still has great speed. ALL of the ORMs lack some feature in one way or another
<FromGitter> <jwoertink> Clear and Lucky only support postgres, so if you're using something else, then those are out already.
<FromGitter> <jwoertink> Crecto and Core are also really nice if you want to use a different pattern for your ORM.
<FromGitter> <jwoertink> Hope that helps give some insight
wontruefree has quit [Quit: bye]
duane has joined #crystal-lang
duane has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 244 seconds]