<FromGitter>
<Blacksmoke16> ` get_response.headers.add "Foo", "Bar"` added a class method that is accessible in all controllers, to get request/response
<FromGitter>
<Blacksmoke16> so its there if you need it but not in the way if you dont
g- has quit [Quit: Lost terminal]
g- has joined #crystal-lang
sagax has joined #crystal-lang
rohitpaulk has joined #crystal-lang
jemc has quit [Ping timeout: 250 seconds]
jemc has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<j8r> Send macro as a proc?!
<FromGitter>
<j8r> Remember macro are expanded before compilation
<FromGitter>
<j8r> If proc there is, it can only be done inside the macro world
<devil_tux>
what does `wrap` keyword does?
<devil_tux>
s/does/do
hightower2 has joined #crystal-lang
ashirase has quit [Ping timeout: 250 seconds]
<FromGitter>
<dscottboggs_gitlab> @j8r I realize it didn't work, and I figured it probably wouldn't, the (kinda funny) issue is the `given 0, expected 0` error message
<mps>
I found reason for failed build of the crystal 0.27.2 on Alpine. Build fails with libxml2 2.9.9 version. with previous libxml2 version i.e. 2.9.8, crystal can be built and pass tests with some small tweaks
<mps>
so, my question is, what is the libxml2 version with which 0.27.2 is build for other distributions, if anyone can tell me
<FromGitter>
<straight-shoota> @j83 That's wrong. The compiler binary is actually built and linked on alpine 3.8. But the compiler itself doesn't use libxml2, so it's not linked.
<FromGitter>
<j8r> oh ok
<FromGitter>
<j8r> so it uses the libxml2 of the host
<FromGitter>
<j8r> @straight-shoota but why there is a from debian at the start?
<FromGitter>
<j8r> this Dockerfile is a bit messy :/
<FromGitter>
<straight-shoota> Yes, definitely
<FromGitter>
<straight-shoota> It first cross-compiles the compiler from debian (gnu) to alpine (musl) and links it statically on alpine. This boostrapped compiler is then used to compile the actual binary and it's also linked on alpine.
<FromGitter>
<j8r> got it, thanks
<FromGitter>
<straight-shoota> Resolving #7196 should help to reduce the complexity at least a little bit
<FromGitter>
<dscottboggs_gitlab> xenial is not a debian version itโs ubuntu 16.04 but close enough
<FromGitter>
<straight-shoota> Oh, right. I mistyped.
<FromGitter>
<dscottboggs_gitlab> Nbd I just didnโt want someone to get confused because they couldnโt find debian xenial haha
<mps>
straight-shoota: your post explains a lot to me
<mps>
I waste some time trying to understand that
<mps>
building (compiling, testing and building static version of compiler) on Alpine 3.8 worked without problem and on the v3.9 before libxml2 is upgraded
<FromGitter>
<straight-shoota> what exactly is the error message with libxml2 2.9.9?
<mps>
after libxml2 upgrade it fails in check (make spec)
<mps>
straight-shoota: right now I don't have it saved, but something about sigfault
<mps>
I will upgrade libxml2 again and run build and will save build log
<FromGitter>
<straight-shoota> okay ๐
<FromGitter>
<straight-shoota> Just open an issue about that
<mps>
on github? I don't have account there
<mps>
I will post results to some of paste services
<jokke>
hm is it by design that i can't require code from below src/
<jokke>
i have stuff in db/ that needs compiling
<jokke>
if i try requiring files there i get an error that the file wouldn't exists
<jokke>
-s
<FromGitter>
<straight-shoota> mps, allright, then post it here
<mps>
ok, will do
<FromGitter>
<straight-shoota> jokke, what's the require expression?
<FromGitter>
<straight-shoota> then there's one `..` too much
<jokke>
hm why?
<jokke>
one .. would be in src/
<FromGitter>
<straight-shoota> and the file you want to require is in src/db/template_migrations
<FromGitter>
<straight-shoota> ?
g- has quit [Quit: Lost terminal]
<jokke>
no
<jokke>
it's in db/template_migrations
<jokke>
so outside of src
<FromGitter>
<straight-shoota> Oh okay, you said it was below src
<FromGitter>
<straight-shoota> By default, only src is in the path
<jokke>
ah
<jokke>
that'd explain it
<FromGitter>
<straight-shoota> You can add `./db` (or `.`) to `CRYSTAL_PATH` to make this directory available, but I think it's a good convention to keep all code in src
<jokke>
it's a good security feature though
<jokke>
yeah definitely but these are database migrations
<FromGitter>
<straight-shoota> Hm, yeah
<FromGitter>
<straight-shoota> Have you looked at how frameworks like amber and lucky do this?
<FromGitter>
<straight-shoota> Well, probably they don't include the migrations into the binary and just run them on the fly
<FromGitter>
<straight-shoota> But I can see there's a use case for embedding them into a single binary.
<FromGitter>
<straight-shoota> So why not put them in src/db/ instead of db/ ?
<FromGitter>
<Sija> IIRC that's a convention inherited from (at least) Rails
<FromGitter>
<Sija> which btw makes sense, since migrations are not code *per se*, they are coded transformations
<FromGitter>
<Sija> so they could be written down in many formats, not necessarily code even though they usually are
<FromGitter>
<Sija> you don't keep specs or benchmarks under src/ as well, same story here I guess
wmoxam has quit [Ping timeout: 240 seconds]
<FromGitter>
<j8r> does it make sense to have a shared library with migrations?
<FromGitter>
<j8r> a `.so` I mean
<FromGitter>
<Sija> I dunno, seems pretty weird
<Yxhuvud>
it could make sense if the app share a db with another app, but that isn't very common
<Yxhuvud>
aka avoid it if you can
wmoxam has joined #crystal-lang
Dreamer3 has joined #crystal-lang
<devil_tux>
is there literal to alias_method? aka an alias to specific method, can `previous_def` be used like that
<devil_tux>
currently I can create new `def` and call previous method
<FromGitter>
<Sija> @devil_tux nope, there is not, quite intentionally because Crystal tries to discourage aliases
<devil_tux>
shame :<
<FromGitter>
<Sija> `previous_def` has nothing to do with aliases though, it's used to call the previous impl *of the same method* inside the override
<devil_tux>
yeah, figured that out.. not sure why is it described as an rubys `alias_method` tho
<FromGitter>
<Sija> you can easily do it with macros if u need to
<FromGitter>
<Sija> you'd need to ask @r00ster91 about it since he's the original author as it seems
<FromGitter>
<jwoertink> I have some code using `Time.now.to_s("%Y-%m-%d %H:%M:%S %:z")` and `Time.parse_utc(current_time, "%Y-%m-%d %H:%M:%S %:z")`. Is there any Time constant that already specifies this format? or maybe a shortcut method to handle this? I saw some things like the iso_8601 and rfc something, but I'm not sure which to use?
<FromGitter>
<Sija> IMO this comparison should be removed since it's highly confusing
hightower2 has quit [Ping timeout: 245 seconds]
<FromGitter>
<Sija> @jwoertink IIRC there's none but @straight-shoota will know for sure
<FromGitter>
<jwoertink> I like how rails has `Time.now.to_s(:db)`. It would be sweet to have that as well as doing `Time.parse(time, :db)` or even `Time::Format::DB` or whatever
<FromGitter>
<Sija> last time I've checked `Time::Format` is missing some commonly used format(s), but in any case you can define it yrself for sure
<FromGitter>
<jwoertink> Yeah. I'll probably end up just defining it myself. Think I should open an issue to discuss? Or would this fall under the "just do it yourself" category? lol
<FromGitter>
<Sija> I'm pretty sure that it would end up in this category but you can open an issue anyway ;)
<FromGitter>
<Sija> Some kind of a neat API to access commonly used formats (with ability of extension) would be a nice thing to have... I'd give it a ๐ for sure
fanta7531 has joined #crystal-lang
<FromGitter>
<mixflame> hey guys, I'm back
<FromGitter>
<mixflame> :D
<FromGitter>
<jwoertink> Welcome back
Dreamer3 has quit [Quit: Computer has gone to sleep.]
<FromGitter>
<kingsleyh> Evening
<FromGitter>
<mixflame> Evening (morning here)
<FromGitter>
<mixflame> Thanks :D
fanta7531 has quit [Quit: fanta7531]
<FromGitter>
<girng> https://play.crystal-lang.org/#/r/6bso anyone know why going from the number `42` to `43` modifies `p.health` to a negative number?
<FromGitter>
<kinxer> @girng It's because you're using an `i8`
<FromGitter>
<girng> i also feel like i'm using f32 too much. is it worth it to jus use the regular float64? i was just thinking of using float32 because less space, but that's negligible right
<FromGitter>
<girng> that way, i don't need to do "f32" everywhere, really ajnnoying
<FromGitter>
<kinxer> You're multiplying `level` by 3. `42 * 3` is `126`, which barely fits in the range of an 8-bit integer. When you change it to `43`, that product becomes `129`, which overflows back down to `-127`. You then add `10.0`, getting `-117.0`
<Jenz>
Alright, thanks, looks smart, though I dunno how to_set is better than using .uniq
<Jenz>
Thanks again oprypin, I really appreciate your help and all you've done for the crystal community
<Jenz>
And everyone else :D
<oprypin>
yay
<Jenz>
So many nice Crystal people
<oprypin>
Jenz, `uniq` needs to keep the order and a set doesn't
<oprypin>
though hopefully it also uses a set under the hood (otherwise it's n^2 complexity)
<FromGitter>
<j8r> Why set won't keep the order? It's based on Hash
<FromGitter>
<j8r> @girng that's why I said better to use integers...
<FromGitter>
<j8r> When you got thousands of player, it may affect perf to have floats operations and casting everywhere
<Jenz>
Hashes are amazing
<Jenz>
...
<Jenz>
Though I don't really get 'em
<Jenz>
I should read more
<Jenz>
(On them)
<Jenz>
s/more/anything/
<Jenz>
I'm sad how rarely I manage to find places I can use Sets
<FromGitter>
<drum445> Does anyone know how to get days between two dates correctly?
<FromGitter>
<drum445> actually, is there a way to set the time location to use app wide, this new change with locations is causing a lot of issues?
<FromGitter>
<drum445> `Time::Location.local = Time::Location.load("UTC")` โ if anyone needs
Dreamer3 has joined #crystal-lang
devil_tux has quit [Read error: Connection reset by peer]
Jenz has quit [Quit: leaving]
<mps>
straight-shoota: sorry, had a visitors. here is result of 'abuild check' (make spec) http://tpaste.us/ErXO
<mps>
crystal 0.27.2 with libxml2 2.9.9, llvm5
<FromGitter>
<dscottboggs_gitlab> @Blacksmoke16 remember when I was trying to create a type union using a macro? Look what I just found in the Kemal source code! โ โ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c6f1f25a7d733509da4baa8]
<FromGitter>
<Blacksmoke16> ayy
<FromGitter>
<Blacksmoke16> nice one
<FromGitter>
<dscottboggs_gitlab> indeed!
devil_tux has joined #crystal-lang
<FromGitter>
<Blacksmoke16> i found another bug with athena/granite last night :(
<FromGitter>
<dscottboggs_gitlab> oh, no
<FromGitter>
<dscottboggs_gitlab> what happened
<FromGitter>
<Blacksmoke16> `in lib/CrSerializer/src/CrSerializer/json/to_json.cr:15: no overload matches 'Granite::Base#to_json' with types JSON::Builder, Array(String), Array(String)`
<FromGitter>
<Blacksmoke16> works fine when i only have 1 model defined, else i get that that wont compile
<FromGitter>
<Blacksmoke16> yet i can call it manually and serializes just fine
<FromGitter>
<dscottboggs_gitlab> oh, I feel like this is kinda related to an issue I've been running into
return0e_ has joined #crystal-lang
<FromGitter>
<Blacksmoke16> havent dug into it much yet tho
<FromGitter>
<Blacksmoke16> oh?
<FromGitter>
<dscottboggs_gitlab> If you try to serialize a type union that can also resolve to an abstract class, you run into weird errors
<FromGitter>
<Blacksmoke16> i think it has to do with the type being a union of the two models
<FromGitter>
<dscottboggs_gitlab> I haven't been able to create a consistent minimal example but there have been a few times where I've run into issues where that happened.
return0e has quit [Ping timeout: 255 seconds]
<FromGitter>
<dscottboggs_gitlab> I think I'll take another stab at a minimal example now...
<FromGitter>
<dscottboggs_gitlab> take a look at the issues surrounding promotion of Unions to a common type, there might be something going on there @Blacksmoke16
<FromGitter>
<Blacksmoke16> yea, based on the error its defaulting to its base type
<FromGitter>
<Blacksmoke16> ill poke you if i find out anything
<FromGitter>
<dscottboggs_gitlab> yeah that's similar to the issue I've been running into with `instantiating allocate` and other not-helpful errors. haha
<FromGitter>
<Blacksmoke16> because like both should easily be able to have that method called on them
<FromGitter>
<Blacksmoke16> im defining it on `Object` like standard serialization stuff
<FromGitter>
<Blacksmoke16> :shrug: ill figure it out
<FromGitter>
<dscottboggs_gitlab> my workaround most recently was to replace the abstract base class with an alias, but that won't work for you
<FromGitter>
<dscottboggs_gitlab> OH!
<FromGitter>
<dscottboggs_gitlab> So, {{type}}::Serializable is a module, which defines `self.new` on an included class, right?
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<Blacksmoke16> also gets carried over to subclasses
<FromGitter>
<dscottboggs_gitlab> I think what's happening, is if you define that on an abstract class, it might try to actually instantiate the abstract class, on line 119 there
<FromGitter>
<Blacksmoke16> but its not abstract
<FromGitter>
<Blacksmoke16> and im calling `to_json` so shouldnt be related?
<FromGitter>
<dscottboggs_gitlab> but if I were right, there would be a rescue on that allocate that would be obfuscating the error there too
<FromGitter>
<dscottboggs_gitlab> ๐ญ
<FromGitter>
<Blacksmoke16> :shrug: see if you can reproduce it :P
<FromGitter>
<Blacksmoke16> but i have a WIP draft of the athena + granite blog/tutorial post i been working on if you wanted to see it
<FromGitter>
<Blacksmoke16> get some early feedback