<FromGitter>
<anamba> did anyone else chime in yesterday on an easy way to work on shards locally? if not, here is an improved version of the script i posted yesterday to replace `lib/myshard` with a symlink. obviously you could do this by hand, but doing it several times a day becomes tedious very quickly. https://gist.github.com/anamba/4b30076c6f9869b041d592c4347d8e11
<FromGitter>
<Blacksmoke16> you know you can give your shards a reference to a directory
<FromGitter>
<girng> so if it's a property it assigns the 16 bits to it. and that's the max. but if it's just a local variable/variable or whatever, it change dynamically dependent on what value you give it? can fluxuate between 16bits, 32bits, etc, etc?
<FromGitter>
<Timbus> youre reassigning the variable.. you could do `a = 10; a = "string";` too..
<FromGitter>
<girng> but i initially set the variable to use 16 bits only, just like how i would in a class
<FromGitter>
<Timbus> you didn't. you just assigned a variable to an int that was 16 bits. this doesn't limit future assignments
<FromGitter>
<Timbus> you want `number : Int16 = 0`
<FromGitter>
<girng> i see, so the "limit future assignments" only happen if it's assigned a type in a Class property?
<FromGitter>
<Timbus> it just needs to have a type constraint at some point
<FromGitter>
<girng> yeah i just figured i didn't need to do the `: Int16` part, because i don't do that for my class properties and it restricts the type. but i guess if i don't use property macro, i need to restrict it. thanks!
<FromGitter>
<anamba> still working with the phusion passenger team to figure out why passenger and `HTTP::Server` don't seem to get along. anyone have any idea what 3rd thing HTTP::Server might be doing, other than either accepting the connection or returning a ECONNREFUSED? https://github.com/phusion/passenger/issues/2144#issuecomment-445394338
<FromGitter>
<proyb6> ```Array(myStruct).new``` took 120+ns to create new array, can it gets faster?
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #crystal-lang
jemc has quit [Client Quit]
<FromGitter>
<girng> this a good way to check if an array has valid indexes that are in a hash?
<FromGitter>
<girng> it's working 100%, and i like it but just curious if i'm doing it the right way lol
<FromGitter>
<anamba> @DanilaFe you are pretty quick! i haven't had to do this kind of stuff since maybe soph year of college time. which for me, was like 18 years ago.
<FromGitter>
<DanilaFe> Fortunately for me, this *is* my first sophomore year of college :)
<FromGitter>
<anamba> getting a good brain workout from aoc.
<FromGitter>
<DanilaFe> I managed to scored in the top 100 a couple of days in 2017, so I'm trying to recapture that. Closest I've gotten was 200 though :(
<FromGitter>
<anamba> wow nice. wait, i got 187 yesterday
<FromGitter>
<anamba> maybe you finished right between when i submitted and when i checked the leaderboard :)
<FromGitter>
<anamba> i thought you beat me yesterday
<FromGitter>
<DanilaFe> Yesterday wasn't a good day for me, actually
<FromGitter>
<DanilaFe> I did pretty well on part 1 but took a solid hour on part 2
<FromGitter>
<anamba> ok, i must have been thinking of another day, heh. yesterday's was extremely straightforward for me. (also i wanted to finish quick to try smash bros)
<FromGitter>
<DanilaFe> The first part was straightforward, but I still can't come up with a good solution for part 2. I had to study for an exam, but abandoning the problem was not an option
<FromGitter>
<anamba> i actually could have finished yesterday's part 2 a lot quicker except that i misread, and used a <= instead of < π’
<FromGitter>
<anamba> my one chance at a top 100 finish...
<FromGitter>
<DanilaFe> I was actually having a similar issue. Kind of unfortunate
<FromGitter>
<DanilaFe> There's still, what, 18 days left?
<Yxhuvud>
yawn.
<FromGitter>
<DanilaFe> oh hey, @Yxhuvud, aren't you the #2 from the leaderboard?
<Yxhuvud>
yes
<FromGitter>
<DanilaFe> how's this advent of code going for you?
<Yxhuvud>
so-so
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter>
<anamba> looking for a shard that makes use of the mozilla public suffix list to figure out the "base" domain name, given a string. like this: https://github.com/weppos/publicsuffix-ruby i haven't found one yet... i will probably have to make it. but if anyone knows of something similar, please let me know!
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter>
<girng> that gonna be a lot of ifs π
<FromGitter>
<asterite> compiler bug, but it's because time is closured
<FromGitter>
<r00ster91> alright I will open up an issue
<FromGitter>
<asterite> it already exists
<FromGitter>
<asterite> search immutable vars
<FromGitter>
<asterite> it's similar
<FromGitter>
<r00ster91> ah ok
<FromGitter>
<girng> im trying to change a property of a class by a string https://play.crystal-lang.org/#/r/5q31/edit β use case: i have skill tree data, and each node modifies the player's stats. want to do it all in one loop instead of a bunch of if statements using .notation
<FromGitter>
<girng> IF It can only be done with a macro, please don't show me how just give me a starting point where to look. because i can learn if i do it with a macro by myself
<FromGitter>
<r00ster91> but you can try doing it with a macro as well. Hint: you have to pass a Player object to the macro and you need to define the macro with `macro`
<FromGitter>
<girng> ok
<FromGitter>
<girng> @r00ster91 so i can't actually put any macro code inside the []=(name, value) part?
<FromGitter>
<girng> instance_vars
<jokke>
asterite: would there have been any way to make the code i pasted above work? i tried casting the result of chain to Iterator(Node) but that just triggered an infinite loop while compiling until i was out of ram
<FromGitter>
<r00ster91> you need to put your macro stuff inside a `macro`, not a `def`
<FromGitter>
<r00ster91> you can put macros everywhere
<FromGitter>
<proyb6> I'm thinking how would you rename ```Node``` to ```Tree``` instead because it's easier to read and it's π²
<FromGitter>
<r00ster91> you can solve the problem by having only one macro in your class and the properties @girng β you dont need a def and a macro
<FromGitter>
<asterite> jokke: what code?
sagax has quit [Read error: No route to host]
<foxxx0>
when I'm defining a custom class with some properties, how do I need to write the #initialize() so that some properties are optional and they are properly initalizes with e.g. an empty array
<foxxx0>
ah, just specify default values for the arguments in the #initialize()...
<RX14->
good news: you'll get to play with your favourite spinny logo on the new crystal forums :) http://owo.sh/3b9f9b.png
RX14- is now known as RX14
<FromGitter>
<vladfaust> Nice!
<FromGitter>
<proyb6> Cool! But spinny logo can be non-animated?
<jokke>
asterite: i get an generic type too nested error if i try that
<FromGitter>
<asterite> then i guess there's no way to do it
<jokke>
mmh
<FromGitter>
<asterite> the iterator results in an infinite recursive type
<FromGitter>
<asterite> and because crystal doesn't have interfaces nor virtual dispatch there's no way to represent that
S0bait has joined #crystal-lang
<S0bait>
Afternoon
<S0bait>
When Crystal creates an app via `crystal init app <app_name>`, how do run the build command? From the way the command seems to be laid out, it seems we need to have a "root module" in src?
<FromGitter>
<drum445> if your app_name is project
<FromGitter>
<asterite> `crystal` is the "dummy" compiler: takes a file (and dependencies from it), compiles it to an executable. `shards` is higher level in that it will put it in `bin`, allow to compile multiple targets, etc.
jemc has joined #crystal-lang
jemc has quit [Ping timeout: 244 seconds]
jemc has joined #crystal-lang
jemc has quit [Ping timeout: 246 seconds]
sagax has joined #crystal-lang
_whitelogger has joined #crystal-lang
S0bait has quit [Quit: Connection closed for inactivity]
<FromGitter>
<bhargavrpatel> How do i change the time that appears on gitter
<FromGitter>
<delef> Why does autodetection type not work in this case?
<FromGitter>
<r00ster91> It would probably be possible to type infernce this as well. But I think it would probably take pretty long. From the beginning of Crystal you didn't even have to specify the type of an array. This worked: `arr = []` but it was super slow! IIRC it took around 30 seconds to compile because Crystal of course has to type inference every type that might be pushed into that array! β So you still have to specify
<FromGitter>
... *some* types. But probably still way less than in other compiled languages.
rohitpaulk has quit [Ping timeout: 244 seconds]
non-aristotelian has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
<FromGitter>
<DanilaFe> 30 seconds, darn
<FromGitter>
<DanilaFe> I got to Crystal after this was changed
Vexatos has quit [Remote host closed the connection]
Vexatos has joined #crystal-lang
<FromGitter>
<bigeasy> Is Crystal written in Crystal?
<FromGitter>
<vladfaust> Almost, yes
<FromGitter>
<bigeasy> What bits are not Crystal and what language are they written in?
<FromGitter>
<bigeasy> I'm poking through the source, so if you could suggest a directory to look in, that would be appreciated.
<FromGitter>
<bigeasy> `/src/llvm/ext/llvm_ext.cc` is all I could find.
<FromGitter>
<bigeasy> So, that means it's almost entirely built by itself. Neato.
<FromGitter>
<j8r> the parts not written in Crystal can be due to lower level stuff that Crystal depends: LLVM is written in C++, Assembly to interact with processors.
<FromGitter>
<kingsleyh> hey - can anyone give me some pointers on how I should represent this struct in Crystal
<FromGitter>
<kingsleyh> I don't understand what this C code is doing exactly
<FromGitter>
<kingsleyh> my guess would be the struct takes 2 inputs - the pkey and the key - and then get0 takes the pkey and returns the pkey? and get1 takes the pkey and returns the key?
mps has joined #crystal-lang
<FromGitter>
<girng> @delef i believe because classes need to know the instant variable types before initializing them