ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | 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
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
Creatornator has joined #crystal-lang
ashirase has quit [Ping timeout: 264 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
greengriminal has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter> <girng> :D :D
<FromGitter> <girng> Hello
snsei has quit [Ping timeout: 265 seconds]
<FromGitter> <girng> my topic got almost 100 views already :D
kixune[m] has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
qard has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Client Quit]
Yxhuvud has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
Creatornator has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Yxhuvud has quit [Client Quit]
Yxhuvud has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
illy_ has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
qard has quit [Quit: qard]
faustinoaq has quit [Ping timeout: 265 seconds]
faustinoaq has joined #crystal-lang
<FromGitter> <XaRuLa> hello anyone know how to code shell linux command on cr like ping or etc
<FromGitter> <aisrael> hi, channel! what's the easiest or recommended way to um... dynamically create an instance based on something? For example, depending on a file extension, instantiate either a `SqlFoo` or a `YamlFoo`? I tried creating a `Hash(String, FooBase)` but couldn't figure out how to call `FooBase.load_file` polymorphically (that is, have `FooBase.load_file` resolve to `SqlFoo.load_file`)
<FromGitter> <aisrael> I'm loathe to go the "Java route" of having `FooFactory` and `SqlFooFactory` and `YamlFooFactory`, and so on.
<FromGitter> <aisrael> (In Ruby, well, *everything's* dynamically dispatched so...)
<FromGitter> <aisrael> Also, for now I just "hard code" it using `case ... when` but that creates a) a "circular reference loop" between `FooBase` and all its descendants, and b) obviously, it's now hard-coded which prevents other people who might use this as a library from adding extensions and handlers of their own
<FromGitter> <aisrael> (Ok, am now looking at `crystal_db` for how they do it...)
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has quit [Remote host closed the connection]
flaviodesousa has joined #crystal-lang
<crystal-gh> [crystal] RX14 closed pull request #5485: Work String#starts_with? with regex (master...feature/string/starts_with_with_regex) https://git.io/vbNFX
<FromGitter> <strigonLeader> ```code paste, see link``` ⏎ ⏎ I get the following error with this code: ⏎ instance variable '@branches' of Project was not initialized directly in all of the 'initialize' methods, rendering it nilable. Indirect initialization is not supported. ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5acb3db27c3a01610dc23907]
<oprypin> strigonLeader, please make a complete example reproducing this error
<oprypin> strigonLeader, actually nevermind, i know the cause. you're using `self` before it's fully initialized
<oprypin> basically, cant use `self` inside `initialize`
<crystal-gh> [crystal] RX14 closed pull request #5718: Keep empty sections when parsing INI (master...keep_empty_ini_sections) https://git.io/vA3eQ
<FromGitter> <straight-shoota> you can just assign a default value, then it's fine
<FromGitter> <straight-shoota> @branches : Hash(String, String) ⏎ ⏎ def initialize(@name : String) ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5acb3f30270d7d3708aa004f]
<FromGitter> <straight-shoota> damn
<FromGitter> <straight-shoota> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5acb3f3c080a385053115546]
<FromGitter> <strigonLeader> is that intentional behaviour?
<FromGitter> <strigonLeader> I can confirm Johannes' solution worked for me
<FromGitter> <straight-shoota> Or, the mischievous and potentially dangerous way is to just alias `self`: 😁 Because you can call methods on `self` (although only with implicit receiver). ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5acb401d6d7e07082bd489be]
<FromGitter> <bararchy> XD
<FromGitter> <straight-shoota> the behavious is prinicially intended, but not 100% accurate
<FromGitter> <strigonLeader> so I shouldn't use self in the initializer at all?
<FromGitter> <straight-shoota> In general, it is a good feature of the compiler to not let you use `self` while it is still being initialized. It ensures sanity. But it's not always correct (for example where `self` will not be directly used), and it just doesn't catch all possible scenarios :P
<FromGitter> <straight-shoota> you can use it after all ivars are initialized
<FromGitter> <strigonLeader> oh I see
blackchalk has joined #crystal-lang
<FromGitter> <strigonLeader> so once I've initialized @branches it recognises that self is initialized and lets me use it
<FromGitter> <strigonLeader> ok
<FromGitter> <strigonLeader> thanks
<travis-ci> crystal-lang/crystal#4f4240b (master - Work String#starts_with? with regex (#5485)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/364044636
<DeBot> https://github.com/crystal-lang/crystal/pull/5485 (Work String#starts_with? with regex)
blackchalk has quit [Quit: quitting]
blackchalk has joined #crystal-lang
blackchalk_ has joined #crystal-lang
blackchalk_ has quit [Client Quit]
blackchalk has quit [Ping timeout: 245 seconds]
<travis-ci> crystal-lang/crystal#b1c30c2 (master - Keep empty sections when parsing INI (#5718)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/364049287
<DeBot> https://github.com/crystal-lang/crystal/pull/5718 (Keep empty sections when parsing INI)
<FromGitter> <strigonLeader> splat arguments can't have no values?
<oprypin> incorrect
<oprypin> thats a triple negative
<FromGitter> <strigonLeader> nvm didn't rtfm
ua__ has joined #crystal-lang
duane has quit [Ping timeout: 255 seconds]
ua_ has quit [Ping timeout: 265 seconds]
Sarah___ has joined #crystal-lang
<Sarah___> Quick question, how do you get user input in crystal?
duane has joined #crystal-lang
<wuehlmaus> e.g. STDIN.gets or STDIN.read_line or STDIN.gets_to_end
<Sarah___> Thanks
<oprypin> drop the `STDIN.`, it's cleaner
duane has quit [Ping timeout: 245 seconds]
<Sarah___> Now to run it in terminal, having come from Ruby, do you use the name of the language, and beside it the name of the program?
<oprypin> generally yes
<RX14> yes
<RX14> for now :)
<Sarah___> That fixed it, apparently I had a conflict.
<FromGitter> <girng> good morning!
<Sarah___> I had installed it to user, than had a previous version of desktop.
<Sarah___> Hello.
<Sarah___> Gtg for now. Thanks again.
Sarah___ has quit [Quit: Page closed]
<FromGitter> <bararchy> if I do ⏎ ⏎ ```Foo.new(hi = "hello", bye = "bye bye") ⏎ ⏎ # V.S ⏎ ⏎ Foo.new("hello", "bye bye")``` ⏎ ⏎ Does it matter? as in do those vars get assaigned or ? [https://gitter.im/crystal-lang/crystal?at=5acb4fe1080a38505311a675]
<wuehlmaus> oprypin: why is dropping STDIN. cleaner, it's at least not clearer :)
<oprypin> bararchy, it's `hi="hello"; bye="bye bye"; Foo.new(hi, bye)`
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> I see, thanks
duane has joined #crystal-lang
shalmezad has joined #crystal-lang
<FromGitter> <girng> i love crystal!!
<FromGitter> <bararchy> :)
<FromGitter> <bararchy> dont we all @girng
<wuehlmaus> +1 :)
<wuehlmaus> hihi, sorry for the viral answer!
<Groogy> Crystal-san daaaai-ski~~!
<FromGitter> <girng> i've been used to dynamic languages all my life. crystal makes me feel about my code that i write because of the static types
<FromGitter> <girng> i believe static types make the programmer feel more confident (it does for me anyway)
<oprypin> :)
<FromGitter> <bararchy> for me it was a very wierd transition from Ruby, but now I can't live without it
<FromGitter> <girng> it is very different though, and i need to define everything but i like that bcz it helps me remember which property is doing what (since it's now ingrained in my head that it's that specific type). it was really hard at first because in js/gdscript/php i just wrote a variable and forgot about it. it's nice, but i also forgot about the true meaning of that variable and later on while coding. yes, naming the
<FromGitter> ... variable property helps, but there is something about setting its true type, that really stick with my brain. ⏎ ⏎ hard to explain, but agree @bararchy now i don't want to go back bcz i feel like i'm doing something wrong
<Groogy> I wished there were an easier interfaceo to initialize an array with certain size and unique objects than with the block :/
<crystal-gh> [crystal] straight-shoota opened pull request #5932: Add context to errors in JSON.mapping (master...jm/feature/mapping-errors) https://git.io/vx7AE
<faustinoaq> `64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=86.5 ms` lol, my Internet is pretty slow :)
<faustinoaq> `64 bytes from 1.1.1.1: icmp_seq=1 ttl=58 time=32.2 ms` Well, seems CloudFlare dns is a bit faster ;)
<FromGitter> <straight-shoota> Groogy, what would that be?
<FromGitter> <straight-shoota> you can do `Array.new(@size.x * @size.y, Bucket.new)` but then all items will point to the same instance of `Bucket`
<oprypin> when 1.1.1.1 first came out, it wouldn't load on my home internet connection. thankfully it works now
<Groogy> yeah I know
<Groogy> would be nice though
<oprypin> `64 bytes from 1.1.1.1: icmp_seq=4 ttl=58 time=1.84 ms` `64 bytes from 8.8.8.8: icmp_seq=4 ttl=59 time=2.18 ms`
<Groogy> Array.initialized(@size.x * @size.y, args_for_obj)
<Groogy> and that would initialize every element with the args you give
<oprypin> Groogy, i see nothing wrong with this, and in this case i would insist that you use the { } syntax
<oprypin> `.new(@size.x * @size.y) { Bucket.new }` is perfectly fine
<Groogy> it gets really freaking long though
<Groogy> depending on the array type etc.
<oprypin> i dont think you need the (Type)
<livcd> I just read the news that there's fudning for 1 full time crystal developer. Who is it ? :-)
<Groogy> hmm I could try
<FromGitter> <straight-shoota> yes, it will be inferred
<FromGitter> <straight-shoota> from the block return value
<oprypin> livcd, there haven't been news on that front. i'm guessing that this is a theoretical concept, just money-wise they could afford it
<Groogy> yeah it worked
<livcd> oprypin: ah ok
<FromGitter> <straight-shoota> That's way better readable than a cryptic `Array(Bucket).initialized(size)`
<faustinoaq> oprypin, lol, your Internet by much more faster than mine XD
<faustinoaq> s/by//
<wuehlmaus> anybody able to compile crystal with the latest llvm-config 6 on Apple? on Arch Linux i get it to compile with llvm-6, here it throws errors.
<wuehlmaus> i am on Apple Sierra right now.
<wuehlmaus> i talk about crystal-git
<oprypin> wuehlmaus, you should start by posting the error
txdv has quit [Ping timeout: 260 seconds]
<wuehlmaus> i posted the error weeks ago and became the answer that i should use llvm-config 5 so i stood away from repetition this time.
rohitpaulk has quit [Ping timeout: 256 seconds]
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 260 seconds]
faustinoaq has quit [Ping timeout: 265 seconds]
faustinoaq has joined #crystal-lang
txdv has joined #crystal-lang
shalmezad_ has joined #crystal-lang
<RX14> oprypin, it's less theoretical in that there will be a full-time crystal dev - it's just not decided who yet
shalmezad has quit [Ping timeout: 264 seconds]
<faustinoaq> RX14, Perhaps Manas can hire ary or waj fulll time for crystal :D
<RX14> waj is full-time in another role
<RX14> just pulling someone out of a critical role in a company isn't going to happen
<faustinoaq> Oh, ok
<RX14> and I doubt that ary wants to come back and work on crystal full-time
<faustinoaq> lol
<FromGitter> <straight-shoota> in the end it doesn't really matter who it is or even if the full-time job was shared. It's long awaited good news which will hopefully get some really needed manpower to the core team.
<RX14> exactly
<Vexatos> wouldn't a shared full-time job be two part-time jobs?
<RX14> yes
<FromGitter> <straight-shoota> Obviously, that does not mean we'll have multithreading and windows support by next month 😆
<Vexatos> Maybe in half a year, who knows :P
<FromGitter> <straight-shoota> ... but maybe one of those^^ 😏
<RX14> somebody recently made the std_specs run very slow
<RX14> used to be 4 seconds
<RX14> now 17 seconds
<FromGitter> <straight-shoota> => #5508
<DeBot> https://github.com/crystal-lang/crystal/issues/5508 (General benchmarks suite)
<RX14> nothing related
<RX14> ah
<RX14> it's all the specs that compile other programs and run them
<RX14> ugh
<RX14> building an empty file now takes 0.849 seconds
<RX14> when did *that* happen
<FromGitter> <gnuos> hi
<RX14> hi
<FromGitter> <gnuos> i don't know how to express myself. i've had some trouble.
<FromGitter> <wrq> That's universal
<FromGitter> <wrq> We've all been there
<FromGitter> <bararchy> @gnuos well, you can start by letting us know if its code related or general bad life decision? After that you can share the code and error :)
<FromGitter> <girng> if it's php related, i welcome you to open arms
<FromGitter> <gnuos> i was going to statically compile a app, which was written in crystagiri, and i hoped that i can learn crystal through some spider example, but the compilation was failed.
<FromGitter> <straight-shoota> you shouldn't start learning crystal and try to compile statically linked exe
<FromGitter> <straight-shoota> static binaries are nice to have in certain situations, but not yet completely supported by Crystal and you can do as good without
bcardiff has joined #crystal-lang
qard has joined #crystal-lang
shalmezad_ has quit [Quit: changing network adaptor (again)]
<FromGitter> <gnuos> but i tried to compile crystal
<FromGitter> <gnuos> that was ok
<FromGitter> <straight-shoota> compiling statically has some issues
<FromGitter> <straight-shoota> you could at least show us the compiler output... otherwise there's no way in helping you except suggesting to stay away
shalmezad has joined #crystal-lang
<FromGitter> <gnuos> ok , wait a moment
rohitpaulk has joined #crystal-lang
benharri has quit [Quit: The Lounge - https://thelounge.github.io]
benharri has joined #crystal-lang
<oprypin> is there any way to get the compiled crystal binary from travis / circle ?
<oprypin> and i know that it could be arranged by adding a config to manually push it somewhere, but anything out of the box?
<Vexatos> Travis can't do it unless you upload it elsewhere like you mentioned
<Vexatos> I don't know circle
andrewzah has joined #crystal-lang
faustinoaq has quit [Ping timeout: 260 seconds]
faustinoaq has joined #crystal-lang
<FromGitter> <gnuos> i created a repository
benharri has quit [Quit: The Lounge - https://thelounge.github.io]
benharri has joined #crystal-lang
<FromGitter> <straight-shoota> please just paste in the compiler output
<FromGitter> <gnuos> and i described my compile command
<RX14> --static doesn't work anywhere but alpine linux
<FromGitter> <straight-shoota> what does this command produce?
<RX14> don't use the flag
<faustinoaq> @gnuos, Do you have all static dependencies installed?
<FromGitter> <gnuos> i recorded the command produce
<oprypin> gnuos, ok don't use --static
<FromGitter> <gnuos> ok
<FromGitter> <gnuos> i see
<FromGitter> <gnuos> thank you
<FromGitter> <gnuos> oh, when can i use --static ?
<oprypin> in a few years hopefully
<FromGitter> <gnuos> oh, god
<FromGitter> <girng> 😄
<FromGitter> <bararchy> Or use alpine , I made a few static bins
<FromGitter> <gnuos> maybe i could adapt dynamic linking
<FromGitter> <gnuos> aha
<RX14> adapt?
<FromGitter> <gnuos> ☺️
<FromGitter> <gnuos> my english is poor
<FromGitter> <gnuos> sorry
<FromGitter> <gnuos> 😄
<FromGitter> <gnuos> thank for your help
<FromGitter> <gnuos> thanks
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
flaviodesousa has quit [Ping timeout: 276 seconds]
<faustinoaq> @gnuos Which language do you speak well?
<faustinoaq> :)
<FromGitter> <gnuos> i use chinese . 😃
<FromGitter> <gnuos> I like Crystal and Ruby
<faustinoaq> @gnuos Nice!
<FromGitter> <gnuos> I have read this post
<faustinoaq> @gnuos BTW, you can use docker as well, see this: https://manas.tech/blog/2017/04/03/shipping-crystal-apps-in-a-small-docker-image.html
<FromGitter> <gnuos> yeah,I am reading this Dockerfile
<faustinoaq> Yeah, that's the official docker repo
<FromGitter> <gnuos> @bararchy thx
<oprypin> girng, there is no magic that would switch you to the other fiber somehow. that's why usually you don't invade on other objects, but send them a message with channels
<oprypin> player 1 's fiber calls a method, then the method executes in player 1 's fiber
<FromGitter> <girng> even if that method uses other player's .send method?
<oprypin> a player is not connected to a fiber in any way
<oprypin> you just happened to call its methods (event loop / accept) in one fiber and then call its methods from another fiber
<FromGitter> <girng> okay got it
<FromGitter> <girng> cool, thanks for explanation
<FromGitter> <girng> ok that's really cool then. cuz if a player is in a chat with 25 people, and elaves. i send out a notifications to all those other players, that his user has left the channel
bcardiff has quit [Quit: bcardiff]
<FromGitter> <girng> and it's done in that user's fiber, doesn't bother the others, so i should be ok
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has quit [Ping timeout: 260 seconds]
bcardiff has joined #crystal-lang
Creatornator has joined #crystal-lang
<oprypin> you could have sent this as text
<oprypin> girng, the code you write above is a loop, it is executed synchronously.
<FromGitter> <girng> @oprypin kk cool. i like synchronicity
<FromGitter> <girng> thanks again btw
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<oprypin> np
Yxhuvud has quit [Ping timeout: 255 seconds]
<FromGitter> <girng> wow opyrpin you steam profile is impressive
<crystal-gh> crystal/master 1a6d597 Jakub Jirutka: Makefile: Allow to extend FLAGS (#5860)
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vx5l4
Creatornator has joined #crystal-lang
<FromGitter> <girng> i think the only game i 100% completed was diablo 2, but that's just cuz i played it since i was 12
qard has joined #crystal-lang
<FromGitter> <dbachinin> Hi! Please tell me. How in crystal convert u32 little-endian to u8 bytes (ie. 409611234_u32 to [226_u8, 43_u8, 106_u8, 24_u8]? Or convert it`s to binary dump (ie. \xE2+j\u0018*W\u001C\x9C)
<FromGitter> <dbachinin> Is that possible?
<FromGitter> <dbachinin> applying simple action
<oprypin> dbachinin, https://crystal-lang.org/api/0.24.1/IO.html#write_bytes%28object%2Cformat%3AIO%3A%3AByteFormat%3DIO%3A%3AByteFormat%3A%3ASystemEndian%29-instance-method
<oprypin> dont actually use io.gets though :|
<oprypin> this probably https://crystal-lang.org/api/0.24.1/IO.html#read%28slice%3ABytes%29-instance-method
<FromGitter> <dbachinin> @oprypin thank you! I need read more documentation!
<FromGitter> <dbachinin> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5acba34927c509a774f3cd69]
<FromGitter> <girng> same
Yxhuvud has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
<FromGitter> <wrq> I wish the crystal site had a pdf version of the docs. I'm offline 90% of the time and I'd like to spend time reading documentation. Can gitbook be made to output a pdf?
<crystal-gh> [crystal] Givralix opened pull request #5933: Corrected a typo in File's documentation (master...master) https://git.io/vx50A
<FromGitter> <girng> can try this: https://github.com/GitbookIO/gitbook-pdf
<FromGitter> <bararchy> @wrq if you clone the compiler you can use `crystal docs` inside the directory, this will create an offline resource
<FromGitter> <wrq> @oprypin thanks very much! I really appreciate it.
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
<FromGitter> <Sjoerrdd> Hey
<FromGitter> <girng> Hey
<FromGitter> <Sjoerrdd> I'm learning about a week now, I like the language (I love ruby, and this speed is awesome!). ⏎ The community is also really awesome. ⏎ Thanks dudes!
<FromGitter> <girng> agreed. devs here really do love helping
<FromGitter> <Sjoerrdd> I'm a developer for 5 years now (17 y/o student), and this is the best what happend in the last 7 years
<FromGitter> <girng> damn u started young. i first got into programming at 17
<FromGitter> <Sjoerrdd> :P
<FromGitter> <Sjoerrdd> Crystal is great, but I need better support for Windows
<FromGitter> <girng> i was looking at the Time api, but can't find a way to get the elapsed time since the crystal app stfarted?
<FromGitter> <girng> started* in milliseconds is that possible?
<FromGitter> <dbachinin> crystal eval 'io = IO::Memory.new(409611234);slice = Bytes.new(4);io.read(slice);p slice'
<FromGitter> <dbachinin> Where did I doing wrong?
<FromGitter> <dbachinin> Because this line return: Bytes[0_u8, 0_u8, 0_u8, 0_u8]
<crystal-gh> [crystal] RX14 closed pull request #5575: Alter logic in Time.leap_year? for performance (master...slightly-better-leap_year-calc) https://git.io/vNslW
<oprypin> dbachinin, uh i think you created an io of 409611234 zeros
<FromGitter> <sam0x17> @Sjoerrdd that's when I started, and I'm 26 now ;)
<FromGitter> <sam0x17> was all PHP back then, or (gasp) ASP.NET
<FromGitter> <straight-shoota> @girng Crystal itself doesn't store a time reference at startup, but you can do that easily in your code
<FromGitter> <straight-shoota> ```APP_STARTED = Time.measure ⏎ ⏎ # somewhere else: ⏎ elapsed = Time.measure - APP_STARTED``` [https://gitter.im/crystal-lang/crystal?at=5acbaee05f188ccc15489cb8]
<oprypin> dbachinin, sorry for possible confusion. i sent you the first link but told you not to use the `.gets` part from it. but you need to use the rest of the example
<oprypin> and your example is exactly what you need to replace `gets` with
<FromGitter> <Sjoerrdd> PHP is my job, asp.net my education :( and Crystal my hobby :P
<FromGitter> <Sjoerrdd> What is "the best" Crystal framework for a API?
<oprypin> good luck doing your job now...
<FromGitter> <girng> @straight-shoota wow, cool
<FromGitter> <dbachinin> @oprypin why? it`s 409611234 the digit.
<oprypin> dbachinin, what do you mean why? it's what it does, as per docs https://crystal-lang.org/api/0.24.1/IO/Memory.html#new%28capacity%3AInt%3D64%29-class-method
<FromGitter> <dbachinin> @oprypin thank you!
<FromGitter> <dbachinin> @oprypin 0_o!!! You turn over my view! :)
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <girng> if i have a property that is a 0_i64 type. then change this property to a int64 digit during the app, but then change it to `0` when a user logs off, is that redundant or does the space taken already allocated. switching it back to 0 makes no sense right?
<oprypin> what you're saying makes no sense
<FromGitter> <girng> for example, if you set a property to 0_i64 (0), but it now becomes `Time.now.epoch_ms`. *(Which is a LARGER number than 0)*. do i need to set that property back to 0 or can i just leave it? Is it taking up the same amount of space whether it is 0 or `9,223,372,036,854,775,808`?
<oprypin> taking up the same amount of space
<FromGitter> <straight-shoota> eh
<FromGitter> <straight-shoota> Int64 is always 64 bit, that's even in the name!!
<FromGitter> <girng> well, that's why im trying to use elapsed time since app started instead of time.now.epoch_ms bcz it takes a int64 which is YUUUGGEEE
<oprypin> no it's tiny
<FromGitter> <straight-shoota> and a Time::Span takes 128 bit.
rohitpaulk has joined #crystal-lang
<FromGitter> <straight-shoota> And you most certainly shouldn't use Time.now to calculate elapsed time but `Time.measure` as in the example I gave you
<oprypin> girng, computers these days have 100000000000 bits, they can handle 64
<FromGitter> <girng> ` 'Time.measure' is expected to be invoked with a block, but no block was given`
<oprypin> what @straight-shoota actually meant might have been `monotonic` https://github.com/crystal-lang/crystal/blob/80a975cf0a98a4ce8464d0069145131667becd70/src/time.cr#L178
<FromGitter> <straight-shoota> ah, yes thatnk oprypin
<FromGitter> <straight-shoota> *thanks
<FromGitter> <straight-shoota> doing to many things
<FromGitter> <girng> wait, it says takes the time for a block to run
<FromGitter> <straight-shoota> `Time.measure` does essentially `t0 = Time.monotonic; run_block; return Time.monotonic - t0` for you
<oprypin> and run_block is actually replaced with your code, it has ZERO overhead
<oprypin> and run_block is not a real thing, just an example
<FromGitter> <straight-shoota> but I figure you probably might want to take several measurements of the time elapsed since startup, so you can't use `Time.measure`
<FromGitter> <girng> ok i got it
<FromGitter> <girng> i changed Time.measure to Time.now.epoch_ms it works, thx @straight-shoota
<travis-ci> crystal-lang/crystal#1ce052c (master - Alter logic in Time.leap_year? for performance (#5575)): The build is still failing. https://travis-ci.org/crystal-lang/crystal/builds/364245928
<DeBot> https://github.com/crystal-lang/crystal/pull/5575 (Alter logic in Time.leap_year? for performance)
<FromGitter> <straight-shoota> you should use `Time.monotonic`, sorry for the confusion
<oprypin> lol
<FromGitter> <girng> 1) 08:07:09.181690000 wtf is dat O_o
<oprypin> looks like 8 hours
<FromGitter> <straight-shoota> 1 day 8 hours 7 minutes 9.18169 seconds
<FromGitter> <straight-shoota> time seems to fly at your location 😄
<oprypin> must be a fast time zone :p
<FromGitter> <straight-shoota> or relativistic effect
<FromGitter> <girng> hahaha
duane has quit [Ping timeout: 260 seconds]
qard has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bcardiff has quit [Quit: bcardiff]
Creatornator has joined #crystal-lang
rohitpaulk has joined #crystal-lang
bcardiff has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <girng> which shard command deletes/uninstalls a shard?
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5acbc6af27c509a774f485f4]
<oprypin> rm -r lol
<FromGitter> <girng> :D
<FromGitter> <j8r> I like prunes :)
<FromGitter> <girng> good antioxidants in there to protect from php
Jenz has joined #crystal-lang
<Jenz> Man, just found out the 'utero' os, 'written in crystal as much as possible'; has 4 lines of crystal code, which is binding to a c main, and calls it............
<FromGitter> <girng> lmao
bcardiff has quit [Quit: bcardiff]
<FromGitter> <straight-shoota> Jenz, well... it's a work in progress. But at least 98% written in Crystal thanks to including the entire stdlib
<FromGitter> <girng> https://play.crystal-lang.org/#/r/3uoh/edit can sum1 help what i'm doing wrong?
<FromGitter> <straight-shoota> 100 is parsed as Int32
<FromGitter> <straight-shoota> use 100_i64 for Int64
<FromGitter> <girng> oh WOW
<FromGitter> <girng> fail, sorry about that
<FromGitter> <girng> thakn you
<oprypin> Jenz, dafuq, and 30 stars
Jenz has quit [Ping timeout: 240 seconds]
bcardiff has joined #crystal-lang
shalmezad has quit [Quit: Leaving]
benharri has quit [Quit: The Lounge - https://thelounge.github.io]
benharri has joined #crystal-lang
Jenz has joined #crystal-lang
<FromGitter> <ryankshah> Is there a crystal equivalent for the Ruby `.to_sym`?
<FromGitter> <ryankshah> Also is this a valid statement? `@var.is_a?(Hash)`
Jenz has quit [Ping timeout: 276 seconds]
qard has joined #crystal-lang
Jenz has joined #crystal-lang
<FromGitter> <straight-shoota> @ryankshah no and yes
<FromGitter> <ryankshah> Is there a workaround to `.to_sym`?
<FromGitter> <straight-shoota> to_sym cant work because symbols are not available at runtime
<FromGitter> <ryankshah> Fair enough ^^
<FromGitter> <straight-shoota> you could case when over possible strings and hard code the respective symbols
Jenz has quit [Ping timeout: 265 seconds]
<FromGitter> <straight-shoota> but that stinks
<FromGitter> <straight-shoota> you shouldn't need to convert a string to a symbol at runtime
<FromGitter> <ryankshah> Would `@var[method_param]` be the same as `@var[method_param.to_sym]` then?
<FromGitter> <straight-shoota> if @var has string keys, yes
<FromGitter> <ryankshah> if not?
<FromGitter> <straight-shoota> then probably not, depends on the implementation of `#[]`
<FromGitter> <ryankshah> ^^
<FromGitter> <ryankshah> Okay prob best for me to come up with a better way of doing what I gotta do :) thanks
<FromGitter> <straight-shoota> in Ruby it is quite common to use Hash with Symbol keys
<FromGitter> <straight-shoota> in Crystal you don't
<FromGitter> <straight-shoota> either use String keys or NamedTuple
<FromGitter> <ryankshah> Cheers :)
<FromGitter> <girng> ok ima try to learn something by myself but want guidance on where
<FromGitter> <girng> to read about it. i'll give u a hint
<FromGitter> <girng> sorting array oftuples by a property
<FromGitter> <girng> don't give answer plz, i want to see if i can do it by myself but which docs should i look at?
rohitpaulk has quit [Ping timeout: 245 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <girng> ok. i think i got it but am stuck
<FromGitter> <bew> missing comma after Int32
<FromGitter> <girng> yea, fixed that ty, nething else maybe?
<FromGitter> <bew> don't use a NameTuple, use a class or struct
<FromGitter> <girng> ok
Creatornator has joined #crystal-lang
<FromGitter> <bew> otherwise you have to use `a[:some_key]` to access a key in a namedtuple
<FromGitter> <bew> but I strongly suggest class or struct
Jenz has joined #crystal-lang
mooe has joined #crystal-lang
<oprypin> girng, you should actually use sort_by
<oprypin> `sort_by { |x| x.last_joined_channel_time }`
<oprypin> `sort_by &.last_joined_channel_time`
<FromGitter> <girng> https://crystal-lang.org/api/0.24.2/Array.html#sort%21%28%26block%3AT%2CT-%3EInt32%29-instance-method
Jenz has quit [Ping timeout: 260 seconds]
ua__ has quit [Ping timeout: 260 seconds]
bcardiff has quit [Quit: bcardiff]
ua__ has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <fridgerator> I'm trying to bind a C library, and I'm stuck. Wondering if someone knows how to handle this. ⏎ ⏎ https://github.com/fridgerator/netcdfcr/blob/read/src/netcdf/types/nc_var.cr#L143 ⏎ ⏎ trying to do something similar to this : https://github.com/swillner/netcdf4-js/blob/master/src/Variable.cpp#L264 [https://gitter.im/crystal-lang/crystal?at=5acbe5f76bbe1d2739cc0ce7]
<FromGitter> <fridgerator> specifically for the `NC_DOUBLE` type
<FromGitter> <fridgerator> returns 0.0 every time, when I know its not
<oprypin> fridgerator, this is too much stuff to get into
<FromGitter> <fridgerator> what do you mean?
<oprypin> i can't be bothered reading all this to help you
<FromGitter> <fridgerator> then just dont respond...
<oprypin> now, I get that this sounds offensive, but this is feedback and in case you don't get responses, this may be the reason
<FromGitter> <straight-shoota> 👍
<FromGitter> <girng> @oprypin thank you, i did ⏎ ⏎ ```temp.sort_by! do |x| ⏎ x[:last_joined_channel_time] ⏎ end``` ⏎ ⏎ and it worked. i have two questions though cuz im still confused how it works ... [https://gitter.im/crystal-lang/crystal?at=5acbe7f292f5d62057af15bf]
Creatornator has joined #crystal-lang
<oprypin> .sort is what the description is about. .sort_by is different - compare this thing instead of the actual value
<oprypin> seems to be no way to specify reverse order in sort_by. for integers a hack is to add a minus. or just .sort.... .reverse
<FromGitter> <girng> oh good idea
<oprypin> for .sort just use > instead of <
<oprypin> i guess it's the more general approach. although Python completely eliminated it and has only sort_by
<FromGitter> <girng> thatm akes sense then. sort by a value, then reverse it if you want ASC or DESC order
<FromGitter> <girng> i wish it had your description here: https://crystal-lang.org/api/0.24.2/Array.html#sort_by%28%26block%3AT-%3E_%29-instance-method
<FromGitter> <girng> will help a lot
Jenz has joined #crystal-lang
<FromGitter> <straight-shoota> docs for these methods are in master
<FromGitter> <straight-shoota> just not release yet
<FromGitter> <straight-shoota> and https://crystal-lang.org/api/master/ lags behind one month...
<oprypin> oof
Jenz has quit [Ping timeout: 256 seconds]
<FromGitter> <bew> @fridgerator can I ask why you're using netcdf4-js (the js binding of netcdf4) as a 1-1 reference ?
<FromGitter> <girng> yay! got it all working @oprypin https://play.crystal-lang.org/#/r/3uq7/edit im going to stick with namedtuple for now just cuz. but will take bews struct/class suggestion into consideration
<FromGitter> <fridgerator> In most cases so far ive been able to figure out a working solution using the node (v8 c++) as examples
<FromGitter> <fridgerator> I tried reading the python version and gave up
<FromGitter> <fridgerator> My issue is I don't know what types to pass for a lot of the libc types, so I guess based on the node version
<FromGitter> <bew> what does it do ? (the method you're implementing) do you have documentation somewhere?
sz0 has joined #crystal-lang
<FromGitter> <fridgerator> just reads a single value from the file
<FromGitter> <fridgerator> but netcdf files are multidimensional
rohitpaulk has joined #crystal-lang
<FromGitter> <girng> multidimensional files? sounds like sorcery
<FromGitter> <fridgerator> so if there is one dimension you just pass `read(index)`
<FromGitter> <fridgerator> if there are 3 dimensions, you pass `read(index1, index2, index3)`
<FromGitter> <fridgerator> they're actually quite nice, they are used a lot in environmental data sciences
<FromGitter> <fridgerator> a good example of dimensions would be time x latitude x longitude
<FromGitter> <fridgerator> so given some variable `RH` (relative humidity), give me the value for `t` , `lat`, `lng`
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <fridgerator> this is a little over my head, seeing as how I dont know C, and I'm not familiar with the inner workings of the filetype
<FromGitter> <fridgerator> was just trying to give environmental data people a reason to try crystal
<FromGitter> <fridgerator> this would be a first step
DeBot has quit [Ping timeout: 256 seconds]
DeBot has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang