jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<raz> brrr for once i have to agree with the hn hivemind
<raz> the new github design is terrible
<FromGitter> <watzon> I actually don't hate it
<FromGitter> <watzon> But I'm usually in the minority when it comes to these things
<FromGitter> <watzon> Not bad if I do say so myself
<FromGitter> <watzon> Which I do
<FromGitter> <Blacksmoke16> neat
<FromGitter> <watzon> Suck on that, Java
<FromGitter> <watzon> Lol
<FromGitter> <watzon> I need to do some cold start benchmarking and see how it compares to Selenium
postmodern has joined #crystal-lang
<raz> noice!
rocx has joined #crystal-lang
oddp has quit [Ping timeout: 265 seconds]
<FromGitter> <watzon> Anyone know how to return an image from a kemal route? I've tried returning the raw bytes and the base64 encoded data while setting the content type to "image/png", but that doesn't seem to work.
<FromGitter> <watzon> Nvm, found `send_file`
<FromGitter> <sam0x17> is it yet possible to call a macro within a macro?
<FromGitter> <Blacksmoke16> nope
<FromGitter> <sam0x17> :(((
<FromGitter> <sam0x17> k
<FromGitter> <Blacksmoke16> well kinda, depends on what you mean exactly
<FromGitter> <sam0x17> I guess I could deal with a macro that writes a macro
<FromGitter> <sam0x17> sort of situation
<FromGitter> <sam0x17> I know that's a thing
<FromGitter> <sam0x17> I have macro A that gets used on it's own and also needs to be used in macro B
<FromGitter> <Blacksmoke16> you can do like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef2ad16c223cc536a307bec]
<FromGitter> <sam0x17> unfortunately I can't in my case, but I might just duplicate the code of macro a
<FromGitter> <sam0x17> as part of macro b
<FromGitter> <Blacksmoke16> what *isnt* possible atm is using macro to share common code within other macro code
<FromGitter> <sam0x17> right
<FromGitter> <sam0x17> which unfortunately what I need
<FromGitter> <sam0x17> so will just not be DRY
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <sam0x17> actually can a macro param have a default value?
<FromGitter> <sam0x17> I might be able to just merge b into a if so
<FromGitter> <Blacksmoke16> i think so yea
<FromGitter> <sam0x17> thx
<FromGitter> <watzon> https://ca7623d59c16.ngrok.io/screenshot/?url=https://github.com/watzon
<FromGitter> <watzon> Well I'll have this up for a few minutes if anyone wants to play. Put in a URL and get a screenshot.
twosecslater has left #crystal-lang [#crystal-lang]
<FromGitter> <watzon> Is it possible to have Kemal routes not block?
<FromGitter> <Blacksmoke16> block how?
<FromGitter> <watzon> Well idk if it's Kemal or something else I'm doing, but I have something happening in the route that could take up to 10 seconds, and it's not allowing other routes to go through until the process is finished.
<FromGitter> <Blacksmoke16> https://github.com/kemalcr/kemal/issues/575 ?
<FromGitter> <watzon> Hmm I don't think so. By itself the route works fine and sends the response in a reasonable amount of time, its just when I try to make multiple requests to the route at the same time that I have trouble.
<FromGitter> <Blacksmoke16> something in implementation that locks something so only 1 fiber can access it at a time?
<FromGitter> <Blacksmoke16> i.e. using a mutex so two separate requests cant access the same file at once?
<FromGitter> <watzon> I'm using a connection pool, so that shouldn't be an issue
<FromGitter> <Blacksmoke16> hm
<FromGitter> <watzon> I'm also watching the system monitor and it's only starting one process from the connection pool. It never grabs a new one because it doesn't get a chance to.
<FromGitter> <watzon> That's what I've got right now
<FromGitter> <Blacksmoke16> not sure, nothing comes to mind
<FromGitter> <Blacksmoke16> maybe try to reproduce with a simpler example then go from there?
<FromGitter> <watzon> Same behavior: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef2c33c7ba3965373c602ef]
<FromGitter> <Blacksmoke16> :0
<FromGitter> <Blacksmoke16> id say thats a simple example
<FromGitter> <watzon> A little lol
postmodern has quit [Quit: Leaving]
<FromGitter> <watzon> I would've thought the routes could be hit concurrently
<FromGitter> <Blacksmoke16> like via multiple curl requests?
<FromGitter> <watzon> Just running in multiple browser tabs. That shouldn't stop it should it?
<FromGitter> <Blacksmoke16> i wouldnt think so
<FromGitter> <Blacksmoke16> my understanding is each request is its own fiber, so you should deff be able to hitup the same route concurrently
<FromGitter> <Blacksmoke16> you could try it out with the default server
<FromGitter> <Blacksmoke16> do something like `http://localhost:3000/?delay=10`
<FromGitter> <Blacksmoke16> query param delay, sleep that amount, have one tab be `10` and another be `5`, do the longer delay first and assert the shorter delay is done first
<FromGitter> <Blacksmoke16> fwiw i tried it with athena and thats what happens, so id assume default server is the same
<FromGitter> <Blacksmoke16> must be something with how kemal is implemented?
<FromGitter> <Blacksmoke16> er you sure @watzon? I tried my idea and it also worked fine
<FromGitter> <watzon> Hmm yeah must be the browser. I used curl in three different tabs and it works as expected.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <watzon> Weird. I would've expected Chrome to run each tab in a different process.
<FromGitter> <watzon> But whatever, as long as it works
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <watzon> I need to add connection pruning to pool
twosecslater has joined #crystal-lang
twosecslater has left #crystal-lang [#crystal-lang]
twosecslater has joined #crystal-lang
zorp_ has joined #crystal-lang
zorp_ has quit [Read error: Connection reset by peer]
<FromGitter> <watzon> @Blacksmoke16 I'm sure you've had to deal with this. How do you handle boolean annotation parameters that default to true?
<FromGitter> <watzon> Because `NamedTupleLiteral` has no `#fetch`
<FromGitter> <watzon> And `ann[:option].nil?` doesn't work for some reason, so I'm having to do `%option = {{ ann[:option] }}.nil? ? true : {{ ann[:option] }}` which is fugly.
deavmi_ has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
Welog has joined #crystal-lang
deavmi_ has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
ghanima has joined #crystal-lang
<FromGitter> <richarddewit> I cant get ameba to work in both Emacs and VSCode. Error: ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5ef3181b7ba3965373c6ca7c]
<FromGitter> <richarddewit> When I run `ameba` from in the terminal it does work as intended though
oddp has joined #crystal-lang
alexherbo2 has joined #crystal-lang
ep4sh has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
csaba has quit [Ping timeout: 246 seconds]
csaba has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
HumanGeek has quit [Remote host closed the connection]
HumanGeek has joined #crystal-lang
HumanGeek has quit [Quit: Leaving]
<FromGitter> <Blacksmoke16> @watzon `{% option = ann[:option] != nil ? ann[:option] : false %}`
<FromGitter> <Blacksmoke16> fixed
HumanG33k has joined #crystal-lang
<FromGitter> <phykos> @Blacksmoke16 with 4G + 3G of swap they should be enough to bootstrap the compiler?
<FromGitter> <Blacksmoke16> id hope so
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
<FromGitter> <confact> I now have 24 stars on Kindmetrics, most from the crystal community so just want to say thanks. You boost and motivates me on building some cool crystal project!
deavmi has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
HumanG33k has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
<FromGitter> <phykos> @Blacksmoke16 on `watch swapon --show` it says 267M from a couple of minutes
<FromGitter> <Blacksmoke16> and it finished?
<FromGitter> <phykos> Not yet
<FromGitter> <phykos> 1) 43/3.73 RAM used
<FromGitter> <phykos> For now
<FromGitter> <phykos> Running the compiler with `-pts` says this:
<FromGitter> <phykos> `[12/13] [0/1] Codegen (bc+obj)`
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <Blacksmoke16> so it failed?
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
deavmi has quit [Client Quit]
deavmi has joined #crystal-lang
<FromGitter> <watzon> Ahh @confact I forgot kindmetrics was yours. Great job with that.
<FromGitter> <watzon> Trying to figure out if there would be a good way to pipe a process output and error to a `Log`
<jhass> Ctrl+F LogIO
<jhass> we had that like yesterday :D
<FromGitter> <watzon> If there was an event driven IO it would be easy to just say `io.on_write { |data| Log.info { data } }` or something.
<FromGitter> <watzon> `IO::Evented` doesn't seem to live up to its name in that regard though
<jhass> watzon: https://play.crystal-lang.org/#/r/9awb (in courtsey of oprypin)
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo21 is now known as alexherbo2
<FromGitter> <asterite> I think you can do `while line = output.gets` then send it to the log. I'm not sure using an IO for this is the best idea. An IO works by doing `write` and that can be any amount of data, but logger works by outputting lines. The buffered trick is nice but I'm not sure it'll always work
<FromGitter> <watzon> That blocks though doesn't it? So I imagine it would have to be done in a separate fiber?
<jhass> the edge case it has is that it'll write a line onto two log lines if it exceeds the buffer size. Could argue that a feature though
<FromGitter> <watzon> Yeah turns out actually logging this process output isn't a good idea anyway
<FromGitter> <watzon> I need to scan the output for data
mps has joined #crystal-lang
<FromGitter> <wyhaines> Thoughts? I can't get an insert with a bind variable to work. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ef37b4e7ba3965373c7ee39]
<FromGitter> <watzon> Doesn't it need a semicolon at the end?
<FromGitter> <watzon> @wyhaines ^
<FromGitter> <naqvis> @wyhaines pg expects params to be in `$` format, `?` is for mysql. ⏎ `db.exec("insert into tags (tag) values ($1)", args)`
<FromGitter> <naqvis> PostgreSQL uses `$n` where `n` is the ordinal number of the argument (starting with 1).
<FromGitter> <wyhaines> @naqvis Ah! I just assumed that the code under the covers standardized it. Thank you.
<FromGitter> <watzon> Ahh weird
<FromGitter> <naqvis> 👍
<FromGitter> <asterite> also probably needs to be `args: [args]`
<FromGitter> <phykos> Finally I managed to bootstrap the compiler, but `crystal --version` returns `1.0.0-dev ()` and other stuff.
<FromGitter> <phykos> Is this right?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> because you built master
<FromGitter> <Blacksmoke16> which is ahead of latest release
<FromGitter> <phykos> Kk
<FromGitter> <phykos> I had to use a 16G usb stick for swap btw
<FromGitter> <Blacksmoke16> xD
<FromGitter> <phykos> Lmao
<FromGitter> <phykos> Also I had to `gcc -c` and `g++ -c` some files, should I make a PR?
<FromGitter> <Blacksmoke16> https://forum.crystal-lang.org/t/problem-compiling-crystal-from-source-on-raspberrypi-4/1395 id read thru here first if you haven't already
<FromGitter> <phykos> ok
livcd_ has quit [Ping timeout: 265 seconds]
<jhass> whose idea was that 😕 https://carc.in/#/r/9bl0
<FromGitter> <grkek> @Blacksmoke16 just accept the PR god damn
<FromGitter> <Blacksmoke16> 😕
<FromGitter> <grkek> Whats with that face brother :D
<FromGitter> <grkek> I mean how do you expect me to download menson, ninja build the project, copy the lib.so to the correct path and then build it on a CI
<FromGitter> <Blacksmoke16> its probably possible, im kinda skeptical that there is 0 tests you can write. Unrelated to that PR wouldn't that make it *super* hard to work with if there is no way to automate testing to ensure changes dont break anything?
<FromGitter> <sardaukar> is there a problem with --exclude-warnings in 0.35.1? I have it set to exclude warnings from `/home/sardaukar/.asdf/installs/crystal/0.35.1/share/crystal/src/` and I get warnings from `/home/sardaukar/.asdf/installs/crystal/0.35.1/share/crystal/src/logger.cr:140:3`
<FromGitter> <asterite> jhass: I think it's convenient to do `a <= b <= c`, also maybe `a == b == c`
<jhass> I kinda can see a < b < c, though it has the same problem
<jhass> my problem is that it's special knowledge to parse the chain as a single expression rather than a composed expression
<jhass> like I kinda knew about a < b < c but never used it because I never felt confident about remembering it right
<jhass> maybe too much language hopping, but yeah
<FromGitter> <grkek> @sardaukar I used your elixir bank api example for the event sourced app that is pretty awesome, thank you mate
<FromGitter> <thelinuxlich> are there any crystal books from 2019-2020?
<FromGitter> <thelinuxlich> I've bought a great one from PragProg, but it's 2018
<FromGitter> <sardaukar> @grkek glad you found it useful! :D
<FromGitter> <sardaukar> question: when you use OptionParser, does --exclude-warnings stop working? I thought if you used `--` to separate Crystal's from your options, OptionParser would only parse yours
<FromGitter> <Blacksmoke16> what command are you running?
<FromGitter> <sardaukar> `crystal src/project.cr --exclude-warnings=/home/sardaukar/.asdf/installs/crystal/0.35.1/share/crystal/src/ --exclude-warnings=lib/ -- -rr`
<FromGitter> <sardaukar> and I get `ERROR: --exclude-warnings=/home/sardaukar/.asdf/installs/crystal/0.35.1/share/crystal/src/logger.cr is not a valid option.`
<FromGitter> <Blacksmoke16> try doing `crystal run ...`
<FromGitter> <Blacksmoke16> and move your arguments *before* the file
<FromGitter> <sardaukar> ok that works! thanks
<FromGitter> <Blacksmoke16> some of how this worked changed a bit in `0.35.1`
<FromGitter> <Blacksmoke16> `0.35.0`*
<FromGitter> <asterite> jhass: I agree with you and if we can remove it from the language I think it's better
<jhass> probably a 2.0 thing if anything
<jhass> I wonder if other languages do this though, I feel like I've seen it somewhere else
<jhass> kotlin maybe?
<jhass> mh, no they seem to solve it with ranges (x in 1..10)
<FromGitter> <watzon> Python allows chaining like that
<FromGitter> <watzon> Iirc
<FromGitter> <asterite> Yes! Because it seems `True <= 2` is True (wat)
<FromGitter> <asterite> Oh, my, `True == 1` is True, and `False == 0` is true in Python
<FromGitter> <watzon> Yeah python has a lot of truthy and falsy values
<FromGitter> <asterite> Ah, no, chaining works indeed
<FromGitter> <Blacksmoke16> in ruby `or` and `||` work differently too iirc
<FromGitter> <asterite> just precedence difference
<FromGitter> <watzon> Yeah, `||` has a higher precedence
<FromGitter> <watzon> So it's not possible to create an `HTTP::Client` instance without a host. What should I do when I want people to be able to pass in their own client instance so they can do stuff like add a proxy, or use a completely different method of fetching pages (like with Marionette).
<FromGitter> <watzon> Right now I'm doing this (https://github.com/watzon/arachnid/blob/master/src/arachnid/agent.cr#L25), but this doesn't allow you to pass in a client that needs custom initialization.
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <asterite> As far as I know the host is a required header, so that's why
<FromGitter> <watzon> I think I figured out a solution, just requires a bit more abstraction and an abstract class
<FromGitter> <watzon> I guess we'll see
rocx has quit [Remote host closed the connection]
HumanG33k has quit [Ping timeout: 264 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <watzon> Hmm, would've thought that making a field in a JSON serializable object `JSON::Any` would
<FromGitter> <watzon> have used `JSON.parse` on the raw string
<FromGitter> <watzon> Instead I end up with a JSON string
HumanG33k has quit [Ping timeout: 240 seconds]
HumanG33k has joined #crystal-lang
Human_G33k has joined #crystal-lang
ep4sh has quit [Quit: WeeChat 1.9.1]
HumanG33k has quit [Ping timeout: 260 seconds]
Human_G33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
ryanprior has joined #crystal-lang
<ryanprior> I was under the impression that you can disable the gc and do manual memory management with object destructors if you don't want gc, but I can't find any docs for that. Am I making this up or is this a thing?
<FromGitter> <Blacksmoke16> iirc its like `-Dgc_none` or something like that
<FromGitter> <watzon> Yeah. You can technically disable the GC, but you also have to run with no standard library since the whole standard library relies on it.
<FromGitter> <watzon> That is until someone decides to rewrite the entire standard library
<ryanprior> Ah, but we could have a separate prelude that uses manual memory management if we wanted to?
<ryanprior> Also is there any documentation for this or is just kinda community insider knowledge?
<ryanprior> Also how do you manually free an object?