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
<FromGitter> <greenbigfrog> *Warning: This might spoiler day 1 of advent of code for you*https://github.com/greenbigfrog/advent-of-code/blob/master/2018/Day1/task_2-bm.cr ⏎ Anyone able to explain to me, why prepopulating the Set with 0, makes it a bit faster? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c0324bbbc1a693e3a3fe947]
<FromGitter> <greenbigfrog> (I'm heading to bed now, but will see answers in the morning)
<FromGitter> <proyb6> @girng I think "includes?" tend to be slower than strstr in C which is 50% faster
<FromGitter> <proyb6> especially for string
<FromGitter> <Blacksmoke16> well got everything work with nested classes and arrays now
<FromGitter> <Blacksmoke16> just had to override the default `to_json` functionality
<jokke> asterite: hehe good to hear. Join Jenz's leaderboard!
<jokke> asterite: it's 289786-69f3013e
ua_ has quit [Ping timeout: 250 seconds]
ua has joined #crystal-lang
bazaar has quit [Ping timeout: 252 seconds]
bazaar has joined #crystal-lang
ashirase has joined #crystal-lang
ashirase has quit [Client Quit]
ashirase has joined #crystal-lang
akaiiro has joined #crystal-lang
ashirase has quit [Quit: ZNC - http://znc.in]
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 250 seconds]
akaiiro has quit [Ping timeout: 240 seconds]
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
ashirase has joined #crystal-lang
ashirase has quit [Quit: ZNC - http://znc.in]
akaiiro has joined #crystal-lang
akaiiro has quit [Ping timeout: 240 seconds]
akaiiro has joined #crystal-lang
ashirase has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <m-o-e> https://crystalshards.xyz/
<FromGitter> <m-o-e> looks like that site has a booboo lol
<FromGitter> <girng> lol
sz0 has quit [Quit: Connection closed for inactivity]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
rohitpaulk has joined #crystal-lang
akaiiro has quit [Ping timeout: 245 seconds]
rohitpaulk has quit [Remote host closed the connection]
ravernkoh has joined #crystal-lang
<FromGitter> <asterite> jokke: cool, I'll join, though my timezone makes it so that I have to do it like 12 hours after it's published
ravernkoh has quit [Remote host closed the connection]
<FromGitter> <DanilaFe> Joining that leaderboard too :)
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
<FromGitter> <mpcjanssen> @greenbigfrog instead of the loop wich checks for continue, you can use INPUT.cycle.each this goes repeatedly through INPUT
* FromGitter * mpcjanssen test driving Crystal wit AoC and happy thus
<FromGitter> <mpcjanssen> far
<FromGitter> <vlazar> Old question comes back to me again :) Is adding an implicit block argument for cleaner syntax is a good idea or possible at all in current Crystal syntax? ⏎ ⏎ > Does anybody know if Kotlin-like syntax was considered for Crystal blocks? For example: ⏎ > ``` ⏎ > ints = [1, 2, 3] ... [https://gitter.im/crystal-lang/crystal?at=5c03b1d0e827492525872be9]
<FromGitter> <greenbigfrog> @mpcjanssen Thanks
<FromGitter> <asterite> Just use a block argument name. It's not a big deal.
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <vlazar> Sure, but implicit `it` feel just a bit cleaner than adding `|it|` and `&.` shortcut is a separate syntax and limited to single method call.
Yxhuvud has joined #crystal-lang
Jenz has joined #crystal-lang
<Jenz> Join the crystal leaderboard of AoC 2018 guys!
<FromGitter> <greenbigfrog> what's the join code?
<Jenz> Go here https://adventofcode.com/2018/leaderboard/private, with join code: 289786-69f3013e
* Jenz :D
<Jenz> And share the leaderboard with fellow crystallers (or whatever we call ourselves), the more the merrier!
<Jenz> (Though AoC puts a maximum of 200 people per private leaderboard)
<FromGitter> <greenbigfrog> Anyone ever had issues with crystal not resolving addresses properly when running inside docker and trying to connect to a other container on the same overlay network?
* Jenz has never even used docker...
<Jenz> And hehe, crystal stdlib has some juicy stuff for part to of todays AoC challenge
<Jenz> s/part to/part two/
<FromGitter> <greenbigfrog> mind sharing your solution?
<Jenz> I haven't completed part 2 yet, not even started really, just read the desc and got some ideas
<FromGitter> <greenbigfrog> When you do, I'd like to see a better implementation then mine...
<FromGitter> <greenbigfrog> The address resolving has to do with static compiling glibc... https://github.com/crystal-lang/crystal/issues/6099 ⏎ Smh I could've googled this earlier and spared myself trying to fix this for over half a day...
<FromGitter> <asterite> It would be nice to have a place to see the Crystal repos for the solutions of adventofcode of this year
<FromGitter> <asterite> I just pushed my solutions for day 2: https://github.com/asterite/adventofcode2018/tree/master/2
<Jenz> Oh nice, I had no idea there was an Array#each_combination, nice!
<Yxhuvud> asterite: mine is at https://github.com/yxhuvud/aoc18
<FromGitter> <asterite> Nice!
<FromGitter> <greenbigfrog> Mine at https://github.com/greenbigfrog/advent-of-code/tree/master/2018/ ⏎ Not rly any good implementations though 😄
<FromGitter> <mamantoha> It would be nice to have a place where anyone can post a link to its AoC repository.
<FromGitter> <mamantoha> https://github.com/crystal-community ?
<FromGitter> <mpcjanssen> Mine at https://github.com/mpcjanssen/adventofcode2018
<Jenz> This gets the right answer for the example: https://play.crystal-lang.org/#/r/5obb, but I get a wrong one for the real input, anyone see what Im missing?
<Jenz> Actually, I think I know
<Jenz> Or not...
<Jenz> Ah it was that after all
<FromGitter> <meltheadorable> I'm a ruby dev trying to learn crystal and, presently, feeling silly because this doesn't work: ⏎ ⏎ ```arr = [] of Int32 ⏎ (1..100).each_with_index do |n, index| ⏎ arr[index] = n ⏎ end``` ⏎ ⏎ i vaguely understand *why* it doesn't work (the array is size 0, so `arr[0]` is out of bounds), but is there any way I could do something vaguely similar in the future without knowing in advance
<FromGitter> ... how big to initialize the array or using append? I wanted to handle a less straightforward case where I had integer keys that weren't necessarily sequential and I wanted to insert them one at a time, I ended up having to replace it with a hash, which might have been the more correct data structure, but i use this sort of thing often enoug ... [https://gitter.im/crystal-lang/crystal?at=5c03dedaa6c29a1037d01236]
<Yxhuvud> asterite: thanks for each_combination, it gave me a cleaner and shorter require-free solution to part2. :)
<FromGitter> <mpcjanssen> @meltheadorable if you have holes in your array, a hash is the proper data structure
<FromGitter> <meltheadorable> @mpcjanssen fair enough, if that's the answer then that's the answer :P
<FromGitter> <proyb6> I seen some Crystal code in Day 2 P1 use map, chars and groul_by
<FromGitter> <proyb6> Why not use ".find" to simplify?
<Yxhuvud> proyb6: I don't understand. Care to gist some code to explain how the code for that wood look?
<FromGitter> <proyb6> Hmm, Can post here in the open?
<Yxhuvud> better use a gist, some may not want to be spoiled.
<FromGitter> <proyb6> I will private message you
<FromGitter> <proyb6> Ok a gist
<FromGitter> <mpcjanssen> @proyb6 thanks for the tip
<FromGitter> <proyb6> Yxhuvud Secret gist, spoiler, just a small part ⏎ https://gist.github.com/proyb6/1498a56bad25aa034cb2665302568bc6
<FromGitter> <proyb6> @mpcjanssen No problem :)
<FromGitter> <mpcjanssen> Yxhuvud, this is how it simplified my solution *SPOILER* https://github.com/mpcjanssen/adventofcode2018/commit/1c3a622c8ef3ee759fe106c205cd23d1d9015af3
<FromGitter> <mpcjanssen> which is the solution to part to. I changed a map and select into a find
<FromGitter> <ilanusse> What's Day 2 P1?
<Yxhuvud> proyb6: Oh, that is actually quite nice.
<Jenz> @ilanusse why don't you check for yourself?: https://adventofcode.com
<FromGitter> <proyb6> Yxhuvud, I found your code quite nice too but wasn't sure on the occurrence parts, think it work as such. I'm off to do something else.
<FromGitter> <proyb6> @ilanusse It's an Advant of Code game
mjanssen has joined #crystal-lang
<FromGitter> <ilanusse> Thanks!
<jokke> i might have a slightly different solution :) (SPOILER) https://gitlab.com/jreinert/aoc-2018.cr/blob/master/src/2_2.cr
<jokke> makes use of iterators a lot
Jenz has quit [Ping timeout: 250 seconds]
Jenz has joined #crystal-lang
ua_ has quit [Ping timeout: 240 seconds]
ua has joined #crystal-lang
<FromGitter> <ilanusse> https://crystalshards.xyz/ is down :/
* Jenz D:
<Jenz> It is terrible
<Jenz> - that it is down
<Jenz> I had no idea they were different :o
<Jenz> huh, thanks oprypin
dabedoc has joined #crystal-lang
<dabedoc> Hm
<dabedoc> When will crystal get proper parallelism?
<jokke> heh there's a O(n*w) solution to part 2
<jokke> is there a more elegant way to do this? https://p.jokke.space/JmX/
<jokke> (might contain spoilers)
<jokke> basically i want to create a new string from an input string which has all chars of the input string except for the one with the given index
<FromGitter> <asterite> String interpolation with two substring
<FromGitter> <asterite> "#{s[0...index]}#{s[index+1..-1]}"
<Jenz> ooh
<FromGitter> <j8r> I'm now satisfied with the 25% performance increased vs JSON, time to do Serializable stuff
dabedoc has quit [Ping timeout: 256 seconds]
<FromGitter> <ilanusse> Macros are pretty fun now that I've figured out how to call methods with them
Jenz has quit [Ping timeout: 268 seconds]
_whitelogger has joined #crystal-lang
akaiiro has joined #crystal-lang
<FromGitter> <greenbigfrog> Currently trying to containerize a few crystal applications. ⏎ `Unhandled exception in spawn(name: T Bot): SSL_connect: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed (OpenSSL::SSL::Error)` ⏎ I was using a multistage build until I now started noticing the issue above (which is due to missmatching openssl versions at build and runtime?) ⏎ I could of course fix this,
<FromGitter> ... by getting rid of the multistage build, increasing the image size unnecessarily though. ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5c041214500e8e37284bcbe9]
<FromGitter> <greenbigfrog> anyone got any suggestions how to get around this?
<FromGitter> <Blacksmoke16> iirc, static build only works in alpine, try that maybe?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c041338be66d82526668c88]
<FromGitter> <Blacksmoke16> otherwise thats what i use and it works fine, not as small as scratch but is like 100mb i think?
akaiiro has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> yea 109
<FromGitter> <greenbigfrog> Alpine isn't 0.27.0 yet
<FromGitter> <Blacksmoke16> welp ;/
<FromGitter> <j8r> for the moment you could use alpine with 0.26.0 and compile crystal 0.27.0 inside
<FromGitter> <greenbigfrog> 88MB vs 15MB is acceptable for now 😄 thanks for the debian:<sth>-slim tip
<FromGitter> <Blacksmoke16> np
<FromGitter> <BlobCodes_gitlab> Hello, I tried to use the OAuth2 library, but when I want to get the token, the request takes a minute and says "Error reading socket: Connection reset by peer". ⏎ ⏎ Code: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c041aaf8fa4333e392ab01a]
<FromGitter> <BlobCodes_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c041af5be66d8252666b9db]
<jokke> asterite: thanks
<FromGitter> <j8r> @greenbigfrog just git clone crystal, make and you'll get the latest crystal in alpine
<FromGitter> <ilanusse> Is there a good library for scientific computing in Crystal?
<FromGitter> <ilanusse> I feel like it's a great language for that, I was thinking of porting SciPy/NumPy to Crystal
<FromGitter> <j8r> @ilanusse you can also take a look at Julia
<FromGitter> <ilanusse> Oh I don't really have a need for it
<FromGitter> <ilanusse> I just recently fell in love with Crystal and I'm looking to help the community by pumping out useful shards
<FromGitter> <j8r> ok! I said that because I prefer Julia than any Python related scientific lib :)
<FromGitter> <ilanusse> Thanks!
<FromGitter> <j8r> that's totally a personal opinion of course.
<FromGitter> <j8r> Btw, welcome to Crystal @ilanusse
<FromGitter> <ilanusse> Cheers :)
akaiiro has joined #crystal-lang
<FromGitter> <ilanusse> How are people handling Auth in Lucky and Amber?
<FromGitter> <ilanusse> Is there some sort of Devise-like shard?
<jokke> asterite: my rust implementation is like 3 times faster :(
<jokke> i noticed that there's no add method for a set which would return if the element was already in the set or not
<jokke> asterite: what's worse: even perl is as fast as crystal
<jokke> do you see any low hanging fruit? https://p.jokke.space/ZOu/ (SPOILER)
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> jokke: if you do `line[0...index]} + line[index + 1..-1]`?
<jokke> no real change :/
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
ua has quit [Excess Flood]
<FromGitter> <BlobCodes_gitlab> Why is this not working in Crystal ? ⏎ ⏎ Crystal: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c042ba4e8274925258a2437]
<FromGitter> <BlobCodes_gitlab> The Ruby thing works, but the Crystal Code gives an error.
<FromGitter> <ilanusse> What error?
<FromGitter> <BlobCodes_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c042c0e3f5031103615102c]
<FromGitter> <ilanusse> Hmm no clue
ua has joined #crystal-lang
<FromGitter> <jgaskins> @BlobCodes_gitlab Whenever you get `Connection reset by peer` trying to make an HTTP request, nearly 100% of the time it's because you're making an HTTP request to a server expecting HTTPS or vice versa. Your code should work if you pass `tls: true` to `post`.
<FromGitter> <jgaskins> I'm surprised the Ruby version doesn't give the same error. I've always had to pass `use_ssl: true` in HTTPS requests with `Net::HTTP`.
<FromGitter> <jgaskins> Ahhh, looks like Ruby's `Net::HTTP.post_form` has special handling for that (https://github.com/ruby/ruby/blob/a7f1bcb2d65e4953c993d7ba1bc626bdd6bfe7ae/lib/net/http.rb#L528-L529).
<FromGitter> <girng> i still don't understand macros and never will <laughing while crying.gif>
<FromGitter> <ilanusse> What's Crystal's equivalent to Rack?
<FromGitter> <bew> hey @girng you're back
<FromGitter> <ilanusse> @girng Just imagine the preprocessor replaces any macro calls with the entire macro code
<FromGitter> <j8r> @girng they generates source code, instead of your hands writing this code
<FromGitter> <girng> the only macro code that i used, was opyrin's macro_everything macro, which does DB.mapping and JSON.mapping. it's all i ever needed so far LOL
<FromGitter> <girng> @j8r yeah just the thought of that makes my head explode
tdc has quit [Quit: Leaving]
<FromGitter> <girng> @bew =] glad to be back. finished up my MasterServer, now finishing up my GameServer (that has the tickrate)
<FromGitter> <BlobCodes_gitlab> @jgaskins Thanks! I finally got it to work! ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c04334c99ad1556dbf6eac9]
<FromGitter> <BlobCodes_gitlab> Just the tls: true got it to work
sagax has joined #crystal-lang
<sagax> hi all!
<sagax> i change crystal to production
tdc has joined #crystal-lang
<FromGitter> <girng> nice
<FromGitter> <girng> what kind of service? web server?
<FromGitter> <DanilaFe> little late to the party, but here are my solutions for Advent of Code so far
DTZUZO has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <BlobCodes_gitlab> Trying to get the Microsoft Office365 OAuth2 to work is just pain.. ⏎ ⏎ The normal OAuth2 module in Crystal just won't work - you need to specify that it has to use tls, but even if you replace the .get_access_token_using_authorization_code() function, the integers are given in Strings and Crystal's OAuth2::AccessToken.from_json wants integers.. Thus it crashes again..
<sagax> websocket server
<sagax> girng
<sagax> as speed websocket server
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <girng> oh really???
<sagax> yes, i change xD
<FromGitter> <girng> websocket eh, awesome! were you inspired by @sdogruyol's benchmarking article? hahaha
<sagax> no no, just change, it's all
<FromGitter> <girng> i see :D
<sagax> yes
<sagax> ^_^
akaiiro has quit [Remote host closed the connection]
<sagax> anyway crystal quicker than ruby
lucasb has joined #crystal-lang
DTZUZO has quit [Ping timeout: 244 seconds]
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Read error: Connection reset by peer]
Renich has joined #crystal-lang
RyanMcCoskrie has joined #crystal-lang
<FromGitter> <girng> i'm so happy i'm free from javascript on the server
<FromGitter> <girng> crystal feels so much more nicer. especially the db module. code looks way better and easier to read and the synchronous nature makes it easier to do things with queries
<FromGitter> <girng> i also did something that dramatically changed the way i program and increased my productivity tenfold
<jokke> great to hear
<FromGitter> <girng> i simply changed the text editor's zoom level in godot and vscode ( for crystal code), to around 64%. at first, it was hard to see the code, but i'm used to it now. BUT OMG it affects productivity and increases confidence by a lot. because it makes me feel like i have more room to "write stuff" and the more space in the editor, makes me feel like i can write more code
<FromGitter> <girng> ya'll think i'm crazy prob lol, but honestly it's the truth. it helps!
RyanMcCoskrie has quit [Remote host closed the connection]
moei has quit [Quit: Leaving...]
vikaton has joined #crystal-lang
ua has quit [Ping timeout: 250 seconds]
<oprypin> well what do you know, Crystal's color in Github stats is actually black now
<FromGitter> <girng> i don't understand
<FromGitter> <girng> why is that repo called linguist when that PR was to change the hex color
<FromGitter> <Blacksmoke16> because it handles the logic of what language each repo is
justinmcp has quit [Remote host closed the connection]
justinmcp has joined #crystal-lang
justinmcp has quit [Remote host closed the connection]
justinmcp has joined #crystal-lang
ua has joined #crystal-lang