RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.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
DTZUZO has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
<FromGitter> <Sija> damn, those deers during rutting season sound like they r in real pain, they’re braying like their balls gonna xplode anytime soon
<FromGitter> <Sija> excuse my OT, I’m listening to that for the past several hours and had to vent my amazement/amusement somewhere :D
<FromGitter> <girng> what is a "kernel buffer" in relation to crystal and sockets? info here (https://www.reddit.com/r/crystal_programming/comments/9jei7u/when_a_socketsend_is_being_called_from_outside_of/e6rhar7/?context=3)
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
sagax has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> @Sija LOL
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <rishavs> While using crystal-db, can I batch multiple select queries in a single db connection? ⏎ The round trip for each connection is adding up to be an issue
<FromGitter> <proyb6> Is there an API is capable of resumable file uploads in the case of network interruptions, the files can resume uploading progress from where it stop?
flaviodesousa has joined #crystal-lang
<FromGitter> <proyb6> Something like it can be cache a temporary/partial files for particular session until the server or application know it’s completed in a specific of period.
<FromGitter> <vladfaust> @rishavs ⏎ ⏎ ```(SELECT result FROM tbl1 LIMIT 1) ⏎ UNION ALL ⏎ (SELECT result FROM tbl2 LIMIT 1)``` [https://gitter.im/crystal-lang/crystal?at=5bade7fa53c31c111178d058]
<FromGitter> <j8r> I don't understand what happen with https://github.com/rufelo
<FromGitter> <j8r> a spammer i guess
<FromGitter> <vladfaust> I guess this happened by mistake
<FromGitter> <rishavs> @vladfaust my queries are more like; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5badee178ddf5867dc87dd8c]
ashirase has quit [Ping timeout: 245 seconds]
<jokke> Blacksmoke16 yeah i was thinking about that
<FromGitter> <vladfaust> @rishavs okay, you still can use `union`
ashirase has joined #crystal-lang
ua_ has quit [Quit: Leaving]
ua has joined #crystal-lang
scott_tams has joined #crystal-lang
<scott_tams> is there a way to apply type restrictions to abstract definitions?
<FromGitter> <ohenepee> ```code paste, see link``` ⏎ ⏎ Anyone know how to get the fraction of seconds parsed along during the Time.parse? [https://gitter.im/crystal-lang/crystal?at=5badffe84d320a463b08280f]
<FromGitter> <fusillicode> Hi guys :)
<FromGitter> <fusillicode> Sorry for the bother but I'm struggling with some trivial data transformation :(
<FromGitter> <fusillicode> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bae06838196693171c9fd6a]
<FromGitter> <Sija> @bcardiff please ban user “rufelo” who spammed our issue tracker
<FromGitter> <fusillicode> For some reason the compiler is telling me ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bae0730eba8e60bc65a77c2]
<FromGitter> <fusillicode> i.e. `named_captures["property"]` may be `nil` but I have an explicit check with `next acc unless named_captures && named_captures.has_key?("number") && named_captures.has_key?("property")` about its presence 🤔
<FromGitter> <fusillicode> Furthermore, even if I had a `String?` for the first element of the tuple inside the reduce accumulator I still get a runtime exception `Unhandled exception: Missing hash key: "5" (KeyError)`
<FromGitter> <fusillicode> :(
<FromGitter> <j8r> @fusillicode can you post an example in https://play.crystal-lang.org?
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <fusillicode> @j8r you're right I apologize to have cluttered the channel with that code, I'll try to move it on https://play.crystal-lang.org? ASAP (btw I may have figured it out the reason of the 2nd problem :) )
<FromGitter> <j8r> @fusillicode btw you can use `if var = hash["str"]?` syntax to reuse an accessed value
<FromGitter> <fusillicode> @j8r yes I knew that one but while trying to make the compiler happy I tried many things and one of these things was to switch to `has_key?`
rohitpaulk has joined #crystal-lang
<jokke> is shovi here?
<jokke> would be awesome if he/she would make a new release for baked_file_system
francisl has joined #crystal-lang
francisl has quit [Client Quit]
return0e has quit []
<FromGitter> <yxhuvud> so who is that rufelo that spam the pull requests? Some new manas employee?
<FromGitter> <j8r> nope
<FromGitter> <j8r> It creates PRs based on old branches
<FromGitter> <codenoid> wow
<FromGitter> <codenoid> mmm
<FromGitter> <j8r> this also highlights the fact that numerous branches are lying in the repo
<FromGitter> <j8r> some are dead and has to be cleaned up, others may be useful
<FromGitter> <j8r> like the Tar implementation one
<FromGitter> <Sija> @yxhuvud looks like a spammer although I couldn’t tell you the motif
return0e has joined #crystal-lang
wuehlmaus has joined #crystal-lang
<wuehlmaus> hi, all. Anything new on the "parallel" frontier?
rohitpaulk has quit [Ping timeout: 244 seconds]
<jokke> hi wuehlmaus o/
<jokke> not that i'm aware of
<jokke> what's your usecase?
<FromGitter> <ohenepee> where is the docs for this `loop` keyword? ⏎ ⏎ It says that its in the standard library in the language reference section of the *While* loop ⏎ *Or use `loop` , found in the standard library* [https://gitter.im/crystal-lang/crystal?at=5bae24b0eba8e60bc65b3e45]
Tortice has joined #crystal-lang
francisl has joined #crystal-lang
<Tortice> How can I sort in lexicographical order?
<jokke> Tortice: you mean like "0, 1, 10, 11, ..., 2, 20, 21" etc?
<Tortice> Yes, with strings
<jokke> builtin sort should do that
<jokke> strings.sort
<jokke> if strings is an array of strings
<jokke> %w[foo bar baz].sort
<Tortice> I get ["1", "11", "2"] with crystal eval 'puts ["1", "2", "11"].sort'
<FromGitter> <yxhuvud> Yes, of course. strings are sorted lexicographically
<FromGitter> <yxhuvud> if you want numerical sorting, convert them to numbes first
<FromGitter> <yxhuvud> ie arr.sort_by &:to_i
<FromGitter> <yxhuvud> &.to_i
<wuehlmaus> jokke: i don't have one, i just know that many people wait on real parallelism to arrive in Crystal, so i ask evry once in a while.
<jokke> yeah but they usually don't have an usecase for real parallelism
<jokke> Tortice: isn't that what you wanted?
<jokke> Tortice | How can I sort in lexicographical order?
<Tortice> My mistake
<Tortice> Apologies
<FromGitter> <fridgerator> https://i.imgflip.com/2ixhw2.jpg
<FromGitter> <ohenepee> where is the docs for the `loop` keyword? I can't find it any where in the official docs
<FromGitter> <dscottboggs_gitlab> @ohenepee https://crystal-lang.org/api/0.26.1/toplevel.html#loop%28%26block%29-class-method
<FromGitter> <ohenepee> @dscottboggs_gitlab Thanks a lot
<FromGitter> <dscottboggs_gitlab> np, I just saw the source for it the other day, it's just a macro for "while true"
<FromGitter> <ohenepee> ```code paste, see link``` ⏎ ⏎ @dscottboggs_gitlab how about this? ⏎ ⏎ Anyone knows how to get the fraction of seconds parsed along during the Time.parse? [https://gitter.im/crystal-lang/crystal?at=5bae2eaf56877c463a9a2992]
<FromGitter> <dscottboggs_gitlab> ¯\_(ツ)_/¯
<FromGitter> <ohenepee> Hmmmm... 😒
<Tortice> So what if I have ["1", "1a", "2", "11"]?
<Tortice> .to_i obviously fails on 1a
<FromGitter> <j8r> https://carc.in/#/r/545o
<FromGitter> <j8r> not efficient, but short
<Tortice> Can ints and strings not be sorted together?
<Tortice> I would like 1a included if possible
<FromGitter> <j8r> alphabetically?
<Tortice> ["1", "1a", "2", "11, "13", "other"]
<Tortice> like that
<FromGitter> <j8r> https://carc.in/#/r/545w ?
<Tortice> but then "2" is after "11"
<FromGitter> <j8r> oh yes
<FromGitter> <j8r> you'll have to do a custom `sort_by` block
<Tortice> but I don't know what to sort by
<Tortice> https://carc.in/#/r/545j is the closest I got
francisl has quit [Quit: francisl]
<jokke> does this channel have a bot which executes single line crystal snippets?
francisl has joined #crystal-lang
<jokke> > "test"
francisl has quit [Client Quit]
<jokke> >> "test"
<jokke> hm
francisl has joined #crystal-lang
<jokke> Tortice: ["1", "1a", "2", "11", "13", "other"].sort { |a, b| a_result, b_result = a.chars.zip(b.chars).find { |a_char, b_char| (a_char <=> b_char) != 0 }; a_result <=> b_result }
<jokke> :P
<jokke> => ["1", "11", "13", "1a", "2", "other"]
<jokke> oh
<jokke> wait what
<jokke> ok
<FromGitter> <j8r> that's a complicated sort
<Tortice> that doesn't compile for me
<jokke> Tortice: https://carc.in/#/r/546a
<jokke> j8r is right. it's a rather complicated sort
<FromGitter> <asterite> Same result but with simpler code: https://carc.in/#/r/546c
<FromGitter> <proyb6> Let me guess, convert to binary and sort then convert back to alphanumeric
<Tortice> thank you very much jokke
<Tortice> you're right, way above my head
<jokke> asterite: :D
<jokke> Tortice: no problem
<FromGitter> <asterite> At least start with an array that's not sorted ;-)
<jokke> yeah
<jokke> Tortice: ah it still doesn't do what you want
<jokke> (at least what i think you want
<jokke> oh ok it does
<FromGitter> <j8r> @ezrast how does tail for /dev/urandom, `#skip_to_end` or `file.seek(0, IO::Seek::End)` blocks forever
<Tortice> I guess it's called "natural sort order"
<jokke> what you want is: sort by the number prefix (numerical sorting) first and only if they match check the suffix. strings without a number prefix will be at the end
<jokke> correct?
<Tortice> I think so?
<Tortice> either way great job and tyvm
<jokke> no problem
<jokke> how do you guys solve the problem of starting up crystal services that depend on a db being up in docker-compose? depends_on obviously can't know when a service is completely up so i can't really rely on that. since my service is always started way faster than the db it fails with Unhandled exception: (DB::ConnectionRefused)
<FromGitter> <yxhuvud> another way could be to make sure the strings are equally long (and pad in FRONT) before sorting
<FromGitter> <fridgerator> jokke I install `netcat` in my container, and use it in the start command: `command: bash -c 'while ! nc -q 1 postgres 5432 </dev/null; do sleep 1; done && ./bin/micrate up'`
francisl has quit [Quit: francisl]
francisl has joined #crystal-lang
<robacarp> if you haven't tried it, socat is a great upgrade to almost everything I used to use nc for
<Tortice> can I exclude "." and ".." from Dir.entries?
<FromGitter> <j8r> what an ugly code Tortoise :o
<FromGitter> <j8r> but yes you can
<FromGitter> <j8r> https://crystal-lang.org/api/master/Dir.html#each_child%28%26block%29%3ANil-instance-method or https://crystal-lang.org/api/master/Dir.html#children%3AArray%28String%29-instance-method
<Tortice> oh, so I just need to get better at reading docs
<Tortice> thanks and sorry
<FromGitter> <j8r> https://carc.in/#/r/546u
francisl has quit [Quit: francisl]
<robacarp> Tortice: check out https://crystal-lang.org/api/0.26.1/Dir.html#children%3AArray%28String%29-instance-method and https://crystal-lang.org/api/0.26.1/Dir.html#children%28dirname%29%3AArray%28String%29-class-method
<robacarp> they filter ./.. for you
sevensidedmarble has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
francisl has joined #crystal-lang
<FromGitter> <codenoid> something wrong with crystal http
<FromGitter> <codenoid> `Unhandled exception: connect: No route to host`
<FromGitter> <codenoid> but it's working when i use other http client
<FromGitter> <codenoid> like curl, insomnia, postman, etc
<robacarp> codenoid can you post the code?
<FromGitter> <codenoid> just basic HTTP::Client.post with body
<FromGitter> <codenoid> > .<
<FromGitter> <codenoid> ">.<"
<FromGitter> <j8r> Note the http client doesn't follow redirections
<FromGitter> <codenoid> i know, `but it's working when i use other http client`
<robacarp> okay, so what's the url?
<robacarp> other http clients _do_ follow redirects
<FromGitter> <codenoid> actually, ip, http://8.8.8.201
<FromGitter> <codenoid> that's
<FromGitter> <codenoid> i statically define the "http://8.8.8.201" and it's work
DTZUZO has quit [Ping timeout: 272 seconds]
francisl has quit [Quit: francisl]
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
DTZUZO has joined #crystal-lang
francisl has joined #crystal-lang
non-aristotelian has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter> <KevinSjoberg> Is https://github.com/crystal-lang-tools/sublime-crystal still maintained?
<FromGitter> <KevinSjoberg> It seems like the snippets are basically copy-pasted from Ruby. There are several Ruby-specific snippets in there.
<FromGitter> <KevinSjoberg> I've submitted a pull request to address filename-dependent snippets to work properly. See https://github.com/crystal-lang-tools/sublime-crystal/pull/52.
<FromGitter> <j8r> @ezrast got it, I check if the file size is != 0
<FromGitter> <dscottboggs_gitlab> @fridgerator why can't you just `rescue` the `DB::ConnectionRefused`, try again after a timeout a predetermined number of times. ⏎ ⏎ or you could set `restart: on-failure` ⏎ ⏎ or you could do the first thing, but instead of rescuing the exception, try to open a socket connection with the host/port a predetermined number of times. either way. [https://g
<FromGitter> ... itter.im/crystal-lang/crystal?at=5bae6a9d1e23486b935bcf0e]
<FromGitter> <fridgerator> because thats what I do and it works, so I stopped trying to figure out another way
<FromGitter> <dscottboggs_gitlab> oh sorry, I meant to reply to the other guy who was looking for a solution.
<FromGitter> <dscottboggs_gitlab> jokke
StephenLynx has joined #crystal-lang
<StephenLynx> quick question, have crystal always compiled to llvm ir? or did it used to transpile to C?
wontruefree has joined #crystal-lang
francisl has quit [Quit: francisl]
<FromGitter> <vladfaust> @KevinSjoberg you could take the development under your wing, and it will be replaced in awesome list then
scott_tams has left #crystal-lang ["Leaving"]
<oprypin> StephenLynx, always, AFAIK. first Ruby was used to interface with LLVM, then Crystal was used to interface with LLVM
StephenLynx has left #crystal-lang ["Leaving"]
<FromGitter> <KevinSjoberg> @vladfaust I'd be up for it. :slight_smile:
francisl has joined #crystal-lang
francisl has quit [Quit: francisl]
francisl has joined #crystal-lang
<FromGitter> <KevinSjoberg> Would it be possible to get commit access directly to https://github.com/crystal-lang-tools/sublime-crystal? There are several open pull requests that's been just hanging around.
<FromGitter> <KevinSjoberg> Or is forking it the way to go at the moment?
<FromGitter> <vladfaust> I honestly don't know
<FromGitter> <vladfaust> Do you actuallt have experience in maintaining/creating Sublime Packages?
<FromGitter> <vladfaust> Are you able to continiusly develop it? Check out exisitng issues
<FromGitter> <vladfaust> If you're able to fix most of them, then fork and update the package and propose it to the list telling how many issues you've fixed
<FromGitter> <KevinSjoberg> @vladfaust I have some Sublime package experience, but I'm not a wizard. What I do have, is the willingness and time to maintain it. :slight_smile:
<FromGitter> <KevinSjoberg> I think I'll reach out to @faustinoaq to see what he thinks.
<FromGitter> <vladfaust> Then just use the forked version for yourself right now and propose PRs
<FromGitter> <SeedyROM> Has anybody in here used `Readline.bind_key` to capture ansi escape sequences?
<FromGitter> <SeedyROM> Specifically arrow keys.
<FromGitter> <SeedyROM> Is it even possible?
<Tortice> I'm trying to build a GUI with https://github.com/hedron-crystal/hedron - small question: How can I sleep without blocking the main thread/gui update loop?
<Tortice> I tried to sleep in a channel but it executed instantaneously
<Tortice> so I must be doing something wrong
Heaven31415 has joined #crystal-lang
<Heaven31415> hi
<FromGitter> <Blacksmoke16> o/
<FromGitter> <codenoid> morning
francisl has quit [Quit: francisl]
Tortice has quit [Remote host closed the connection]
<FromGitter> <asterite> Tortice: you probably can't, there aren't threads in Crystal
<FromGitter> <vusaalab> Hi guys why this error happened undefined method 'status_code' for Nil (compile-time type is (HTTP::Client::Response | Nil)) ⏎ ⏎ ``` if @response.status_code == 404 ⏎ ^~~~~~~~~~~``` [https://gitter.im/crystal-lang/crystal?at=5bae8fe0c08b8b3067a3a3e1]
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
<FromGitter> <Blacksmoke16> @vusaalab see https://crystal-lang.org/docs/syntax_and_semantics/if_var.html
<FromGitter> <Blacksmoke16> specifically the `Limitations` section
<FromGitter> <Blacksmoke16> but basic the type of `@response` can either be `HTTP::Client::Response` or `Nil`
<FromGitter> <Blacksmoke16> which doesnt have a `status_code` method, so have to make sure it isnt nil before setting the code
<FromGitter> <paulcsmith> In cases like that I usually use `try` -> `if @response.try(&.status_code) == 404`
<FromGitter> <Blacksmoke16> yup
<FromGitter> <Blacksmoke16> or better yet have a guard clause above it that handles the nil, so everything below you know is not nil
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/549w
<FromGitter> <Blacksmoke16> for example
<FromGitter> <Blacksmoke16> wont work the same i think since your `@response` is an instance var but the concept is the same
<FromGitter> <Blacksmoke16> https://www.thechrisoshow.com/2009/02/16/using-guard-clauses-in-your-ruby-code/ (based on ruby but still good practice imo)
<FromGitter> <vusaalab> thanks i got it
<FromGitter> <Blacksmoke16> np
francisl has joined #crystal-lang
francisl has quit [Quit: francisl]
Tortice has joined #crystal-lang
Heaven31415 has quit [Quit: Leaving]
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
<FromGitter> <Sija> evenin’, how’s going?
<FromGitter> <Sija> bit of music to space out for the ones interested - https://www.youtube.com/watch/?v=hzSwPXiPJuE :)
vikaton has joined #crystal-lang
<FromGitter> <bajro17> @Sija So nice :) I like it so much
<FromGitter> <bajro17> This is so weird all programmers I meet love so much this kind weird and peaceful music :)
<FromGitter> <Sija> yeah, hang is rly an incredible instrument, it manages to combine beat making with acoustics, sounds from outer space ;)
<FromGitter> <bajro17> https://www.youtube.com/watch?v=llC9L87pESY check this one also
<FromGitter> <Sija> haha, maybe your programmer friends are more chilled than mine, since it rly varies (but I don’t have much of programmer friends because usually they r damn boring ppl :P)
<FromGitter> <Sija> one dude I met had ADHD, was doin’ some kind of synthetic, military-grade amphetamine prescribed by his doctor (sic!) and was listening to (what a surprise) lots of rock and metal
<FromGitter> <bajro17> hahahha
<FromGitter> <Sija> he was bit childish too, that IMHO gets along with rock and metal pretty well ;)
<FromGitter> <bajro17> In my country most popular is turbo folk
<FromGitter> <bajro17> some weird music with no sense
<FromGitter> <Sija> https://www.youtube.com/watch?v=xk3BvNLeNgw - another gr8 hang music vid
<FromGitter> <Sija> haha, I heard it, it’s gr8 for a wedding party ;) kind of variation of techno, huh?
<FromGitter> <fridgerator> what does rock music have to do with being childish?
<FromGitter> <Sija> Travis A. King blends pretty well, thx
<FromGitter> <bajro17> Yes but words dont have any fucking sense
<FromGitter> <Sija> @fridgerator in my eyes one’s inner rebel
<FromGitter> <bajro17> For example one of our balkan singer say: "Someone tonight will make me son "
<FromGitter> <bajro17> hahahahah
<FromGitter> <fridgerator> that doesn't make any sense at all
<FromGitter> <Sija> you know, this “fighting against the system” thing and so on
<FromGitter> <Sija> hahah, self-recursive bearthgiving
<FromGitter> <bajro17> We have one so amazing group maybe hear about them
<FromGitter> <Sija> I hear “alleluja"
<FromGitter> <bajro17> dubioza kolektiv
<FromGitter> <bajro17> check video :D hahah
<FromGitter> <fridgerator> I really dont undestand wtf you're talking about
<FromGitter> <Sija> @fridgerator sorry if you felt offended (looking at your tshirt I reckon you might be a rock listener ;)), no harm intended :)
<FromGitter> <fridgerator> I listen to all types of music
<FromGitter> <Sija> I meant ppl who r suspended in one particular genre
<FromGitter> <Sija> kind of you know, “rock fans”, not anyone who happens to listen to some rock bands
ua has quit [Ping timeout: 252 seconds]
<FromGitter> <Sija> in my country we have for instance groups which universally listen to one genre of music, lets say punk - like anarchists, who think they do such a gr8 job fighting with the system, in the same time being part of it (beneficiares too, since in the end they live out of state supplies - food, shelter, energy - aside of some things they manage to generate by themselves…)
<FromGitter> <Sija> @bajro17 haha, dubioza is fun
<FromGitter> <Sija> @bajro17 do u know this one? https://www.youtube.com/watch?v=PVliHO-sj4A
<FromGitter> <bajro17> @Sija hahahahha WTF is that first time hear its sick
<FromGitter> <Sija> yeah, it had its popularity peak some yrs ago, some sick stint (done btw by some Australian dude)
<FromGitter> <Sija> “fly away my space rocket, you no need put money in my pocket, the door is closed, I just locked it, I put my … plug in your socket” :D
<FromGitter> <Sija> proper bs
<FromGitter> <Sija> haha, oh yeah, that’s one party piece
<FromGitter> <bajro17> I plan to make shirt with this man picture and write touch my ta-lala for ladies hahahah
<FromGitter> <Sija> sounds like a gr8 opener :D
<FromGitter> <Sija> check this family battle
<FromGitter> <Sija> that was my favorite for a long time, gives me tingles evey time
wontruefree has quit [Quit: this is not the client you are looking for]