RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
Dreamer3_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <hybls_twitter> hey guys, quick question: Where can I find a list of crystal's built-in types (UInt32, String, Char, etc.) I'm having a hard time finding it.
<FromGitter> <hybls_twitter> Ah, nevermind. I found what I was looking for.
gangstacat has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<oprypin> hybls_twitter, it's good to share your finding in such cases, otherwise https://xkcd.com/979/
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <iambudi> Can someone help how to get client remote IP Address from HTTP server context?
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
chemist69 has joined #crystal-lang
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <Sija> @iambudi see #7302
<DeBot> https://github.com/crystal-lang/crystal/pull/7302 ([WIP] Add remote_address to HTTP::Server::Context)
<FromGitter> <bew> @Sija the forum link is good your ip, not the client's iirc
<FromGitter> <bew> s/good/for
<FromGitter> <Sija> @bew yep, you’re right
<FromGitter> <bew> @oprypin how do you find the perfect xkcd? There is no search engine iirc.. Every time i tried to find one i got lost
sagax has quit [Ping timeout: 258 seconds]
<FromGitter> <Sija> google “xkcd no answer"
<FromGitter> <Sija> @Blacksmoke16 try using `===` instead for checking the object type
sagax has joined #crystal-lang
ua__ has quit [Ping timeout: 268 seconds]
laaron has joined #crystal-lang
ua__ has joined #crystal-lang
Groogy has joined #crystal-lang
<oprypin> bew, u just need to remember some quote from it. believe it or not, this one i was searching by the phrase "denvercoder"
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> @Sija https://play.crystal-lang.org/#/r/5zkw :/
<FromGitter> <Blacksmoke16> wouldnt be *as* bad if both `Generic` and `Union` had a `types` method
<FromGitter> <Blacksmoke16> vs `types` and `types_vars`
<FromGitter> <Blacksmoke16> then could prob do something like `arg.restriction.is_a?(Path) ? arg.restriction.resolve.nilable? : arg.restriction.types.any? { |t| t.resolve.nilable? }`
<FromGitter> <iambudi> @Sija thank you
<FromGitter> <Sija> @Blacksmoke16 https://play.crystal-lang.org/#/r/5zlp
<FromGitter> <Sija> although it’s weird ‘cause there’s `TypeNode#nilable?` which should work inside macros...
moei has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> ikr? i was attempting to add the `#nilable?` to `Union` yesterday and i was doing like `BoolLiteral.new(@types.any? { |t| t.nilable? })` and was saying `no method #nilable?` exists on TypeNode`
<FromGitter> <Blacksmoke16> wait, hows that work? just by adding `()`?
<FromGitter> <Blacksmoke16> oh, are doing it at runtime now
Groogy has quit [Quit: WeeChat 2.3]
<FromGitter> <Blacksmoke16> works well enough for my needs
spacemanspam has joined #crystal-lang
<FromGitter> <Sija> yep, runtime to the rescue...
<FromGitter> <Blacksmoke16> well, now i just need to write docs
sagax has quit [Ping timeout: 258 seconds]
simerax has joined #crystal-lang
<simerax> How can I initialize a Hash with values? Apparently you can invoke Hash.new with a Block. However I don't quite get how I could invoke that block as some kind of iterator. Lets say I would like to create a Hash which holds each Letter of the alphabet as a key and the Numeric value of that Letter as Value. How could I achieve something like that?
<simerax> I don't seem to find any example of that
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <Sija> @simerax `('a'..'z').map { |char| [char, char.ord] }.to_h`
<FromGitter> <Sija> nevertheless `Hash` could use `.[]` method for alternative version (`Hash[('a'..'z').map { |char| [char, char.ord] }]`)
Groogy has joined #crystal-lang
<simerax> i did not think about the to_h method. i thought you would usually do it with Hash.new
<simerax> ^^
Groogy has quit [Quit: WeeChat 2.3]
Groogy has joined #crystal-lang
spacemanspam has quit [Read error: Connection reset by peer]
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
<simerax> @Sija i have another question regarding the method you showed me to initialize the hash. In my Class i defined @alphabet as Hash(Char, Int32). However @alphabet = ('A'..'Z').map { |char| [char, char.ord] }.to_h does not compile. Error Message is: instance variable '@alphabet' of Message must be Hash(Char, Int32), not Hash(Char | Int32, Char | Int32). Why does this create union types?
<FromGitter> <Sija> because elements of an `Array` are always an `Union` of all possible types
<simerax> Well and how could i then create a true Hash(Char,Int32) ?
<FromGitter> <Sija> I’ve updated my example to use `Tuple`s instead but the IRC bridge doesn’t show updates obviously
<FromGitter> <Sija> try `('a'..'z').map { |char| {char, char.ord} }.to_h`
<simerax> that does the trick!
<simerax> thank you
<FromGitter> <Sija> notice `{}` (`Tuple` literal) vs `[]` (`Array` literal)
<FromGitter> <Sija> yw
sagax has joined #crystal-lang
chemist69 has quit [Quit: WeeChat 2.2]
<FromGitter> <girng> o/
<Harzilein> no ircv3wg spec for updates?
<oprypin> Harzilein, ?
<oprypin> doesnt matter anyway cuz gitter doesn't expose updates in its "simple" API and the "full" API is crazy
<FromGitter> <bararchy> oprypin, any idea what I'm doing wrong in https://github.com/crystal-lang/crystal/pull/7296 ? It seems Ruby uses the same c fucntion with same parameters as I do
<oprypin> bararchy, but what is the actual problem?
<oprypin> oh yeah, unsuported algorithm, that one
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> from the specs
<oprypin> but in ruby you dont specify any file with certificate
<oprypin> oh the file is unrelated (pre-existing)... you're adding a different spec
<FromGitter> <bararchy> ^ yeha
<oprypin> but the code is still different
<FromGitter> <bararchy> just renamed so there is "from file" and "from context"
<oprypin> `"CN=Nobody/DC=example"` is never mentioned
<FromGitter> <bararchy> It doesn't matter, it's just a thing to add
<FromGitter> <bararchy> it fails with and without it
<oprypin> well i can't see which difference in code causes the problem if it's actually different code
ua__ has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
sagax has quit [Ping timeout: 246 seconds]
<FromGitter> <vladfaust> I think that gitter integration with github is broken
sagax has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <Sija> I’ve just stumbled upon the fact that you can’t use lazy getters with `Bool` since `||=` operator will (incorrectly in this case) run lazy macro for `false` values
<FromGitter> <Sija> should it be changed to check for `.nil?` instead? whatcha think? /cc @asterite @bcardiff @ysbaddaden @straight-shoota
<FromGitter> <Sija> @vladfaust seems like it
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <j8r> you can't too with the `if var = nillable_bool` and `nillable_bool ? ... : ...`
<FromGitter> <j8r> it's consistent
<FromGitter> <Sija> @j8r I’m talking about lazy getters, not conditionals...
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/athena/blob/cli/docs/cli.md added docs for the cli commands
<FromGitter> <Blacksmoke16> also modularized everything so if you can only require what you want/need
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <girng> nice blacksmoke
<FromGitter> <girng> i think i found a bug in the db module with NULL lol. if you check the "NULL" box in adminer for your mysql column, when reading that data from the query you'll get some can't cast nil to {whatever}. i even tried `{type: Int64, nilable: true}` in the DB.mapping, but i think nilable is different than nullable? i don't know LMAO ⏎ ⏎ but, i did just uncheck the "NULL" checkbox in adminer, and the Int64
<FromGitter> ... default's to 0, which works fine
<FromGitter> <Blacksmoke16> <3
<FromGitter> <j8r> @Sija but you're talking about changing the `||=` behavior?
<FromGitter> <Sija> @j8r I’m talking about lazy getters with `Bool` types
<FromGitter> <Nbotz> Hello all, anyone know of a good way to dynamically add/read to/from a crystal file?
<oprypin> you'll have to explain what you're trying to achieve by that
<FromGitter> <Nbotz> I have a set of images in a folder, and i want a gallery to display information of the picture as well as the picture itself. I have a .cr file that consists of an array. the array has hashes that have the information of the images, aswell as the image location
<FromGitter> <Nbotz> I want to make it so that when another hash is added into the array, the output changes without having to recompile
<FromGitter> <Nbotz> its for file uploading
<oprypin> but like.. changing a crystal file and not having to recompile are conflicting goals!
<lvmbdv> yeah a dynamic language might be a better fit for the job
<oprypin> better fit for this backwards solution maybe
<lvmbdv> oh yeah it sounds really weird
<oprypin> Nbotz: keep this information in a json file and load it from the crystal program
<FromGitter> <Nbotz> ok thanks
DTZUZO has joined #crystal-lang
spacemanspam has joined #crystal-lang
simerax has quit [Remote host closed the connection]
<FromGitter> <j8r> Is it append only @Nbotz ?
<FromGitter> <j8r> If yes, an effiecient way is to store the infos in a csv file, and watch the file for new lines
<FromGitter> <Nbotz> yes, append only.
<FromGitter> <j8r> What are you doing exactly with file uploading?
<FromGitter> <Nbotz> uploading the pictures and information. the pictures go into the folder while the information would go into the file
<FromGitter> <j8r> Oh ok i see, a sort of index
<FromGitter> <Nbotz> yes
Raimondi has joined #crystal-lang
<FromGitter> <j8r> But if the file is deleted?
<FromGitter> <Nbotz> files are deleted manually, meaning i'd just recompile and fix the error manually
<FromGitter> <j8r> Don't know if it's useful for your usecase, there is a library to watch a folder and files inside it
gangstacat has quit [Ping timeout: 268 seconds]
davic has quit [Ping timeout: 268 seconds]
gangstacat has joined #crystal-lang
davic has joined #crystal-lang