<FromGitter>
<blankoworld> (I just talk about the "hash", it's not the same)
<FromGitter>
<absolutejam_gitlab> `MIME.init false` sorte for now
<FromGitter>
<absolutejam_gitlab> Actually
<FromGitter>
<absolutejam_gitlab> Had a bad URL
<FromGitter>
<absolutejam_gitlab> that it couldn't resolve
<FromGitter>
<atik7> Why puts (2**32).to_s , gives 0 in Crystal, but in ruby its working
flaviodesousa has joined #crystal-lang
<FromGitter>
<naqvis> @atik7 thatβs because output is beyond what `Int32` can hold. You can invoke this operation by casting the val to `Int64` like β β ```pp (2_i64 ** 32).to_s # => 4294967296``` [https://gitter.im/crystal-lang/crystal?at=5d5271451dadc42a11609942]
<FromGitter>
<absolutejam_gitlab> Anyone know how I can get the query params from a http server handler?
<FromGitter>
<absolutejam_gitlab> I changed the request to my OAuth server from `token` to `code`. Looks like it had different reponse mechanisms
<FromGitter>
<absolutejam_gitlab> I wish there were some more examples or docs for `HTTP::Server`
<FromGitter>
<absolutejam_gitlab> I just want to show a basic success message and the docs' example: β β ```code paste, see link``` β β don't seem to print output like I expected, and I don't know how to perform a redirect either [https://gitter.im/crystal-lang/crystal?at=5d527b3bbfd2887f53ddaef5]
<FromGitter>
<absolutejam_gitlab> I basically want the redirect from my OAuth endpoint to hit a basic success page with the auth token removed from the URL
<FromGitter>
<absolutejam_gitlab> Any idea about actually returning content?
<FromGitter>
<absolutejam_gitlab> Thanks for the above response though, I'll try that in a mo
Yxhuvud has joined #crystal-lang
<FromGitter>
<naqvis> you can return content via using `Response#print` or `Response#write`. But redirect shouldnβt contain any body as browsers/clients ignore the payload and just use the `Location`
<FromGitter>
<absolutejam_gitlab> I've done `context.response.print` and there's nothing though, I just get `This page isn't working`
<FromGitter>
<absolutejam_gitlab> I assumed just setting the content type and adding to the `IO` would print it
<FromGitter>
<absolutejam_gitlab> This is prior to any redirects
<FromGitter>
<absolutejam_gitlab> I'll probably redirect to a page that has a response message
<FromGitter>
<Blacksmoke16> @absolutejam_gitlab that was a url fragment, prob part of the implicit SSO flow. uses the `#` because its a client side flow which shouldnt be accessible via a server
<FromGitter>
<absolutejam_gitlab> Yeah, I'd done the implicit flow
<FromGitter>
<absolutejam_gitlab> as I thought it was something else
<FromGitter>
<Blacksmoke16> that would do it
sagax has joined #crystal-lang
lucasb has joined #crystal-lang
<FromGitter>
<absolutejam_gitlab> ohhh
<FromGitter>
<absolutejam_gitlab> it's because I'm exiting too quickly and the server is running in a fiber
<FromGitter>
<naqvis> did you invoked `Fiber.yield` ?
<FromGitter>
<absolutejam_gitlab> No....
<FromGitter>
<naqvis> you need to, as `spawn` isnβt guranteed to be executed immediately. So calling `Fiber.yield` will ensure that
<FromGitter>
<absolutejam_gitlab> it's being launched though because I have a `puts` in there
<FromGitter>
<naqvis> but main thread is getting done prior to spawned code get a chance to respond, so that in turn closed all other spawned processes from the main thread
<FromGitter>
<absolutejam_gitlab> So, just `server.listen` in a fiber?
<FromGitter>
<absolutejam_gitlab> I wrapped the whole HTTP Server in a function which I wrapped in a `spawn do`
<FromGitter>
<Blacksmoke16> the server already spawns fibers to handle requests
<FromGitter>
<absolutejam_gitlab> But I don't want the server running in the fg
<FromGitter>
<Blacksmoke16> for writing specs?
<FromGitter>
<absolutejam_gitlab> I'm basically spinning up the http server to receive the OAuth redirect and that's it
<FromGitter>
<Blacksmoke16> ah
<FromGitter>
<absolutejam_gitlab> and kinda show the 'success!' page
<FromGitter>
<Blacksmoke16> spawns the server in another fiber, runs the block, then stops the server
<FromGitter>
<Blacksmoke16> could do something similar to start it, show the page, then stop it after?
<FromGitter>
<kniknoo> I got my assembler working and spent this morning optimizing. String builder rocks! This morning it was taking me about 12 seconds to do a 26k line "pong" game and now I have it down to about 80 milliseconds.
<FromGitter>
<kniknoo> I like the optimization features we have. I want to figure out a way to redefine the default Int to be, say, an Int16 or UInt8 instead of Int32. I presume if you can guarantee that you will never exceed your limit (or pay the rollover price) that there is a performance boost for working within a smaller word size.
<FromGitter>
<kniknoo> It's been a while, but I remember a lot of these optimizations were handy for NeoPixel programming.
<FromGitter>
<kniknoo> Also, are there no hints for mutable methods? I find that really useful and while I ended up skipping Array.delete_at() in the end, it would be nice to get ! hints still.
<FromGitter>
<naqvis> great job and congratulations @kniknoo π
<FromGitter>
<kniknoo> Thank you! I can't wait to rewrite this for a more familiar grammar. For now, I'm on to chapter 7 where I'll get to make my first real stack VM using crystal!
<FromGitter>
<naqvis> Crystal ain't a functional programming language and by default `Reference` types are immutable. Though one can achieve kind of immutability in Crystal by just using the `Value` types.
<FromGitter>
<kniknoo> Yeah, I got my symbol table all accounted for, but there are still a few errant Int32s in my parser.
<FromGitter>
<kniknoo> Still plenty for me to learn in this domain of crystal. The more I do this the more I want to write an ATMEGA assembler and my own bootloader for arduino.
duane has joined #crystal-lang
<FromGitter>
<bararchy> @faustinoaq Seems the VScode extenstion is misbehaving with latest crystal (or our huge codebase?)
<FromGitter>
<bararchy> Anyone else has this issue?
<FromGitter>
<naqvis> @bararchy if you are using external programs like `scry`, then you will have to compile them after upgrading `crystal`. As Runtime has changed and those external programs are crashing in backend. You can validate the same by simply invoking those external programs and see if they run properly or not
<FromGitter>
<bararchy> Makes sense
<FromGitter>
<bararchy> I guess I'll disable SCRY for now
<FromGitter>
<bararchy> until it works with 0.30.1
<FromGitter>
<naqvis> it works
<FromGitter>
<naqvis> i've recompiled that with 0.30.1
<FromGitter>
<kinxer> Is there a way to test if an object is an instance of a class that inherits a particular module? This doesn't work, but it's descriptive of what I'm trying to do:
<FromGitter>
<kinxer> I am a fool. I just forgot a `.new`... Nevermind.
<FromGitter>
<naqvis> Though bit earlier to ask, but are `Hash` methods *thread-safe*? Or should one need to use `Mutex`?
<FromGitter>
<naqvis> Though current implementation of `Mutex` isn't itself thread-safe yet
<Yxhuvud>
It is not thread safe. Neither is Array methods.
<FromGitter>
<naqvis> thanks Yxhuvud
devil_tux has quit [Ping timeout: 246 seconds]
<FromGitter>
<absolutejam_gitlab> @Blacksmoke16 yeah I got something similar but the server is closing before It's been redirected as the main thread finishes
<FromGitter>
<absolutejam_gitlab> Main fiber*
<FromGitter>
<Blacksmoke16> try doing `sleep` instead of `Fiber.yield`
<FromGitter>
<absolutejam_gitlab> sleep blocks everything though
<FromGitter>
<absolutejam_gitlab> I've tried adding sleeps and loops with `Fiber.yield` but no dice so far
<FromGitter>
<absolutejam_gitlab> I wonder if I do a blocking loop in the main fiber that waits for an exit from the channel
<FromGitter>
<absolutejam_gitlab> Because if I `sleep` in the main fiber, it blocks the bg fiber too
<FromGitter>
<Blacksmoke16> hmm, doing sleep in the main program should allow the other fibers to execute
<FromGitter>
<absolutejam_gitlab> If I do say `sleep 4` in the main program, the redirect from GitLab to my localhost takes 4 seconds then everything continues and I get the 'server dead before redirecting' race condition
<FromGitter>
<absolutejam_gitlab> Think I Might have it
<FromGitter>
<tenebrousedge> o.o
fyber has quit [Read error: Connection reset by peer]
<FromGitter>
<Blacksmoke16> what happens if you do like
<FromGitter>
<Blacksmoke16> i remember something about using `sleep` with a loop
<FromGitter>
<absolutejam_gitlab> Am I being dumb?
<FromGitter>
<f1refly_gitlab> Hello there, I've got an issue with my compile and compiled crystal programs
<FromGitter>
<Blacksmoke16> try using `()`
<FromGitter>
<Blacksmoke16> on send
<FromGitter>
<absolutejam_gitlab> I've wrapped in `()`
<FromGitter>
<absolutejam_gitlab> oh wait
<FromGitter>
<f1refly_gitlab> When I try to run a binay I get a `syncchanges: error while loading shared libraries: libevent-2.1.so.6: cannot open shared object file: No such file or directory` error
<FromGitter>
<absolutejam_gitlab> I have 2 instance
<FromGitter>
<absolutejam_gitlab> and only did one
<FromGitter>
<f1refly_gitlab> And when I try to recompile I get tons of warning also related to that missing library
<oprypin>
f1refly_gitlab, is it actually arch or manjaro?
<FromGitter>
<absolutejam_gitlab> is my build script for a statically compiled/linked binary
<FromGitter>
<absolutejam_gitlab> otherwise you'll need those libs on the target host
<FromGitter>
<f1refly_gitlab> Everytime I try to compile now I have to cancel because it gets stuck and I have to restart to get rid of all the zombie processes that stay after killing it, so I'd rather not do that too much
<FromGitter>
<absolutejam_gitlab> and I'm on manjaro
<FromGitter>
<absolutejam_gitlab> testing the artifact on same system?
<FromGitter>
<f1refly_gitlab> the artifact?
<FromGitter>
<absolutejam_gitlab> the binary
<FromGitter>
<absolutejam_gitlab> that it spits out
<FromGitter>
<f1refly_gitlab> yeah
<FromGitter>
<absolutejam_gitlab> o
<FromGitter>
<f1refly_gitlab> it doesnt spit out anything anymore though
<FromGitter>
<absolutejam_gitlab> oh, it's failing when compiling
<FromGitter>
<absolutejam_gitlab> I thought it compiled then complained when you tried to run it
<oprypin>
absolutejam_gitlab, so umm i just ran `sudo pacman -Sy crystal` and was able to get your error
<oprypin>
but the thing is, you must never run `pacman -Sy`
<FromGitter>
<f1refly_gitlab> No, I tried running an old binary from before the `libevent` update
<oprypin>
f1refly_gitlab, ah. well yeah, that'll do that as well, i suppose
<oprypin>
u can compile it anew or give it the old libevent
<FromGitter>
<f1refly_gitlab> oprypin: you should do that more often, the system tends to break after 6+ months of updates getting done at once in my experience
<oprypin>
(which can also trigger a cascade of old whatever else)
<oprypin>
f1refly_gitlab, im not sure what you mean
<oprypin>
did u think i said that i never update my system? :p
<FromGitter>
<f1refly_gitlab> > *<oprypin>* but the thing is, you must never run `pacman -Sy` β I misread that, so never mind
<FromGitter>
<f1refly_gitlab> Yeah ^^'
<FromGitter>
<f1refly_gitlab> > u can compile it anew or give it the old libevent
<FromGitter>
<f1refly_gitlab> I can't compile it anew because the compiler is broken now :/
<oprypin>
how is it broken
<FromGitter>
<f1refly_gitlab> Should I run it to get some output?
<oprypin>
uhhhh i suppose?
<oprypin>
but only after you upgrade your system fully
<oprypin>
just so we're not chasing a red herring
<FromGitter>
<f1refly_gitlab> I'm fully updated, no worries
<FromGitter>
<f1refly_gitlab> > https://pastebin.com/DVYn8Sy1 β β I still get this error on crystal 30.1, but it's probably related to the gpg shard I use not being updated
<oprypin>
just delete the whole system
<FromGitter>
<f1refly_gitlab> Can I restore from backup afterwards?
<oprypin>
issa joke
<FromGitter>
<f1refly_gitlab> I know, I'm just not good with humorous answers
<FromGitter>
<f1refly_gitlab> But thank for the quick help anyways
<oprypin>
f1refly_gitlab, anyway the real help can happen after this `grep '^S' /etc/pacman.d/mirrorlist | head -1`
<oprypin>
i.e. what's the first configured mirror
<FromGitter>
<Blacksmoke16> could also install via snap
<FromGitter>
<f1refly_gitlab> oprypin: I used a mirror ranker to find the fastest one a year ago, but I'm willing to change. Would you recommend yours?
<FromGitter>
<f1refly_gitlab> @Blacksmoke16 I won't because I despise the goals and design of snap
<FromGitter>
<f1refly_gitlab> oprypin: I just copied the mirrorlist from my pc to my laptop and it works now, so yeah that was the issue
<FromGitter>
<Blacksmoke16> vs having to worry about if your thing is on x but no y etc
<oprypin>
on arch we dont worry
<FromGitter>
<f1refly_gitlab> Yeah but it undermines the whole idea of dynamically linked packages, so you barely have any control over how old the libraries are that your computer is running
<FromGitter>
<f1refly_gitlab> I personally don't want to use openssl from 2008
<FromGitter>
<naqvis> How to retrieve an instance from an array, by providing a method the `Class` of the instance? Suppose I have an array consisting bunch of subclass instances, and I need to find one for particular sub-type. I've tried with `is_a?` but compiler giving me an error that it is expecting `CONST` instead of param name i've provided?
<FromGitter>
<tenebrousedge> ironically, the typescript gitter is having this same discussion, but the problem is not solvable, because TS types don't exist at runtime