RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.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> <watzon> Shit. What have I gotten myself into? https://github.com/FFmpeg/FFmpeg/tree/master/libavcodec
jnyw has joined #crystal-lang
<FromGitter> <bew> Lol
<FromGitter> <MrSorcus> https://github.com/crystal-lang/crystal/blob/master/src/http/client.cr#L559 ⏎ Here request sending to socket. But i don't know a right way to send request to socks5 socket... It's possible without dirty patching?...
<FromGitter> <MrSorcus> Maybe i'm looking for something like `HTTP::Client.get("example.com", my_own_socket)`
vivus has quit [Quit: Leaving]
hightower has quit [Ping timeout: 256 seconds]
<cptaffe> A major pain point to me is that `JSON::Any` consumes the `JSON::PullParser` and the only way to build a new `JSON::PullParser` is to call `to_json` and re-parse it into the type you want.
<cptaffe> I ran into this issue using the postgres driver for crystal-database, where jsonb columns are consumed as `JSON::Any`
<cptaffe> It seems that classes which parse from json should consume a `JSON::Any` instead of a `JSON::PullParser`, or that it should accept some interface which `JSON::Any` and `JSON::PullParser` implement
cremes has quit [Quit: cremes]
baweaver is now known as baweaver_away
baweaver_away is now known as baweaver
dragonkh has joined #crystal-lang
never_ has joined #crystal-lang
<never_> is it possible to make a class alias ?
<never_> I tried doing this alias : Scene = BaseScene | {BaseScene, Scene}
<never_> and I got a nice recursive struct error (which I understand)
<never_> in Rust I would just make it a pointer but I wonder if there's not a more idiomatic way
<never_> forgive me, I'm bad at OOP
<never_> (BaseScene is a class)
<never_> nvm I figured it out - you can just put the alias in a class and it works =) thanks !
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
dragonkh has joined #crystal-lang
mark_66 has joined #crystal-lang
mark_66 has left #crystal-lang ["PING 1517215811"]
flaviodesousa has joined #crystal-lang
hightower has joined #crystal-lang
<FromGitter> <watzon> @MrSorcus maybe this will help you out https://github.com/crystal-lang/crystal/issues/2963
<FromGitter> <bararchy> If someone is at CyberTech come say hello , were at the Startup pavilion
hightower3 has joined #crystal-lang
hightower has quit [Ping timeout: 260 seconds]
shahe has joined #crystal-lang
shahe has quit [Quit: Leaving]
never_ has quit [Ping timeout: 240 seconds]
ua_ has quit [Ping timeout: 240 seconds]
jnyw has quit [Quit: WeeChat 2.0.1]
<dragonkh> hello - how can I create a Context.new here? for testing purposes? https://github.com/crystal-lang/crystal/blob/18e76172444c7bd07f58bf360bc21981b667668d/src/http/server/context.cr#L11
<dragonkh> It's within another class - so I can't do HTTP::Server::Context.new as it says HTTP::Server is not a module but a class
never_ has joined #crystal-lang
<dragonkh> maybe I have to to do HTTP::Server.new(port, handler) first
<FromGitter> <bajro17> Hi people I want ask you about installation crystal lang
<FromGitter> <bajro17> on linux mint I try install it with method described in on Debian and Ubuntu
<FromGitter> <bajro17> but it dont work for me only work method described in on Bash on Ubuntu on Windows
<FromGitter> <bajro17> is this problem with documentation on some difference between ubuntu and mint?
<FromGitter> <bajro17> or*
<dragonkh> I installed on Ubuntu using the instructions ok
<dragonkh> not tried on Mint though
<dragonkh> what goes wrong with the install on Mint?
<FromGitter> <bajro17> I try add this line in terminal
<FromGitter> <bajro17> echo "deb https://dist.crystal-lang.org/apt crystal main" > /etc/apt/sources.list.d/crystal.list
<FromGitter> <bajro17> and it dont work
<FromGitter> <bajro17> this work
<FromGitter> <bajro17> echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list
<FromGitter> <j8r> @bajro17 you are probably not root when launching the first command, try using `sudo echo...`
hightower has joined #crystal-lang
<FromGitter> <bajro17> I use but it dont work for me only work method described in on Bash on Ubuntu on Windows
hightower2 has quit [Ping timeout: 256 seconds]
<FromGitter> <j8r> I've tried on my side, it only works when you are on a root terminal. `sudo` before the command does'nt work - there is a redirection
alex`` has joined #crystal-lang
never_ has quit [Ping timeout: 256 seconds]
<FromGitter> <MrSorcus> > @MrSorcus maybe this will help you out https://github.com/crystal-lang/crystal/issues/2963 ⏎ Thanks you so much. Yes, it's working. But i'm not sure that's a good way. Anyway thanks you 😄
alex`` has quit [Ping timeout: 240 seconds]
cremes has joined #crystal-lang
ua has joined #crystal-lang
<FromGitter> <yxhuvud> What the heck was #5652 about?
cremes has quit [Quit: cremes]
duane has joined #crystal-lang
never has joined #crystal-lang
cremes has joined #crystal-lang
never has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] MakeNowJust opened pull request #5655: Fix indentation after comment inside 'when' (master...fix/crystal-format/keep-indent-in-when-comma) https://git.io/vNyAT
<FromGitter> <bajro17> Can someone tell me what is use of Symbols
<FromGitter> <bajro17> :test?
<livcd> symbol is an immutable object which refers to the same object in memory if you use it
<FromGitter> <bajro17> thank you so much :)
<RX14> no it's not
<livcd> is it not ?
<RX14> @bajro17 it's basically an enum but global
<livcd> i must be thinking Ruby
<RX14> livcd, in ruby you could say they're immutable strings which always point to the same memory
<RX14> but in crystal they're not
<RX14> they're numbers
<RX14> and they're all known at compile time
<FromGitter> <bajro17> than it mean it just return random number?
<FromGitter> <bajro17> I'm really confused
<RX14> no
<RX14> they're implemented as numbers
<RX14> ut they're not
<RX14> they're not equal to numbers
<RX14> I never use symbolks
<FromGitter> <bajro17> Than I will just skip it :D
<RX14> 99% of the time when you want a symbol you want either an enum or you're using it as a named tuple key
<FromGitter> <bajro17> Thank you so much Sir
<RX14> just learn how to use symbols as named tuple keys
<RX14> and learn how to use enums
<RX14> and you'll never have to use them
<RX14> we should just make named tuples use tuple.key, then remove symbols
<FromGitter> <bajro17> also I find I can put in enum green for example it must be Capital letter
<FromGitter> <bajro17> Gree
<FromGitter> <bajro17> Green
<RX14> yes
<FromGitter> <bajro17> Thank you so much for all you explain me :)
<FromGitter> <bajro17> also this dont work for me
<FromGitter> <bajro17> names = "John", "Peter", "Jack"
<FromGitter> <bajro17> Multiple assignment count mismatch
<FromGitter> <xfbs> Why not ⏎ ⏎ ```names = ["John", "Peter", "Jack"]``` [https://gitter.im/crystal-lang/crystal?at=5a6f31b6e217167e2c152683]
<FromGitter> <xfbs> or ⏎ ⏎ ```the_john, the_peter, the_jack = "John", "Peter", "Jack"``` [https://gitter.im/crystal-lang/crystal?at=5a6f31d9ce68c3bc741a9a44]
<RX14> @bajro17 what are you trying to do?
<FromGitter> <bajro17> I try example from there
<RX14> oh
<RX14> that documentation is out of date
<RX14> I removed that
<RX14> just use an array
<FromGitter> <bajro17> ok thank you
tomlukeywood has joined #crystal-lang
<tomlukeywood> Where would i find a web page explaining for loops in crystal? i cant find it in the official docs
<RX14> there are no for loops in crystal
<RX14> we have while loops and methods which take blocks
<RX14> if you want to iterate over an array you'd use array.each
<RX14> or if you want to do something n time you use n.times do |i|
<RX14> it's a little different to other languages but in crystal you just don't need for loops
<FromGitter> <j8r> the exception are macros, but that's special
snsei has joined #crystal-lang
<tomlukeywood> RX14: that makes sense ty
snsei has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
<tomlukeywood> RX14: How would I do something like for i in range(1..10) step 2
<tomlukeywood> using array.each?
<RX14> 1.step(to: 10, by: 2)
<tomlukeywood> ok
<FromGitter> <bajro17> a = 1..10
<FromGitter> <bajro17> a.to_a
<RX14> Please don't do it that way
<RX14> Allocating an extra array is very slow
<RX14> Plus this way reads a bit nicer
* tomlukeywood passed his code kata \o/
tomlukeywood has left #crystal-lang [#crystal-lang]
alex`` has joined #crystal-lang
<FromGitter> <imonmyown> it has a different meaning
<FromGitter> <bajro17> I find 1 more problem
<FromGitter> <bajro17> with until loop
<FromGitter> <bajro17> a = 1 ⏎ until false ⏎ puts "a" ⏎ a = a + 1 ⏎ break a == 10 ... [https://gitter.im/crystal-lang/crystal?at=5a6f3e0a40259f1a33c07dfe]
<FromGitter> <l3kn> `break if a == 10`
<FromGitter> <bajro17> it dont want to loop
<FromGitter> <bajro17> still dont work
<FromGitter> <bajro17> while loop work normal but until dont
<FromGitter> <l3kn> https://play.crystal-lang.org/#/r/3h5g `until false` should be the same as `while true` or just `loop`
<FromGitter> <bajro17> oh I see it work when I compile from file
<FromGitter> <bajro17> but dont want to work when start crystal play
<FromGitter> <l3kn> You don't see `(9 times) : String` on the right side? Seems like it doesn't “collect” the output for `until` loops
<FromGitter> <bajro17> I dont see 9 times
<FromGitter> <bajro17> yes it dont collect output
qard has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <drujensen> hey, need some help. I’m trying to capture a block and it doesn’t seem to recognize my method
<FromGitter> <drujensen> https://carc.in/#/r/3h5s
<FromGitter> <l3kn> @drujensen `validate` is an instance method but you call it like a class method
<FromGitter> <drujensen> yup, thats it
<FromGitter> <drujensen> thanks
snsei has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
alex`` has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
alex`` has quit [Client Quit]
<crystal-gh> [crystal] asterite closed pull request #5655: Fix indentation after comment inside 'when' (master...fix/crystal-format/keep-indent-in-when-comma) https://git.io/vNyAT
<FromGitter> <bajro17> is there any method to check if some elements is repeated in 2 arrays like
<FromGitter> <bajro17> a = [1, 2, 3,4]
<FromGitter> <bajro17> b = [3,4,5]
<FromGitter> <bajro17> to it return 2 because 3 and 4 repeat in both array
<FromGitter> <l3kn> @bajro17 https://play.crystal-lang.org/#/r/3h6f
<FromGitter> <l3kn> that gives you all elements that are in both arrays, `.length` on that would give you 2
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
snsei has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
<travis-ci> crystal-lang/crystal#995d3f9 (master - Fix indentation after comment inside 'when'): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/334785197
jokke has joined #crystal-lang
<jokke> hey
<jokke> is it already possible to compile crystal libs into .so files?
<jokke> afair it is possible to expose c functions
<FromGitter> <bew> Yes it's possible
<jokke> is it also possible to expose global variables?
<FromGitter> <bew> But not practical, and you won't be able to load 2 Crystal so file at the same time
<jokke> oh
<FromGitter> <bew> jokke don't think so
<jokke> i see
<jokke> too bad :/
<FromGitter> <bew> Why do you need a global var?
<jokke> and what if i built a .o file and a little c program which would set up the global pointer and function and provide a setter for that pointer. then link it with my crystal .o file?
<jokke> says so in the api reference
<jokke> In order to call WeeChat functions in the format displayed in Plugin API, the following global pointer must be declared and initialized in the function weechat_plugin_init:
<jokke> struct t_weechat_plugin *weechat_plugin;
<FromGitter> <bew> Oh yes, you'll need a little C file for that i think
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
cremes has quit [Quit: cremes]
flaviodesousa has quit [Ping timeout: 265 seconds]
<FromGitter> <codenoid> nice @watzon
<FromGitter> <codenoid> and, morning !
<FromGitter> <codenoid> I always hear Proleter and Caravan Palace song when coding with crystal
test has joined #crystal-lang
test has quit [Client Quit]
cremes has joined #crystal-lang
<FromGitter> <jwoertink> Hey, is there anyone here that's created a crystal package installable through homebrew?
<FromGitter> <jwoertink> I have one that always fails, and I don't really understand the homebrew formulas to know what I'm doing wrong
alex`` has quit [Quit: WeeChat 1.9]
<FromGitter> <jwoertink> I'm curious if you would just build the package, and then have homebrew install that built binary, or have homebrew actually run `make`, etc...
<FromGitter> <bmulvihill> myst-lang has a home-brew-tap
<FromGitter> <bmulvihill> which installs the executable (its crystal)
<FromGitter> <bmulvihill> i haven't tried it, but I assume it works
<FromGitter> <jwoertink> Ok, cool. Thanks!
<FromGitter> <jwoertink> I'll see what this one is doing that I'm missing
<FromGitter> <jwoertink> thanks @bmulvihill ! That helped a ton
<FromGitter> <bmulvihill> awesome!
<FromGitter> <bajro17> is it possible to make int array from gets
<FromGitter> <bajro17> if I type in terminal
<FromGitter> <bajro17> 1,2,3,4
<FromGitter> <bajro17> to do something like gets.slice(',')
<FromGitter> <straight-shoota> sd
<FromGitter> <imonmyown> `"1,2,3,4".split(',').map(&.to_i)`
cremes has quit [Quit: cremes]
<FromGitter> <bajro17> @imonmyown awesome bro thank you so much
<FromGitter> <bajro17> I learn more today then last few months :D
<FromGitter> <imonmyown> @bajro17 don't mention ;)
<FromGitter> <bajro17> I recorde some tutorials on yt for crystal lang and I want use this after lesson for arrays to make little game using just arrays and gets and puts
<FromGitter> <bajro17> at same time I learn more about crystal when I stack and ask here :)
<FromGitter> <codenoid> where's the link @bajro17
<FromGitter> <bajro17> I just start and my english is so bad :D
<FromGitter> <fridgerator> 👍
DTZUZU has quit [Quit: WeeChat 1.9]
<FromGitter> <codenoid> just joined at 27 Jan ?, wow, good luck 👍
DTZUZU has joined #crystal-lang
<FromGitter> <bajro17> I create this channel mostly for crystal lang because I fall in love with this language and its hard to find good tutorial on internet than I will try combine all what I can find in documentation and answers from awesome people hear and make some good tutorial
<FromGitter> <bew> @bajro17 you can also do: `"1,2,3,4".split(',', &.to_i)` less allocations :)
<FromGitter> <bajro17> thanks @bew I will do it than like this :)
<FromGitter> <bajro17> also how to create array of 35 unique numbers from 1 to 50?
<RX14> Array.new(35) { rand(1..50) }
<RX14> rip debot 2017 jhass
<FromGitter> <imonmyown> @RX14 are you sure they will be unique?
<RX14> no
<FromGitter> <codenoid> the irc bot ?
<RX14> yeah
<RX14> @imonmyown yeah I missed that part of the requirement
<RX14> the uniqueness is a pain
<FromGitter> <imonmyown> > puts "Hello"
<RX14> it was always >>
<FromGitter> <imonmyown> \>> puts "Hello"
<FromGitter> <imonmyown> crap
<RX14> but its offline
<RX14> it's gone
<RX14> it has 0% chance of working
<RX14> @bajro17 why do the numbers need to be unique
<RX14> ?
<FromGitter> <imonmyown> why not just take consecutives from 1 to 50
<RX14> ??
<FromGitter> <imonmyown> *1 to 35*
<RX14> because thats not what was asked for?
<FromGitter> <bajro17> I need it for this little game tutorial to make bingo
<FromGitter> <imonmyown> well technically it fits the requirements
<RX14> @bajro17 then you'll need an iterative solution
<FromGitter> <bajro17> it display 35 unique numbers in range 1..49
<RX14> just create an array
<RX14> loop until array.size == 35
<FromGitter> <l3kn> `(1..50).to_a.shuffle.take(35)`
<FromGitter> <bajro17> a = Array.new(10) { rand(1..50) }.uniq I try like this but it remove same value
<RX14> yes
<FromGitter> <l3kn> wait, `take` does not work, `...shuffle[0, 35`
<RX14> @l3kn thats exactly what I just wrote
<RX14> except more expensive
<RX14> actually no
<RX14> never mind
<RX14> thats a good solution
<RX14> ignore me
<RX14> do what @l3kn said
<FromGitter> <bajro17> I never ignore you Sir I appreciate all help from you :)
<RX14> it's pop 35
<RX14> a = (1..50).to_a
<RX14> a.shuffle!
<RX14> a.pop(35)
<RX14> thats the best code
<FromGitter> <bajro17> yes but I dont understand why it give all time 15 numbers in array
<RX14> what
<FromGitter> <l3kn> `pop(35)` removes and returns the last elements of the array
<FromGitter> <l3kn> so only the first 15 remain
<RX14> you're emant to use the result of the pop(35)
<RX14> not use a
<RX14> but i'm wrong
<RX14> you should use a[0, 35]
<RX14> not a.pop(35)
<FromGitter> <bajro17> now it work yeeey thank you so much
alex`` has joined #crystal-lang
<FromGitter> <asterite> `(1..50).to_a.sample(35)`
<RX14> Oh
<RX14> I should read the stdlib
<FromGitter> <asterite> Of course I'd keep `(1..50).to_a` as a constant and just invoke `sample` on that
andrewzah has quit [Quit: ""]
cremes has joined #crystal-lang
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
duane has quit [Ping timeout: 240 seconds]
<oprypin> `(1..50).sample` does not work but it should
qard has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14> why oprypin?
<RX14> you can't shuffle an arbitrary stream of numbers without storing them
<oprypin> RX14, well there's no reason for it to not work
<oprypin> sampling does not require shuffling
qard has joined #crystal-lang
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
<RX14> it requires you to know the size of the collection to be fair
<oprypin> and you know the size of 1..50
<RX14> Enumerable doesn't
<oprypin> RX14, that's the problem, it actually should be Indexable
<oprypin> and sample should be on Indexable
<RX14> but a range isn't indexable
<RX14> and it shouldn't be
<RX14> because ranges are defined by #succ and a limit
<oprypin> what do you mean it isn't indexable
<oprypin> oh, that minor snag, right
<RX14> ranges are not conceptaually indexable
qard has quit [Client Quit]
<RX14> they're only enumberable
<RX14> your suggestion only works for number ranges and not all ranges are number ranges
<oprypin> i think the sacrifice on ranges went in the wrong direction
<RX14> what sacrifice?
<oprypin> well this one
<oprypin> they're not indexable (which is very useful btw)
<oprypin> just so they can be defined by #succ
<RX14> and how would you suggest defining them?
<oprypin> start, step, stop
<oprypin> which is also how they actually work
<RX14> uhh
<RX14> thats still not indexable
<oprypin> tell that to python
<RX14> oh, so every index goes back to the start and adds n times
<RX14> great
<RX14> thats not useless at all
snsei has quit [Remote host closed the connection]
<oprypin> stuff like `(1..10..2).index(5)` is nice
snsei has joined #crystal-lang
<oprypin> in O(1) ofc
snsei has quit [Remote host closed the connection]
andrewzah has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<RX14> if you complicate the definition of range you basically make it so only integers can be in ranges
<oprypin> yes
snsei has joined #crystal-lang
<RX14> so no
<RX14> thats a bad idea
<RX14> you've answered it yourself
<oprypin> what other useful ranges are there?
andrewzah has quit [Client Quit]
<RX14> i don't know
<oprypin> uh ok
<oprypin> you've answered it yourself
snsei has quit [Ping timeout: 240 seconds]
cremes has quit [Quit: cremes]
<FromGitter> <j8r> I don't know if ranges floats is useful
qard has joined #crystal-lang
cremes has joined #crystal-lang
qard has quit [Client Quit]
<FromGitter> <ShriekBob> How would you range floats though?
<FromGitter> <ShriekBob> I mean, you could, but you'd need a step size
<FromGitter> <ShriekBob> otherwise theres no meaningful way to do it
<FromGitter> <ShriekBob> Man, I made a suggestion for a change to the spec output, and now I'm like "maybe i hsould submit a PR"
<FromGitter> <ShriekBob> but I can't make head nor tail of the spec implementation. I've found where the spec description is ouput, but damned if I can find where it's set
<RX14> @ShriekBob what are you trying to modify?
<FromGitter> <ShriekBob> My comment at the bottom
<FromGitter> <ShriekBob> Turn: ⏎ ⏎ .F ⏎ ⏎ Failures: ... [https://gitter.im/crystal-lang/crystal?at=5a6fa440494bd0f5303fa6f5]
<FromGitter> <ShriekBob> Man, that was a mess, sorry about that
<FromGitter> <ShriekBob> Sure, I'm reading that atm, but fail.description seems to contain the bulk of the text
<FromGitter> <ShriekBob> and I'm not sure where that is being set
<RX14> no
<RX14> fail.description is the "foo does something with 3 and 4" bit
<FromGitter> <ShriekBob> Ohhh
<RX14> yeah it confused me a bit
<FromGitter> <ShriekBob> I assume it must also set "in spec: "
<RX14> since I wasn't looking correctly at the current spec output
<FromGitter> <ShriekBob> because the previous thing on that line just seems to generate n)
<RX14> which has no in spec:
<FromGitter> <ShriekBob> Ohhh
<RX14> look at a current spec output
<RX14> in spec isn't there
<FromGitter> <ShriekBob> Lesson 1: Confirm the format is still the same
<RX14> well
<RX14> I made the same mistake
<RX14> so don't feel too bad about it lol
<FromGitter> <ShriekBob> Seems like a relatively small change that I can submit a PR for, and even if it never get's merged, helps me work my way around :)
jnyw has joined #crystal-lang
moei has quit [Quit: Leaving...]
<FromGitter> <bajro17> Your code is here :D
sz0 has joined #crystal-lang
<FromGitter> <bajro17> thank you all for today I go sleep and see you tomorrow with 100 new questions :D hahha
Liothen has quit [*.net *.split]
txdv has quit [*.net *.split]
duane has joined #crystal-lang
dahhowl has quit [Ping timeout: 260 seconds]
dahhowl has joined #crystal-lang
txdv has joined #crystal-lang
Liothen has joined #crystal-lang
dahhowl has quit [Ping timeout: 260 seconds]
dahhowl has joined #crystal-lang