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>
<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>
<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`
<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.
<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>
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
<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…]
<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>
<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>
<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> 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
<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.
<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`
<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
<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>
<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>
<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.]