ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.19.4 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
hako_ has quit [Read error: Connection reset by peer]
hako has joined #crystal-lang
ome has joined #crystal-lang
<FromGitter> <redcodefinal> YAY First Shard http://crystalshards.xyz/redcodefinal
ruby_ has quit []
lacour has quit [Ping timeout: 244 seconds]
kulelu88 has quit [Quit: Leaving]
vikaton has joined #crystal-lang
<crystal-gh> [crystal] potatogopher opened pull request #3496: Rename Contributing.md to CONTRIBUTING.md (master...patch-1) https://git.io/vXZSR
ome has quit [Quit: Connection closed for inactivity]
hako has quit [Read error: Connection reset by peer]
hako has joined #crystal-lang
jfontan has quit [Ping timeout: 260 seconds]
jfontan has joined #crystal-lang
pawnbox has joined #crystal-lang
ome has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter> <sdogruyol> @redcodefinal congrats
pawnbox has quit [Remote host closed the connection]
no0p has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
<FromGitter> <phoffer> @sdogruyol I ran into an oddity with websocket routing that I’m not sure is a bug or just a limitation of `WebSocketHandler` being separate from `RouteHandler`… ⏎ I’m trying to have a sort of “subscription” web socket handler that looks like this: ⏎ ```code paste, see link``` ⏎ Is this a bug or just a limitation? It’s not a big problem, I’m just working through Kemal web socket prototyping and trying to fully
ome has quit [Quit: Connection closed for inactivity]
vikaton has quit [Quit: Connection closed for inactivity]
bjz has joined #crystal-lang
hako has quit [Ping timeout: 250 seconds]
Fichtenstein has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
bjz has joined #crystal-lang
bjz has quit [Client Quit]
onionhammer has quit [Ping timeout: 256 seconds]
timeyyy has joined #crystal-lang
bjz has joined #crystal-lang
timeyyy_ has joined #crystal-lang
timeyyy has quit [Read error: Connection reset by peer]
timeyyy has joined #crystal-lang
timeyyy has quit [Read error: Connection reset by peer]
_timeyyy has joined #crystal-lang
_timeyyy has quit [Read error: Connection reset by peer]
onionhammer has joined #crystal-lang
timeyyy_ has quit [Ping timeout: 260 seconds]
mark_66 has joined #crystal-lang
sooli has joined #crystal-lang
DeBot has joined #crystal-lang
gloscombe has joined #crystal-lang
bjz has quit [Ping timeout: 250 seconds]
bjz_ has joined #crystal-lang
bjz_ has quit [Ping timeout: 252 seconds]
bjz has joined #crystal-lang
Philpax has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
Fichtenstein has quit [Read error: Connection reset by peer]
Fichtenstein has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
<FromGitter> <raydf> @redcodefinal nice lib :).
sustained has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
mark_66 has quit [Quit: Leaving.]
mark_66 has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sustained has quit [Remote host closed the connection]
sustained has joined #crystal-lang
shawn42 has joined #crystal-lang
dhk has joined #crystal-lang
sooli has quit [Ping timeout: 260 seconds]
<FromGitter> <paulcsmith> @sdogruyol What kind of middlwares are you reusing and composing that are so helpful? Sounds super interesting, but I'm not entirely sure how you are using them
<FromGitter> <paulcsmith> I'm referring to this BTW https://twitter.com/sdogruyol/status/794149280223232000 :)
<FromGitter> <sdogruyol> @paulcsmith i definitely need to write a blog post / series about those
<FromGitter> <sdogruyol> basically param validations, auth, exception handling and anything you can think of
<FromGitter> <sdogruyol> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=581b3b9d6cb72076302ef43e]
<FromGitter> <sdogruyol> think of the request - response lifecycle going from up to down
<FromGitter> <paulcsmith> Do you also use them for finding and assigning values? I've been trying to figure out how to use middleware for that, but it doesn't really seem possible/nice since you'd need to open up the HTTP context and add instance variables with optional types for the things you assign. Or maybe I just don't know how to do it
<FromGitter> <paulcsmith> That is super cool looking
<FromGitter> <paulcsmith> So does Middlewares::User load up a user and assign it to the context?
<FromGitter> <sdogruyol> indeed
<FromGitter> <sdogruyol> well not `User` but `user_id` in my case
<FromGitter> <paulcsmith> Ohh would you mind sharing that middleware? I've been trying to figure out how to do something like that
<FromGitter> <sdogruyol> because for now you can't store `Object`
<FromGitter> <paulcsmith> Ohh ok that makes sense
<FromGitter> <sdogruyol> hold on
<FromGitter> <paulcsmith> So in the controller/action you still need to grab the actual record from the DB
<FromGitter> <sdogruyol> and this middlewares are super testable
<FromGitter> <sdogruyol> @paulcsmith yep
<FromGitter> <sdogruyol> this is actually for existence
<FromGitter> <sdogruyol> not assigment
<FromGitter> <sdogruyol> check this
<FromGitter> <sdogruyol> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=581b3c5331c5cbef43af2550]
bjz has joined #crystal-lang
<FromGitter> <paulcsmith> Cool :D Thanks for sharing @sdogruyol. Reminds me of plugs in Elixir
<FromGitter> <paulcsmith> Kind of a bummer that records can't be assigned to the server context, but I don't think that could really be done :( Not a big deal though. A lot can be done in middleware as you showed
<FromGitter> <sdogruyol> yeah
<FromGitter> <paulcsmith> Pretty awesome
<FromGitter> <sdogruyol> someone else also said the same
<FromGitter> <sdogruyol> looked like plug
gloscombe has quit [Ping timeout: 260 seconds]
gloscombe has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
dhk has quit [Quit: Leaving]
<crystal-gh> [crystal] asterite closed pull request #3496: Rename Contributing.md to CONTRIBUTING.md (master...patch-1) https://git.io/vXZSR
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
ruby_ has joined #crystal-lang
ruby_ has quit [Remote host closed the connection]
sandelius has joined #crystal-lang
pawnbox has joined #crystal-lang
blassin has joined #crystal-lang
<blassin> hey all
<blassin> is it possible to write to a binary file at a specific offset?
<BlaXpirit> sure, why not
<blassin> I can't find a version of IO#write that takes an offset
<BlaXpirit> ..
<BlaXpirit> blassin, https://crystal-lang.org/api/0.19.4/IO/FileDescriptor.html#seek%28offset%2Cwhence%3ASeek%3DSeek%3A%3ASet%29-instance-method
<blassin> ah ok, so you seek before writing
<blassin> thanks!
<travis-ci> crystal-lang/crystal#b36f72a (master - Rename Contributing.md to CONTRIBUTING.md): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/172978757
blassin has quit [Quit: Page closed]
mark_66 has quit [Remote host closed the connection]
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <redcodefinal> Hey guys, anyone have any experience with [stumpy_png](https://github.com/l3kn/stumpy_png)? I'm planning on writing some utilities on top of it, specifically for combining images, layering them one on top of the other, expansion, inflation etc. Wanted to hear if anyone here has any stumpy_png code they'd be willing to share.
gloscombe has quit [Quit: Lost terminal]
<BlaXpirit> redcodefinal, i dont have much. but it's very simple, just pixels
<FromGitter> <redcodefinal> @BlaXpirit neato thanks man
<BlaXpirit> basically the only call i have is img[xx, yy].to_rgb8 lol
<FromGitter> <redcodefinal> I am also having an issue with crystal being able to find stumpy. I put it into my shards.yml. I ran ```shards install``` and it downloaded ```stumpy_core``` and ```stumpy_png``` to the libs directory
<FromGitter> <redcodefinal> However when using ```require "stumpy_png``` it says it can't find it.
<BlaXpirit> redcodefinal, what directory structure
<BlaXpirit> if your code is in src/ that may be it
<FromGitter> <redcodefinal> yeah the code im running is in src
<BlaXpirit> from my limited experience, i think itgoes to src only if it's a library
<FromGitter> <redcodefinal> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=581b7f63e097df757567b57f]
<BlaXpirit> if i'm making an app, i usually put everything to the root folder
<FromGitter> <redcodefinal> its a lib im making
<FromGitter> <redcodefinal> im writing pasting tools for stumpy
<BlaXpirit> redcodefinal, hm how to explain it...
<BlaXpirit> when an app gets your library from shards, it will get both libraries in *libs* folder and everything will just work
<BlaXpirit> and maybe you should mock this situation
<BlaXpirit> for developmen
<FromGitter> <redcodefinal> Should I directly reference them using something like ```require "../libs/stumpy_png/*"```
<BlaXpirit> certainly not
<FromGitter> <redcodefinal> should I just put my code in the libs folder?
<BlaXpirit> redcodefinal, you're saying it's a library. so how are you running a library?
<FromGitter> <redcodefinal> I'm confused as how to tell crystal that's where stumpy is
<FromGitter> <redcodefinal> oh i made a test.cr that required stumpy
<FromGitter> <redcodefinal> i see what you are saying
<BlaXpirit> well exactly. that's your "app"
<BlaXpirit> so you can indeed now put your library in `libs` but i have a different common pattern i use
<FromGitter> <redcodefinal> good to know
sustained has quit [Ping timeout: 260 seconds]
<BlaXpirit> libs with a symlink to ../src
<FromGitter> <redcodefinal> jeez you did a chipmunk implementation too, you are a busy dude
<FromGitter> <redcodefinal> ah nice! not a bad solution
<FromGitter> <redcodefinal> until windows support that is ;>
pawnbox has quit [Remote host closed the connection]
bmcginty_ has quit [Ping timeout: 250 seconds]
bmcginty has joined #crystal-lang
<RX14> BlaXpirit, isn't the problem just that @redcodefinal is running crystal from src/ instead of the root?
<FromGitter> <redcodefinal> @RX14 yes that was exactly the problem
<FromGitter> <redcodefinal> I thought shards were global, to the project, not needing to be in the root
<RX14> the chat log is pretty confusing...
vikaton has joined #crystal-lang
<FromGitter> <redcodefinal> So I got a basic copy paste working but I noticed that it won't combine transparencies. anyone know any good way to combine the colors if one is transparent? ⏎ ``````
<BlaXpirit> oh, you need that functionality? I didn't think it would be needed for making a ... collage
<BlaXpirit> combining colors needs a non-obvious formula. that library doesn't do it
<FromGitter> <redcodefinal> shoot
<FromGitter> <redcodefinal> a collage lol
<FromGitter> <redcodefinal> but yeah essentially the way the program I am writing works is it layers little sprite blocks like (this guy)[https://github.com/redcodefinal/isometric-world-generator/blob/master/content/forest/blocks/block/base.png] on top of each other. Some times they have transparencies that aren't zero. Like smoke coming out of a chimney or whatever
bjz has joined #crystal-lang
<FromGitter> <phoffer> How do I copy a file from one location to another? I see `IO.copy`, and that `File` inherits that class method, but I must be missing something because I can’t get it to work
<FromGitter> <jwoertink> @phoffer https://crystal-lang.org/api/0.19.4/FileUtils.html#cp%28src_path%3AString%2Cdest%3AString%29-instance-method
<FromGitter> <jwoertink> I think that's what you'll want to use
<FromGitter> <phoffer> ha duh `FileUtils` just like ruby. thanks guys
<FromGitter> <jwoertink> :+1:
<FromGitter> <phoffer> thanks @sdogruyol good to know that’s there for kemal :)
<FromGitter> <sdogruyol> Hehe
sustained has joined #crystal-lang
<FromGitter> <redcodefinal> @BlaXpirit So I found an [add](https://github.com/l3kn/stumpy_core/blob/master/src/stumpy_core/rgba.cr#L13) method in ```RGBA``` but it combines the transparencies, and I want the end transparency to be 100%, not a combination of the two. I've tried a couple iterations on my own and ended up with [this](https://gist.github.com/redcodefinal/5070aed39cc104a0bf47c6ba064a1d83) which produces the image on the left. It should look
<FromGitter> ... like the one on the right. The ending result should look like the one on the right.
<BlaXpirit> redcodefinal, yeah that's just not the method you want
<BlaXpirit> dubious usefulness
<BlaXpirit> actually the idea seems ok
<FromGitter> <redcodefinal> @BlaXpirit I hate working with colors its such a pain in the butt.
<FromGitter> <redcodefinal> the issue is it combines transparencies so the final image isnt 100% opaque.
<BlaXpirit> i don't know about this any more than you. i just know that crsfml can do this through sfml and opengl
<BlaXpirit> but i also hesitate to recommend the dependency because it's not easily installable
<FromGitter> <redcodefinal> @BlaXpirit yeah and I'm working on an ssh connection right now ;___;
<FromGitter> <redcodefinal> @BlaXpirit getting closer i guess
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <redcodefinal> I did it
<BlaXpirit> gj
<Papierkorb> I have to figure out a way to profile my code. Is there something better than having a profile{ .. } method which logs Time difference?
<BlaXpirit> well there are generic profilers for llvm probably but that can get messy
<Papierkorb> Oh that's interesting. Running the torrent client in release mode has no issues keeping up with stuff, while the default mode one uses constant 100% on busy torrents
<Papierkorb> 100% CPU time*
lacour has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Philpax has joined #crystal-lang
<FromGitter> <redcodefinal> Hey why does Crystal complain when I use types like Int and Float like this? ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=581bba27eed0c3125f32e64a]
<BlaXpirit> redcodefinal, a class needs to have a particular memory layout, you can't use an abstract type there
<FromGitter> <redcodefinal> Ah, can I use union types instead? Like if I wanted to support Int32 and Int64?
<BlaXpirit> i think so. but it's a bit weird
<FromGitter> <redcodefinal> Is there a difference between ```typeof``` and ```.class```? ⏎ ```icr(0.19.4) > typeof(1) ⏎ => Int32 ⏎ icr(0.19.4) > 1.class ⏎ => Int32``` [https://gitter.im/crystal-lang/crystal?at=581bbec645c9e3eb43f591ef]
hako has joined #crystal-lang
<BlaXpirit> redcodefinal, typeof is compiletime, class is runtime
<FromGitter> <redcodefinal> I see
<BlaXpirit> >> x = rand ? 5u32 : 7i8; {typeof(x); x.class}
<DeBot> BlaXpirit: Syntax error in eval:21: expecting token '=>', not ';' - https://carc.in/#/r/1d9p
<BlaXpirit> >> x = (rand ? 5u32 : 7i8); {typeof(x), x.class}
<DeBot> BlaXpirit: # => {(Int8 | UInt32), UInt32} - https://carc.in/#/r/1d9r
<FromGitter> <redcodefinal> It's so weird having to think about the difference between compile time and run time after being in the interpreted world for so long
<FromGitter> <redcodefinal> but so far I'm having a blast with Crystal
<BlaXpirit> also typeof doesnt execute its argument
<BlaXpirit> >> typeof(p "5")
<DeBot> BlaXpirit: # => String - https://carc.in/#/r/1d9t
<FromGitter> <redcodefinal> hmmm
<FromGitter> <redcodefinal> now thats interesting
<FromGitter> <redcodefinal> So I tried this https://carc.in/#/r/1d9z
<FromGitter> <redcodefinal> does it just take the last argument from the method for typeof
<BlaXpirit> redcodefinal, no no, it's just that `p` returns its argument. and also the last expression is returned from the method
<FromGitter> <redcodefinal> but it doesn't execute the method?
<BlaXpirit> sorry for confusion
<BlaXpirit> redcodefinal, it doesnt execute the method. it knows that with these types of arguments the method would've returned that type
Philpax_ has joined #crystal-lang
<FromGitter> <redcodefinal> hmm thats neato
Philpax has quit [Ping timeout: 260 seconds]
<FromGitter> <redcodefinal> When making a method that returns nothing, what data type do you use? Nil?
<BlaXpirit> redcodefinal, yes. though people almost never write that a method returns : Nil
<FromGitter> <redcodefinal> @BlaXpirit whys that? No need because of crystals inference?
vikaton has quit [Quit: Connection closed for inactivity]
<BlaXpirit> redcodefinal, well there's never a need to specify any types in methods. it's all for type safety and documentation
<BlaXpirit> and i guess people just find it weird to write : Nil
<Papierkorb> I do it from time to time to make sure to not return anything, else a user might think that the result of that method is intentional and uses it and then their app breaks down the road or so
<Papierkorb> for private methods I don't care, for some public methods I do care. Though I also tend to write out the (non-nil) return type explicitly if either 1) it's not obvious, so to help the reader 2) the code may be finicky so to make the compiler error out on code changes
<Papierkorb> *bad code changes
<FromGitter> <redcodefinal> Yeah I just like being explicit when dealing with types, I agree with @BlaXpirit about the fear of someone changing something down the road and then their stuff no longer works.
<BlaXpirit> you mean agree with Papierkorb?
<FromGitter> <redcodefinal> derp yes
<FromGitter> <redcodefinal> thought you wrote it
<FromGitter> <phoffer> feeling like an idiot… ⏎ ```in ./_copy.cr:16: undefined constant FileUtils ⏎ ⏎ FileUtils.cp(“path_1”, “path_2”)``` ⏎ what am I missing? [https://gitter.im/crystal-lang/crystal?at=581bca5b4aeee0634dc134ea]
shawn42 has quit [Quit: Connection closed for inactivity]
<FromGitter> <jwoertink> Are you trying to copy a file or directory?
<FromGitter> <phoffer> a file
<BlaXpirit> phoffer, tried `require "file_utils"` ?
<FromGitter> <jwoertink> yeah, that ^
<BlaXpirit> when looking in api documentation, check "Defined in:"
<FromGitter> <phoffer> yep bingo
<FromGitter> <phoffer> is there a way to tell which classes/modules are loaded and what ones i need to explicitly require?
<BlaXpirit> phoffer, well you basically just did that :p
<BlaXpirit> phoffer, seriously though https://github.com/crystal-lang/crystal/blob/master/src/prelude.cr but nobody really checks this file
<FromGitter> <phoffer> haha good point
<FromGitter> <phoffer> oooh thanks for linking that, really useful
<FromGitter> <redcodefinal> @BlaXpirit interesting :>
<FromGitter> <phoffer> so nice that crystal internals are so approachable…just don’t always know where to look